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!
Rotation Math Question
-
- Posts: 37
- Joined: Wed Sep 07, 2005 3:41 am
- Contact:
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.
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.
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 :)AudioMonster wrote:There is probably a way to simplify that though.
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
-
- Posts: 37
- Joined: Wed Sep 07, 2005 3:41 am
- Contact:
-
- Posts: 32
- Joined: Thu Sep 15, 2005 8:26 am