23rd July 2002 02:53 UTC
Rotation
I was wondering if anyone could post a movement code for rotation.
Archive: Rotation
ryan
23rd July 2002 02:53 UTC
Rotation
I was wondering if anyone could post a movement code for rotation.
UnConeD
23rd July 2002 11:57 UTC
Mmmm this needs to become a FAQ. Basic rotation goes like this:
x' = x*cos(a) - y*sin(a);
y' = x*sin(a) + y*cos(a);
where a is the angle in radians.
This rotates the point (x,y) around the origin to become (x',y'). To rotate around a different point, first translate the point so that the rotation center is the origin, and then translate back again.
For 3D, you can rotate around the 3 axes by using (x,y), (x,z) or (y,z) as the coordinates in the formula above.
Fork me on GitHub