Math module

rotation_matrix

procedure · 1 overloadSource

The rotation matrix of a unit quaternion as a new matrix of type T (Matrix3 or Matrix4, which has an identity translation).

ExampleOpen in playground ↗
q: Quaternion;
set_from_axis_and_angle(*q, xyz(0, 0, 1), PI / 2);
m := rotation_matrix(Matrix4, q);
assert(m._44 == 1 && m._14 == 0);
assert(abs((m * xyzw(1, 0, 0, 1)).y - 1) < 0.0001);
rotation_matrix :: ($T: Type, q: Quaternion) -> T

A rotation matrix of type T: the identity with the rotation written in.

Parameters

$T: Type
the matrix type.
q: Quaternion
the rotation, expected to be a unit quaternion.

Returns

T

See also