Jump to content
  • Advertisement
Sign in to follow this  
ArchangelMorph

URGENT - Rotation questions..

This topic is 4904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I rotate a point around the origin by lets say 30 degrees for example? If I have a point at (4,7) how do I rotate it about the origin in the 2D plane (rotation about the Z-axis)..?

Share this post


Link to post
Share on other sites
Advertisement
Hi ArchangelMorph, this is how you do it:

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

Share this post


Link to post
Share on other sites
I'll assume you have a little knowledge of Matrix multiplication. I use a column vector convention... so, if I wanted to rotate the point x,y about the origin by angle Z. I would multiply:
|cosZ -sinZ||x|
|sinZ cosZ||y|
Using homogeneous coordinates this becomes:
|cosZ -sinZ 0||x|
|sinZ cosZ 0||y|
| 0 0 1||1|

In case you didn't know matrix multiplication this is how it works:
You can only multiply matrices whose inner dimension are the same. For example this is a 3x3 * 3x1. You could NOT do 3x3 * 1x3. The result is the outer dimensions. In this case a 3x1. To find a specific elements [j] answer you take the dot product(i'll elaborate later) of the ith row of the first matrix and the jth column of the second matrix.

The dot product is computed as follows. For 2 elements. List1 = {a,b}, List2 = {c,d}... dot product = a*c + b*d... For 3 elements. List 1 = {a,b,c}, List2 = {d,e,f}... dot product = a*d + b*e + c*f... and so on for more elements you just sum the products of elements in the same position. Hope that helped

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!