Reputation: 17
I need to create a rotation function that will be used to rotate items around, it nearly works apart from when trying to do -sin. There doesnt seem to be a function that allows this.
Matrix.createRotation = function (rotation) {
return new Matrix(Math.cos(rotation), Math.sin(rotation), 0,
Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
};
Upvotes: 0
Views: 848
Reputation: 8530
You have to negate the result of Math.sin(rotation)
as -Math.sin(rotation)
:
Matrix.createRotation = function (rotation)
{
return new Matrix(
Math.cos(rotation), -Math.sin(rotation), 0,
Math.sin(rotation), Math.cos(rotation), 0,
0, 0, 1
);
};
Note that -Math.sin(rotation)
is faster than (-1)*Math.sin(rotation)
.
Upvotes: 1