# URGENT - Rotation questions..

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

## 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 on other sites
Hi ArchangelMorph, this is how you do it:

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

##### 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 on other sites
Thnx sooo much guys!!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634047
• Total Posts
3015232
×