Jump to content

  • Log In with Google      Sign In   
  • Create Account

Turn Object around Point


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Johannes1991   Members   -  Reputation: 433

Like
0Likes
Like

Posted 26 October 2011 - 07:06 AM

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:
Pic.png
The Plus is the Box Mesh Origo and the red circle is the Rotation Point.

Thanx in advance
EnJOJ Gaming

Sponsor:

#2 clb   Members   -  Reputation: 1789

Like
0Likes
Like

Posted 26 October 2011 - 11:25 AM

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.


Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#3 Juliean   GDNet+   -  Reputation: 2722

Like
0Likes
Like

Posted 26 October 2011 - 11:55 AM

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;

#4 WiredCat   Members   -  Reputation: 375

Like
0Likes
Like

Posted 27 October 2011 - 03:02 PM

or check this

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS