INTERFACEQuaternion ; IMPORT Matrix4; TYPE T = RECORD a, b, c, d : REAL; END; PROCEDURE FromMatrix4 (READONLY M : Matrix4.T) : T;
FromMatrix4(M)
takes an orthonormal matrixM
and returns the corresponding quaternionq
.q
will have unit norm.
PROCEDURE ToMatrix4 (q : T) : Matrix4.T;
ToMatrix4(q)
takes a unit norm quaternion and returns an orthonormal matrixM
that corresponds to this quaternion.
PROCEDURE Interpolate (q : T; f : REAL) : T;
Interpolate (q,f)
takes a unit norm quaternionq = (a,b,c,d)
and a realf
between 0 and 1, and returns a unit norm quaternion. MappingInterpolate
over the range [0,1] and applyingToMatrix4
to the results yields a series of matrices that describe a ``smooth'' rotation, withMatrix4.Id
as the initial matrix andToMatrix(q)
as the final matrix.
END Quaternion.