Linus Posted January 15, 2013 Posted January 15, 2013 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?
frustum Posted January 16, 2013 Posted January 16, 2013 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();
Linus Posted January 16, 2013 Author Posted January 16, 2013 Thanks a lot, I reproduced the code in UnigineScript and it all works fine now. :)
Recommended Posts