forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rotation Math Question

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
BlackDragon777



Joined: 15 Sep 2005
Posts: 32

PostPosted: Sun Sep 25, 2005 11:36 am    Post subject: Rotation Math Question Reply with quote

Hey everyone. I have a simple math question for you. I know how to rotate a point about the origin by using matricies. I also know how to do it using the formula.

The way I do it is

x = x*cos(theta) - y*sin(theta)
y = x*sin(theta) + y*cos(theta)

However I want to rotate my triangle about an arbitrary point. I read in my graphics book that the way to do that using a formula would be,

x = x*cos(theta) - y*sin(theta) + ORIGIN_VARIABLE
y = x*sin(theta) + y*cos(theta) + ORIGIN_VARIABLE

HOwever that doesn't seem to work. I am not great at math. I can do it with matricies but I think it is easier and faster to use a formula if at all possible. can anyone correct my latter formula? Thanks!
Back to top
View user's profile Send private message
AudioMonster



Joined: 07 Sep 2005
Posts: 37

PostPosted: Sun Sep 25, 2005 4:39 pm    Post subject: Reply with quote

I am not good a 3D maths too but i can try :

Your first formula rotates the point [X Y] around [0 0]
Your second formula does the same but then translates the rotated point by [OriginX OriginY].

What you want to do is to rotate around [OriginX OriginY], so you have to translate each point by [-OriginX -OriginY] and do a rotation around [0 0] by using your first formula, then you retranslate the rotated point by [OriginX OriginY].

Like:

x' = x - OriginX;
y' = y - OriginY;

x = x'*cos(theta) - y'*sin(theta) + OriginX;
y = x'*sin(theta) + y'*cos(theta) + OriginY;

That SHOULD work, but i don't guarantee anything ;)
There is probably a way to simplify that though.
Back to top
View user's profile Send private message Visit poster's website
ector



Joined: 12 May 2005
Posts: 195

PostPosted: Sun Sep 25, 2005 4:52 pm    Post subject: Reply with quote

AudioMonster wrote:
There is probably a way to simplify that though.


Yes, you can express all of these operations as 3x2 matrices, and multiply them all together into one. Though depending on your previous level of math knowledge, that may or may not be a simplification to you :)
_________________
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
Back to top
View user's profile Send private message
AudioMonster



Joined: 07 Sep 2005
Posts: 37

PostPosted: Sun Sep 25, 2005 5:02 pm    Post subject: Reply with quote

Would that achieve less multiplication / additions ?
Back to top
View user's profile Send private message Visit poster's website
BlackDragon777



Joined: 15 Sep 2005
Posts: 32

PostPosted: Sun Sep 25, 2005 5:07 pm    Post subject: Reply with quote

Hey! Thanks! I wasn't subtracting the origin points away. Thanks, that fixed my problem!

GOD Bless you Always!!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group