could you give me a tip please, a redirection to what is the "simple" math I need to learn and understand for the rotation of an object (its coordinate x, y) around an other object (an other x, y), I guess I could also describing my need as (x, y) moving coordinate orbiting around (x, y) fixed coordinates. It is for a little HTML5/Javascript game. Thank you.
Answer
You don't need matrices at all. Just take the rotation angle in radians, get its cosine and sine, multiply them by the distance you want between the two objects and add the x and y values of the fixed object:
rotatingObject.x = Math.cos(rotationAngle) * distance + fixedObject.x
rotatingObject.y = Math.sin(rotationAngle) * distance + fixedObject.y
No comments:
Post a Comment