# rotation about an arbitrary point

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

## Recommended Posts

if a point rotates through 'theta' about the origin, how do i calculate through how much it has been rotated about an arbitrary point (rx, ry) ?

##### Share on other sites
I'm not sure I understand the question but how about something like:
vOldVec  = Normalize(pOldPosition - pArbitraryPoint)
vNewVec = Normalize(pNewPosition - pArbitraryPoint)

fAngle = acos( DotProduct(vOldVec,vNewVec) )

Of course this doesn't give you a direction of rotation however I'm not even sure that even applies given the problem.

##### Share on other sites
Quote:
 Original post by manu1001if a point rotates through 'theta' about the origin, how do i calculate through how much it has been rotated about an arbitrary point (rx, ry) ?

It won't really work for an arbitary point. If you are just transforming a single point (which goes from it's original position a, to it's transformed position b), then only the points that lay on the line through the origin, and a point halfway points a and b, might be the center of a rotation that transform that partcular point from a to b, but as soon as you want to rotate multiple points using the same rotation, then it generally won't be possible to express that rotation as a rotation around any other point than the origin.

But I have the idea that you really are trying to do something else though, so maybe you could be a bit more specific on what you're trying to do?

[Edited by - quasar3d on May 2, 2009 7:52:59 PM]

##### Share on other sites
You have to 'bring' the point about which you want the rotation to happen to the origin.
Then Apply the rotation and finally 'undo' your first translation.

In homogenous coordinates we would have:

$\begin{pmatrix} R_x\\ R_y\\ 1 \end{pmatrix} = \begin{pmatrix} 1 & 0 & P_x\\ 0 & 1 & P_y\\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 1 & 0 & -P_x\\ 0 & 1 & -P_y\\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x\\ y\\ 1 \end{pmatrix}$

Where:

(Px, Py) is the point to rotate about
(x, y) is the point you want transformed
theta is the angle of rotation
(Rx, Ry) is the rotated point

If you do the Matrix multiplications you will find a formula for Rx and Ry:

$\begin{pmatrix} R_x\\ R_y\\ 1 \\ \end{pmatrix} = \begin{pmatrix} \cos\theta & -\sin\theta & [P_x(1-\cos\theta) + P_y\sin\theta] \\ \sin\theta & \cos\theta & [P_y(1-\cos\theta) + P_x\sin\theta] \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x\\ y\\ 1 \end{pmatrix}$

So, if I'm not wrong, the final formula to rotate about a point in 2-space would be:

$\\ R_x = x\cos\theta - y\sin\theta + [P_x(1-\cos\theta) + P_y\sin\theta] \\ R_y = x\sin\theta + y\cos\theta + [P_y(1-\cos\theta) + P_x\sin\theta] \\$

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633300
• Total Posts
3011266
• ### Who's Online (See full list)

There are no registered users currently online

×