Quaternion schema, conversion helpers, normalization helpers, interpolation helpers, and quaternion-derived rotation matrices.
Quaternion values expose one marker field, QUATERNION, and one four-entry field, entries.@ (ordinal quaternion -- ref) returns Ref to the selected entry through entries.! (value ordinal quaternion --) writes one selected entry through entries.fieldCount (quaternion -- count) always returns 4.vector (quaternion -- entries) returns a copied four-entry vector of the stored components.axisAngleQuaternion: builds one quaternion from one axis-angle tuple.identityQuaternion: returns the identity quaternion of the selected real schema.quaternion: builds a quaternion either from four entries or from one 3×3 rotation matrix.quaternionCast: casts every entry to another real schema.rotationQuaternion: builds a quaternion from one rotation vector.rotationQuaternion with explicit threshold uses the identity quaternion when the rotation-vector length is below the selected threshold.*: scales a quaternion by one scalar, or composes two quaternions, depending on the argument schemas.+: adds quaternions entrywise.conj: returns the quaternion conjugate.dot: returns the quaternion dot product.squaredLength: returns the squared quaternion norm.unit: returns the normalized quaternion.matrix: returns the 3×3 rotation matrix represented by the quaternion.unitChecked and unitCheckedWithThreshold return the identity quaternion when the input length is below the selected threshold.nlerp performs normalized linear interpolation.slerp performs spherical linear interpolation with the default epsilon.slerpWithEpsilon performs spherical linear interpolation with explicit epsilon handling."Quaternion.identityQuaternion" use
"Quaternion.fieldCount" use
"control" use
{} () {} [
Real32 identityQuaternion fieldCount printStack _:;
] "main" exportFunction
4
"Quaternion.axisAngleQuaternion" use
"control" use
{} () {} [
(0.0r32 0.0r32 1.0r32 0.0r32) axisAngleQuaternion printStack _:;
] "main" exportFunction
{
QUATERNION: ();
entries: (0.0r32 0.0r32 0.0r32 1.0r32);
}
"Quaternion.identityQuaternion" use
"Quaternion.matrix" use
"control" use
{} () {} [
q: Real32 identityQuaternion;
q matrix printStack _:;
] "main" exportFunction
((1.0r32 0.0r32 0.0r32) (0.0r32 1.0r32 0.0r32) (0.0r32 0.0r32 1.0r32))
"Quaternion.quaternion" use
"Quaternion.unitChecked" use
"control" use
{} () {} [
q: (0.0r32 0.0r32 0.0r32 0.0r32) quaternion;
q unitChecked printStack _:;
] "main" exportFunction
{
QUATERNION: ();
entries: (0.0r32 0.0r32 0.0r32 1.0r32);
}
"Quaternion.identityQuaternion" use
"Quaternion.matrix" use
"algebra" use
"String" use
"control" use
{} Int32 {} [
q: Real32 identityQuaternion;
m: q matrix;
expected: ((1.0r32 0.0r32 0.0r32) (0.0r32 1.0r32 0.0r32) (0.0r32 0.0r32 1.0r32));
m expected = print
LF print
0
] "main" exportFunction
TRUE