Jump to content
  • Advertisement
Sign in to follow this  
BaCaRoZzo

Local to Global frame, translation and rotation

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

Hi all,

I've read a lot of stuff (also several thread here) but I'm a bit confused on the best choice (in term of simplicity and efficiency) to update the position of my simulated elements.
I've rigid shapes expressed in term of a local frame and a corresponding transformation matrix 4x4 which translates and rotates bodies from local frame to global one. I've also a constant translation velocity and a constant angular velocity (two vectors in m/s and rad/s) which are updated at certain intervals.

Now, if I want to update the position of a body I just need to update its rotation matrix and its translation vector in the 4x4 matrix. The translation vector can be easily updated:

translation += vel * simulationStep

The rotation matrix can be update independently (since in the simulation I've no constraint which related translation and rotation). Now, the first choice I've found is pretty easy: since I can concatenate two rotations by multiplying their matrices, I calculate the rotation matrix for the current angular velocity, in term of roll, pitch and yaw (my library has a function for this purpose) and then multiply the matrices. That is (warning: sort of pseudo-code!):


vector3 rot; //set to the scalar product of the angular velocity vector and the simulationStep
Matrix3 matrix;
matrix.setRpy(rot.z, rot.y, rot.x); //create the matrix with the roll pitch and yam desired
matrix * rotationMatrix; //rotationMatrix is the current 3x3 rotation matrix in the 4x4 transformation


It is easy and it works (or at last it seems so). Using quaternion, i.e. converting the 3x3 matrix to a quaternion and work with it would be better of could I encounter a performance bottleneck in the conversion? My libraries relies on the 4x4 matrices thus I would end up converting two times (mat--> quat--> mat).

Any advice is really appreciated.
Thanks in advance.
Baca.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!