Jump to content
  • Advertisement
Sign in to follow this  
Johannes1991

Turn Object around Point

This topic is 2607 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

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.

Thanx in advance

Share this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!