Rotation Matrix

 

 

The Rotation Matrix performs a rotation in Euclidean space, preserving the rotated object’s lengths, angles, and scale.  This topic is fundamental in robotics, 3D graphics, and physical simulations as it guarantees rigid-body motion without distortion.

Rotations can be performed in 2D and 3D space.  I will derive rotation matrix in 2D space, then expand upon that derivation in 3D space.

I’ve also written and published my rotation matrices code to demo its implementation!

 

 

Angle Addition of a Triangle

 

The rotation matrix is rooted in the angle addition property of a triangle. 

We start by assuming two right-triangles with a common vertex and a shared side, as shown in the figure below.  This can be thought of as  rotating counterclockwise to the position of .  Note that we cannot assume that .

 

Double Angle Trigonometry derivation

 

 

Let’s start by defining the givens:

 

 

We are solving for .  Based on the figure above:

 

 

Define :

 

 

Define :

 

 

Define :

Transversal Angles

 

 

Define :

 

 

Now that we have all triangles defined, we can derive the Angle Addition formulae:

 

 

 

 

 

2D Rotation Matrix Derivation

 

Now that we’ve derived the angle addition formulae, we can use this to derive a rotation matrix!  Let’s suppose that we have a point at , and we want to rotate it an angle  to . 

Note that positive rotation angles will rotate a point counterclockwise!

 

 

We start with the angle addition formulae that we derived above:

 

 

Since we know , we can convert the cartesian coordinates to polar coordinates:

 

 

Now we can convert  from cartesian coordinates to polar coordinates.  The angle addition formulae are adapted to define the final pose, , as a function of the starting pose, , as polar coordinates.  We notice that our cartesian to polar conversion equations are represented in this form:

 

 

Now we can substitute these polar coordinates into the angle addition formulae:

 

 

We have our rotation equations!  Let’s represent them as a linear system:

 

 

 

This system can be used to determine the position of a point at  that has been rotated an angle  to  in a 2D plane.

 

 

3D Rotation Matrix Derivation

 

Deriving the rotation matrix for a 3D system is identical to the derivation we did for a 2D system. 

 

Right-hand Rule

·         Before starting, let’s understand how to perform the right-hand rule to properly orient a 3D coordinate plane:

o   With an open palm RIGHT hand, point your fingers along the positive x-axis and your palm facing the positive y-axis

o   Curl (close) fingers toward the positive y-axis

o   Your thumb will point along the positive z-axis

 

·         If all 3 right-hand rule conditions are met, then the coordinate plane is properly oriented!

 

Three-Dimensional Coordinate Systems | Calculus III

Right-Hand Rule

 

 

Now that we understand the right-hand rule, let’s derive the rotation matrix for rotations about all 3 axes in a 3D coordinate plane.  We will derive the rotation matrix for the y-axis, and the same process can be used to derive the rotation matrix for the x- and z-axes.

 

When we want to visualize the rotation about an axis, we can illustrate the rotation by looking down along the rotation axis.  Below are important considerations when drawing a rotation diagram:

·         The rotation axis is positive out of the page

·         The right-hand rule is 100% satisfied as defined above.

 

 

Rotation About the y-axis,

 

Since we are deriving the rotation matrix for rotation about the y-axis, we draw a diagram that has the positive y-axis pointing out of the page.  This means that your right hand should lay palm up (out of the page, like the positive y-axis) and fingers pointing to the left of the page, leaving your thumb pointing to the top of the page.

 

Rotation about the y-axis

 

Once you’ve confirmed that the rotation diagram for the y-axis is accurate, we draw the angle addition figure in the quadrant where x and z are positive.  .  Below are important considerations when drawing the angle addition diagram to derive a rotation matrix:

·         Draw the rotation in the quadrant where both axes are positive

·         Rotation angle is assumed positive in the derivation

·         A positive rotation is always counterclockwise

 

This should start looking familiar!  To make this diagram more like the diagram we used to derive the 2D rotation matrix, let’s rotate it so that the positive-positive quadrant is at the top left.

 

This z-x coordinate plane is almost identical to the x-y coordinate plane we used in our 2D derivation!  The only difference is that the axes are z and x instead of x and y, respectively.  With that key distinction in mind, we derive the same angle addition equations, but we must relate each equation to the appropriate axis shown in the diagram.  In other words, the rotation in an x-y coordinate plane defines:

 

 

The z-axis in the z-x coordinate plane is equivalent to the x-axis in the y-y coordinate plane, and the x-axis in the z-x coordinate plane is equivalent to the y-axis in the y-y coordinate plane.  Let’s rewrite the x-y coordinate plane equations in terms of the z-x coordinate plane.

 

 

Now let’s express these equations as a linear system:

 

 

Notice that there is no rotation performed on the y row or column vectors in the rotation matrix. 

·         This is true for each rotation matrix

o   The diagonal entry corresponding to the axis of rotation is 1 because the coordinate along that axis remains unchanged during rotation.

o   The off‑diagonal entries in that row and column are 0 because the other coordinates do not influence the coordinate along the axis of rotation.

 

 

All 3D Rotation Matrices

Now that we have the rotation axis for rotation about the y-axis, let’s define the rotation matrices about the x-axis and the z-axis.  Follow the derivation above to derive these two on your own!

 

Axis of Rotation

Derivation Diagram

Rotation Matrix

 

 

Rotation About Multiple Axes

Rotations about multiple axes can be performed in a single calculation by right-multiplying the rotation matrices in the order in which you want the rotations to occur.  For example:

 

Rotation About No Axes

When a rotation is NOT performed about any axes, the rotation matrices will generate an identity matrix:

 

 

 

 

 

Helpful Links

·         Proof of angle addition formula for sine – Kahn Academy

·         Proof of angle addition formula for cosine – Kahn Academy

·         Rotation Matrix - Wikipedia