Writes the 3x3 rotation matrix of a unit quaternion into a Matrix3 or any matrix with the 3x3 fields (a Matrix4 keeps the rest of it unchanged). The matrix then rotates column vectors: m * v equals rotate(v, q).
q: Quaternion;
set_from_axis_and_angle(*q, xyz(0, 0, 1), PI / 2);
m: Matrix3;
set_rotation(*m, q);
v := m * xyz(1, 0, 0);
assert(abs(v.x) < 0.0001 && abs(v.y - 1) < 0.0001);set_rotation :: (m: *$T/interface AnyMatrix3, q: Quaternion)
Writes the rotation into the upper-left 3x3 of *m. Other entries are left alone.
Parameters
- m: *$T/interface AnyMatrix3
- the matrix to write.
- q: Quaternion
- the rotation, expected to be a unit quaternion.