Jump to content

[SOLVED] Angular velocity to orientation


Recommended Posts

I'm trying to calculate how the angular velocity of an object will affect it's orientation.
The predicted orientation I get doesn't look anything like the rotation I get with Unigine physics.

I'm using this code to calculate the new orientation:

quat rotation = object.getRotation();
rotation *= quat(normalize(angularVelocity), length(angularVelocity) * ifps);
object.setRotation(rotation);

Can anybody point me out why this produces the wrong results?


 

Link to comment

This is an engine code which calculates the rigid body orientation:

 

quat q;

q.x = angular_velocity.x * ifps;

q.y = angular_velocity.x * ifps;

q.z = angular_velocity.x * ifps;

q.w = 0.0f;

 

q = q * orientation;

 

orientation.x += q.x * 0.5f;

orientation.y += q.y * 0.5f;

orientation.z += q.z * 0.5f;

orientation.w += q.w * 0.5f;

 

orientation.normalize();

 

Link to comment
×
×
  • Create New...