Skip to main content

Module rotations

Module rotations 

Source
Expand description

Rotations in two and three dimensions: matrices, axis-angle, Euler sequences, and composable rotation types.

Rotation3 stores a unit Quaternion, so composition is cheap and stays normalised, and converts to and from rotation matrices, axis-angle and any of the twelve Euler sequences. Matrices are row-major [[f64; 3]; 3] acting on column vectors. Euler sequences are intrinsic: Rotation3::from_euler(XYZ, [a, b, c]) rotates by a about X, then by b about the new Y, then by c about the newest Z, i.e. R = Rx(a) Ry(b) Rz(c).

See the book entry Rotations, Euler angles and quaternions.

Structs§

EulerSequence
An intrinsic Euler-angle sequence: three axes where consecutive axes differ. Sequences whose first and last axes coincide (XYX, …) are “proper” Euler angles; the others (XYZ, …) are Tait-Bryan angles.
Rotation2
A rotation in the plane about the origin.
Rotation3
A rotation in three dimensions, stored as a unit quaternion.

Enums§

Axis
A coordinate axis.

Constants§

IDENTITY3

Functions§

is_rotation_matrix
Whether m is orthogonal with determinant +1 within tol.
mat3_apply
Matrix-vector product.
mat3_determinant
mat3_mul
Matrix product a * b.
mat3_transpose
nearest_rotation_matrix
The rotation matrix closest (in Frobenius norm) to m, by Newton iteration for the polar factor. Useful to clean up a matrix that has drifted after many multiplications. Returns None if m is singular or has a negative determinant (is not near a proper rotation).
rotation_matrix_axis_angle
Rodrigues’ formula: the matrix of a rotation by angle about axis (normalised internally; a zero axis gives the identity).
rotation_matrix_x
Rotation about the X axis by angle radians.
rotation_matrix_y
Rotation about the Y axis by angle radians.
rotation_matrix_z
Rotation about the Z axis by angle radians.

Type Aliases§

Matrix3
A 3×3 matrix in row-major order.