Jump to content

  • Log In with Google      Sign In   
  • Create Account

rotate point around origin by angle


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 shaKu_shawn   Members   -  Reputation: 122

Like
0Likes
Like

Posted 14 August 2007 - 12:02 PM

I am not 100% clear on the math for what i am trying to do... let me give you a sample situation... i have a point lets say 15,5 which is the point of an arrow. I have another point which is the base of the arrow (my origin) which is 2,2... what i am doing is i need to rotate the arrow on its origin by 45 degrees and find out the new point for the tip... if somone could give me the equation and a sample solution using the equation for these values it would be great!

Sponsor:

#2 scgames   Members   -  Reputation: 1977

Like
0Likes
Like

Posted 14 August 2007 - 12:09 PM

This isn't homework, is it? (Just checking...)

Anyway, to rotate about an arbitrary point:

1. Translate the point by the negative of the pivot point
2. Rotate the point using the standard equation for 2-d (or 3-d) rotation
3. Translate back

#3 wentworth   Members   -  Reputation: 168

Like
0Likes
Like

Posted 15 August 2007 - 12:05 AM

jyk is correct, and here is an example of how you would do that:


Firstly, translate:

v = (15,5) - (2,2) = (13,3)

Now rotate by 45°:

v = (13*cos 45° - 3*sin 45°, 13*sin 45° + 3*cos 45°) = (7.07.., 11.31..)

And finally, translate back:

v = v + (2,2) = (9.07.., 13.31..)


And there's your answer.


(For the rotation stage, you might find this useful:
http://mathworld.wolfram.com/RotationMatrix.html )

#4 shaKu_shawn   Members   -  Reputation: 122

Like
0Likes
Like

Posted 15 August 2007 - 05:37 AM

haha nah its not homework... working on a 2d sprite based game in XNA and needed this equation for translating the sprite per-pixel collision information based on the current sprite rotation ;) (the game is just for fun by the way)... thanks a ton for the help!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS