# Turn Object around Point

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

## Recommended Posts

I've been trying to rotate a box around a certain point (for the purpose of angular velocity). I Know how to rotate the mesh around a point by changing the origo in mesh space, but the problem is that the i don't know how to rotate the Position variable too. Because if i change the rotation point(and the mesh origor) then the box "jumps" so the new origo in mesh space.

Here's a pic for further explanation:
[attachment=5856:Pic.png]
The Plus is the Box Mesh Origo and the red circle is the Rotation Point.

##### Share on other sites
To rotate an object around the origin, generate the primitive rotation matrix M e.g. by axis and angle, from one of the conventions for Euler angles, from a quaternion, etc. To adjust M to rotate about an axis that contains the given point P on the rotation axis, translate the vector space origin to the point P, then perform the rotation, and finally translate back, i.e. M' = T(P) * M * T(-P), where the matrix T(x) translates by x.

Use the resulting matrix M' to transform the coordinate frame of the box. If your box is represented by a center point and three direction vectors, e.g. like OBB here, then remember to use the transformation matrix M' to transform the pivot point of the OBB as a point vector, and the axes of the box as direction vectors. See here.

If you have any questions of the code implementation, I'll try to clarify.

##### Share on other sites
Translate your mesh in the point you want the mesh to rotate around to origin -> rotate -> translate back. You will need multiple translation matrices to rotate around certain points. Looks like this:

MatrixTransform(mTrans1; -Point);
MatrixRotate(mRotate; angel);
MatrixTransform(mTrans2; Point);

mWorld = mTrans1 * mRotate * mTrans2;

##### Share on other sites
or check this

http://www.swissdelphicenter.ch/torry/showcode.php?id=2093

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 11
• 9
• 11
• 15