Advertisement

Rotations... 2d and 3d??

Started by August 29, 2000 02:20 PM
3 comments, last by Wrathnut 24 years, 3 months ago
I''ve got a formula for a rotation of a point about the origin, it goes like this: X'' = x*cos(theta) - y*sin(theta) Y'' = x*sin(theta) + y*cos(theta) This works great about the origin, but I need to get this to rotate about some arbitrary point, not the origin. I was hoping somebody else would have an idea of how to do this... BTW I''m working in 2d coords for now, although, I''m going to be moving this to 3d coords soon, so which ever way you know how to do it I''d be happy to see. Thanks! War doesn't determine who is right, war determines who is left.
Your formula works correct. This is basicaly what is done with inside of a rotation matrix. But in order to get something to move on an arbitrary point you''d have to move(also known as translating) the object to the origin, rotate it, and then add the new rotated points to the value by which you moved the object to get it to the origin.
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
Advertisement
evaclear is right, you need to translate it to the origin in memory, rotate it in memory, translate it back to it''s original position on the grid, and then display it
very quickly, in equation form...

X'' = (x-a)*cos(theta) - (y-b)*sin(theta) + a
Y'' = (x-a)*sin(theta) + (y-b)*sin(theta) + b

Very Cool! Thanks alot for everyones help, It seems kinda trivial now that I know the answer, but I was going about the translation all wrong, Thanks again!

War doesn't determine who is right, war determines who is left.

This topic is closed to new replies.

Advertisement