# Local to Global frame, translation and rotation

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

## 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).

Baca.

• ### 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!

• 19
• 36
• 9
• 16
• 75