Skip to main content
gamedev.net
🔒 Locked

simple math question

Started by CCF 7 replies 1.5k views
Original Post
CCF
CCF
Hi there, It''s easier to understand this if it''s illustrated but lets say I have a point located in XY-coord at (100, 0). If I rotate the point 30 degrees (in any direction) at it''s base (0,0) where will the point be located now? I just need to know the method of calculating it. Thanks!
Ironside
Ironside
newX = oldX * cos(30) - oldY * sin(30)
newY = oldY * cos(30) + oldX * sin(30)

replace 30 with any arbitray angle in degrees.

Edited by - ironside on January 18, 2002 2:37:14 AM
CCF
CCF
Thanks, guys! I''ll go try it out.
CCF
CCF
KalvinB:
Could you provide an algorithm to do it? I don''t fully understand the sine and cosine part (my math sucks... ). Direction of rotation doesn''t matter (anyway will do).

Ironside:
Hmmm... I couldn''t get it to work using the method you''ve provided (the point doesn''t rotate correctly from it''s base). Is there another way to do it or I might be implementing it wrongly?

Thanks!
CCF
CCF
Oh, Ironside''s method is almost right. Just that it''s not rotating at the specified degrees. Any solutions?
DefCom
DefCom
Please remember to take into account the computer works in radians, not degrees. I had(have) the same problem.
cabbage
cabbage
make sure you are passing in your angle in radians and not degrees.

rad = 2pi * deg / 360
CCF
CCF
It''s working! Yay! Thanks everyone!

I used this method to convert degrees into radian :
radian = degrees * (pi / 180)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.