#### Archived

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

# 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.

## 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 on other sites
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 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 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 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.

1. 1
Rutin
41
2. 2
3. 3
4. 4
5. 5

• 16
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011524
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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!