Rotation Matrices
Overview
Rotation matrices are matrices which are used to describe the rotation of a rigid body from one orientation to another.
In they form a 3x3 matrix.
such that if was a point in 3D space, then we can rotate to around the origin by applying in the following manner:
where:
and are 1x3 vectors
Rotation matrices are always orthogonal matrices which have a determinant of 1.
Combining Rotations
Two successive rotations represented by and can be represented by a single rotation matrix where:
Pay careful attention to the order of the matrix multiplication, successive rotation matrices are multiplied on the left.
How To Find The Rotation Matrix Between Two Coordinate Systems
Suppose I have the frame with the following unit vectors defining the first coordinate system :
And a second coordinate system defined by the unit vectors:
The rotation matrix which rotates objects from the first coordinate system into the second coordinate system is:
where:
is the matrix dot product
and everything else as above
Creating A Rotation Matrix From Euler Angles (RPY)
A rotation expressed as Euler angles (which includes RPY or roll-pitch-yaw notation) can be easily converted into a rotation matrix. To represent a extrinsic rotation with Euler angles , , are about axes , , can be formed with the equation:
where:
Converting A Rotation Matrix To Euler Angles
Whilst converting a rotation expressed as Euler angles is relatively trivial (see above), it is not no simple to go the other way and convert a rotation matrix to Euler angles.
Javascript
THREE.js has a Euler
class with the function .setFromRotationMatrix()
which can convert a rotation matrix to Euler angles. The supported Euler angle orders are XYZ
, YZX
, ZXY
, XZY
, YXZ
, ZYX
, and it only supports intrinsic rotations.
External Resources
https://www.andre-gaschler.com/rotationconverter/ is a great one-page rotation calculator.