Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Wrathnut

Rotations... 2d and 3d??

This topic is 6654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!