Quaternion Functions OK ?

Blitz3D Forums/Blitz3D Programming/Quaternion Functions OK ?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Quaternions are essentially the same as angle/axis, with some restrictions.

Quaternion (w,x,y,z) represents a rotation around an axis.

1. The axis points in the same direction as vector (x,y,z).
2. w is the cosine of half the angle of rotation.
3. The quaternion is scaled so it has length 1.

For example, consider a rotation of 120 degrees around the Y+ axis.
The angle is 120, so w is Cos(60).

(x,y,z) must point in the direction of (0,1,0).
This can be anything of the form (0,y,0), where y is a positive number.
But rule #3 says w*w + x*x + y*y + z*z = 1.0, so 0.25 + y*y = 1.0.
So y must be Sqr(0.75).

Thus the quaternion (w, x, y, z) is about ( 0.5, 0, 0.866, 0 ).

But if you try this with the test code EulerToQuat gives (x,y,z) = ( 0, 0, 0.866 ).

The coordinates x,y,z are mixed up. And a change in handedness can't explain this.
That would change the sign of something, interchanging positive and negative.