Across my travels on the internet I have came across two different ways of integrating a scaled axis angular velocity into a quaternion.
The first way converts the angular velocity into an axis angle quaternion like so
Quaternion q = new Quaternion(vector.normalised(), vector.getLength());
Where the constructor looks like:
float sinHalfAngle = (float) Math.sin(angle / 2); float cosHalfAngle = (float) Math.cos(angle / 2); this.x = axis.x * sinHalfAngle; this.y = axis.y * sinHalfAngle; this.z = axis.z * sinHalfAngle; this.w = cosHalfAngle;
And then multiplies the existing quaternion by that new quaternion
The second approach also converts the velocity into a quaternion, but uses a different method:
Quaternion change = Quaternion.mul( new Quaternion(x * 0.5f, y * 0.5f, z * 0.5f, 0), this );
It then adds the quaternions together, scaled by delta T:
this.w += change.w * scale; this.x += change.x * scale; this.y += change.y * scale; this.z += change.z * scale;
Both approaches produce a rotation, however the first approach rotates the object much faster than the second. I was wondering which is the 'more' correct way, or if they are just different methods used for different units perhaps? (ie: degrees vs radians?)
Thanks very much if you can help.