Lesson 3: Orientation in Robotics ‐ Rotation Matrices - madibabaiasl/kinematics-robotic-arms-modern-approach GitHub Wiki
- Define and distinguish between free vectors and vectors in robotics.
- Explain the role of coordinate frames in describing a robot’s pose.
- Understand how rotation matrices represent the orientation of a robot or its links.
- Identify the constraints that make a 3×3 rotation matrix represent only 3 independent rotational DOFs.
- Recognize how rotation matrices are used to relate, rotate, and transform between coordinate frames.
After completing this lesson, you will be able to:
- Describe how a robot’s pose is defined through position and orientation.
- Construct and interpret rotation matrices that represent 3D orientations.
- Apply properties of the special orthogonal group SO(3) to verify valid rotation matrices.
- Use rotation matrices as operators to rotate vectors and change reference frames.
In the previous lesson, you learned that a robot’s degrees of freedom (DOFs) describe how it can move: its independent motions. But to control or even describe that motion, we must precisely express how the robot is oriented in space. That’s where rotation matrices come in. Rotation matrices bridge the abstract concept of rotational DOFs with the concrete ability to measure, compute, and command a robot’s orientation. Every robotic arm joint, end-effector, or mobile platform ultimately relies on these matrices to represent how one frame moves relative to another. Understanding them turns “the robot can rotate” into “we know exactly how much, and about which axis.”
As we talked in the previous lesson, the configuration of the robot answers the question: where is the robot? This concept is tightly connected to the robot's position and orientation (pose). In order to know the robot's pose, we need to know the position and orientation of the robot's body frame {b} w.r.t some base (space) frame {s}:
The position and orientation of a robot in space can be represented by the position of the origin of the body frame expressed in the space frame coordinates and the directions of the coordinate axes of the body frame expressed in the space frame coordinates.
In this lesson, we want to talk about the robot's orientation and one of the ways that we can express this orientation. Before divining into more details, let's see some preliminary concepts that we will use when studying the robot's pose.
A free vector is a geometric quantity and an arrow in n-dimensional flat space
A vector is a free vector expressed with its coordinates in a reference frame and length scale chosen for that space. In robotics, vectors are represented by an italic letter
A vector is dependent on the choice of the coordinate frame and length scale, whereas the underlying free vector is unchanged by the choice of the coordinate frame or the length scale. In other words, v is coordinate-free.
A free vector is coordinate-free, whereas a vector is dependent on the choice of the coordinate frames and length scale.
A vector can also represent a point p in the physical space. If we choose to give this physical space a reference frame and a length scale, the point is a vector from the origin of this reference frame to the point. It is then represented as an italic
A physical point p can have different representations relative to different coordinate frames.
Question 1. What is the key difference between a free vector and a vector in robotics?
A) A free vector has magnitude only, while a vector has direction only.
B) A free vector is coordinate-free, while a vector depends on the choice of coordinate frame and length scale.
C) A free vector represents a point in space, while a vector cannot represent a point.
D) A free vector exists only in 2D, while a vector exists only in 3D.
Question 2. If we represent the same physical point p in two different coordinate frames with different length scales, what happens?
A) The physical point changes its location in space.
B) The free vector representing p disappears, since it is coordinate-free.
C) The coordinates of p change, but the underlying point remains the same.
D) Both the point and its coordinates remain unchanged.
In Robotics, frames are important. We use frames to represent the robot’s pose, velocities, and forces causing the motion. Frames in robotics:
- have an origin
- consist of orthogonal x, y, and z coordinate axes:
A right-handed coordinate frame consists of x, y, and z coordinate axes. The index finger is in the x-direction, the middle finger is in the y-direction, and the thumb is in the z-direction.
- are right-handed, and this means that the cross product of the x and y axes is z, and so on:
- are stationery! This is from Newton’s laws that the reference frames are always considered to be inertial.
A positive rotation about an axis follows the right-hand rule. If you align your thumb with the axis of rotation, then the positive rotation is in the direction that the fingers curl:
right.hand.rule.mp4
To conclude this part, let’s see a simple demonstration of the positive rotations about the coordinate axes attached to a robot joint:
robot.motions.prelim.demo.positive.rotations.x.y.z.mp4
After these short preliminaries, let's go into detail about one of the ways to represent orientation in robotics.
As we saw at the beginning of this lesson, in order to know the pose of a robot, we should know the position and orientation w.r.t to some base frame. One implicit way to express the orientation is using rotation matrices.
From the DOF lesson, we learned that a rigid body in space has 3 rotational DOFs. Therefore, we need three parameters to explicitly represent a rigid body’s orientation (rotations about the x, y, and z axes). One implicit way to represent the orientation of a rigid body is using 3×3 rotation matrices (note that this is one of the applications of the rotation matrix) to express the orientation of the body frame relative to the base frame. With the 9-dimensional space of the 3×3 rotation matrices subject to 6 constraints, we can implicitly represent the 3-dimensional space of orientations. In other words, of these 9 parameters, only 3 can be chosen independently. The reason that we opt for implicit representation is to take advantage of the algebraic calculations on matrices.
Question 1. Why do we need only 3 parameters to represent the orientation of a rigid body in space?
A) Because a rigid body in space has 3 translational DOFs.
B) Because rotation matrices are always 3×3.
C) Because a rigid body in space has 3 rotational DOFs (rotations about the x, y, and z axes).
D) Because any orientation can be ignored beyond 3 axes.
Question 2. What is the main advantage of using rotation matrices as an implicit representation of orientation?
A) They reduce the dimensionality of the problem from 9 to 3.
B) They allow algebraic calculations on matrices, which simplifies the manipulation of orientations.
C) They remove the need to measure orientation physically.
D) They make orientation independent of coordinate frames.
Suppose a robot in space as shown in the figure at the beginning of this lesson where {b} is the stationary body frame instantaneously attached to the moving body and {s} is the space or reference frame. We want a representation of the orientation of the robot in space.
The rotation matrix R can be defined as a representation of the body frame unit axes expressed in the base frame as:
The dot represents the dot product between the two vectors, and since the coordinate axes are of unit lengths, it represents the cosine of the angle between the two vectors.
Beginning of the Math Note:
Recall that if a and b are two vectors with known lengths and angle between them:
The dot product of two vectors is the multiplication of the length of the two vectors and cosine of the angle between the two vectors.
Then, the dot product of the two vectors can be expressed as the projection of one vector onto the other multiplied by the length of the other vector (in other words, it is the multiplication of the lengths of the two vectors and cosine of the angle between the two vectors):
End of the Math Note.
The nine numbers in this rotation matrix are subject to six constraints (so that we have 3 degrees of freedom). The constraints are:
- The unit norm constraint says that the columns of the rotation matrix R are unit vectors (because they are coordinate axes):
Note that ||.|| represents the norm of a vector.
- The orthogonality condition says that the column vectors of the rotation matrix are orthogonal to each other since they are coordinate axes, and thus the dot/inner product of any two column vectors is zero:
We can write these six constraints in a compact form as
RT_R_proof.mov
As we discussed in the preliminaries, all frames in robotics are taken to be right-handed meaning that the cross product of the x and y axes is the z-axis (and so on). But the six constraints that we just discussed do not account for this since:
If we take the right-handed coordinate system, then the determinant of R will be calculated as:
This result comes from the fact that our frames are right-handed.
Beginning of math note:
We know from algebra that for a 3×3 matrix A defined by its columns as:
The determinant of A can be found by the following formula:
End of math note.
So, we can conclude that for a right-handed frame,
Question 1. What do the entries of the 3×3 rotation matrix R represent in the context of robotics?
A) The cross product of the body frame axes.
B) The dot product between the body frame unit vectors and the base frame unit vectors.
C) The determinant of the coordinate system.
D) The length of each axis vector.
Question 2. Why do the nine entries of the rotation matrix reduce to only three independent parameters?
A) Because of six constraints: three unit norm constraints and three orthogonality constraints.
B) Because only the diagonal entries matter.
C) Because all axes have the same length.
D) Because the determinant is always zero.
Question 3. What is the additional constraint needed for rotation matrices in robotics when using a right-handed coordinate frame?
A) The determinant of R must equal zero.
B) The determinant of R must equal one.
C) The determinant of R must equal negative one.
D) The determinant of R must be undefined.
Question 4. How many total constraints are applied to a 3×3 rotation matrix to reduce its 9 entries down to 3 independent parameters?
A) 3
B) 6
C) 9
D) 1
Question 5. What does it mean when we say a rotation matrix is right-handed?
A) The axes can point in any arbitrary direction.
B) The determinant of the matrix equals zero.
C) It has more than 3 degrees of freedom.
D) The cross product of two axes gives the third axis, following the right-hand rule.
By definition, the group of rotation matrices is called the special orthogonal group SO(3), which is a set of all 3×3 real matrices R that satisfy
A subgroup of SO(3) is the set of 2×2 rotation matrices called the special orthogonal group SO(2) that consists of all 2×2 real matrices R satisfying
Suppose a toy car with its motion confined to the plane and two coordinate frames {s}, and {b} with their corresponding unit axes (a hat notation shows a unit vector):
A toy car on a plane with two coordinate frames {s} and {b} with the unit axes. The orientation of the toy car can be expressed by finding the orientation of the body fixed-frame with respect to the space frame {s}.
{b} is called a body frame since it is a fixed frame attached instantaneously to the moving body. Therefore, to find the orientation of the toy car, we should express the orientation of the body’s fixed-frame coordinates in the base frame coordinates. One way to represent the orientation of the body coordinates in terms of the base coordinates is, as we saw in this lesson, by using a rotation matrix:
The columns of this matrix are the coordinate axes of the {b} frame expressed in the coordinate axes of the {s} frame. And since both the base frame axes and the body frame axes are unit vectors, their dot product is the cosine of the angle between the vectors. Note that
What does the group of rotation matrices SO(3) represent, and what conditions must a 3×3 matrix satisfy to belong to SO(3)?
A) All 3×3 matrices with determinant = 0
B) All 3×3 matrices with
C) All 2×2 matrices with determinant = ±1
D) All diagonal matrices with determinant = 1
Sets of rotation matrices SO(2) and SO(3) are groups and thus have properties of a mathematical group. In general, the SO(n) groups are called Lie groups. A mathematical group has a set of elements and an operation on two elements (this operation is matrix multiplication for SO(n)) such that for all
- The group has closure property and this means that the multiplication of the two matrices in the group also belongs to the group:
$R_1 R_2 \in SO(n)$ .
To show this for the SO(3), suppose that
And thus the product of two rotation matrices is also a rotation matrix.
- The group has associativity property:
$(R_1 R_2) R_3 = R_1 (R_2 R_3)$
Note that the multiplication of rotation matrices is associative but generally not commutative:
Where because of the case for planar rotations, we can write:
Thus with an easy calculation, we can see that RM = MR, and thus for the special case of the planar rotations, the multiplication of the rotation matrices commute. For example, if you rotate a coordinate frame attached instantaneously to a body confined to a plane first by 45 degrees and then by 30 degrees, the result is the same as when you rotate it first by 30 degrees and then by 45 degrees:

- There exists an identity element in SO(n) such that RI = IR = R.
Note that the identity matrix I can be viewed as a trivial example of a rotation matrix. Imagine this by visualizing the first frame aligned with the reference frame.
- There exists an inverse element
$R^{-1}$ in SO(n) such that$R R^{-1} = R^{-1} R = I$ .
For SO(3), we can say that the inverse of a rotation matrix R in SO(3) is also a rotation matrix, and
And thus the inverse of R is also a rotation matrix. Note that
Also, note that when a rotation matrix is applied to a vector to rotate it, this does not change the length of the vector. In other words: For any vector
Proof.
Where
Question 1. Which of the following properties is always true for the set of rotation matrices in SO(n)?
A) Closure and Associativity
B) Closure and Commutativity
C) Associativity and Commutativity
D) None of the above
Question 2. In general, rotation matrices in SO(3) are:
A) Commutative but not associative
B) Associative but not commutative
C) Both commutative and associative
D) Neither commutative nor associative
Question 3. What is the inverse of a rotation matrix
A)
B)
C)
D)
Question 4. When a rotation matrix R is applied to a vector x, what happens to the length (norm) of the vector?
A) It increases by a factor of 2
B) It decreases by a factor of 2
C) It remains unchanged
D) It becomes zero
A rotation matrix can be used for three different purposes that we will discuss in the coming paragraphs.
As we discussed earlier, a rotation matrix can be used to implicitly represent an orientation; in other words, it can be used to represent the orientation of the body frame relative to the base frame. In order to show this, I use an example that is adapted from the reference book “Modern Robotics: Mechanics, Planning, and Control” by Kevin Lynch and Frank Park.
Suppose we have three reference frames {s}, {b}, and {c} that represent the same space with different orientations:
One of the applications of a rotation matrix is to represent the orientation of one frame relative to another. Coordinate frames {s}, {b}, and {c} represent the same space with different orientations. The orientation of frames {b} and {c} relative to {s} can be represented by a rotation matrix. Point p has the same location in space but has different coordinates depending on the choice of coordinate frame. Note that the three reference frames have the same origin and only orientations are different. I showed them in different spots to make the presentation clear. In other words, the same space is drawn three times.
Coordinate frame {b} can be achieved by rotating the {s} frame by 90 degrees about the {s} frame’s z-axis, and frame {c} is achieved by rotating the {b} frame by -90 degrees about the {b} frame’s y-axis. Watch the short demonstration below to understand how these coordinate frames are achieved:
successive.rotations.coordinate.frames.mp4
Three coordinate frames {s}, {b}, and {c} representing the same space with different orientations. A rotation matrix is used to represent the orientation of one frame relative to another frame.
As we discussed, a rotation matrix can be used to represent the orientation of one frame relative to the base frame. Now, let’s see the rotation matrices representing the orientations of the {b} and {c} coordinate frames relative to the {s} frame. By writing the coordinate axes of the {b} and {c} frames in the {s} frame we can get:
Click to reveal answer
It’s easy to note that the coordinate axes of the {s} frame in the for example {c} frame can be achieved by inverting (or transposing in the case of rotation matrices) the rotation matrix representing the orientation of the {c} frame relative to the {s} frame:
Click to reveal answer
Note that because of the properties of a rotation matrix, the inverse of a rotation matrix is equal to the transpose of a rotation matrix.
Also, note that the point p has the same location in the space but has different representations depending on the choice of the coordinate frame:
Click to reveal answer
A space frame {s} and a body frame {b} are related as follows:
- The
$\hat{x_b}$ axis points in the same direction as the$\hat{y_s}$ axis - The
$\hat{y_b}$ axis points in the negative direction of the$\hat{x_s}$ axis
a) Construct the rotation matrix
b) Verify that
One of the applications of a rotation matrix is to change the reference frame of a vector or a frame. Here, a rotation matrix is an operator that acts on a vector or a frame to change its reference frame. For example, to show the change of frame of reference for a coordinate frame, suppose that we have the rotation matrix representing the orientation of the {c} frame relative to the {b} frame as (frames are defined above):
Click to reveal answer
The goal is to express the {c} frame in {s} frame coordinates instead of the {b} coordinates. To achieve this goal, we can use the rotation matrix
Click to reveal answer
By pre-multiplying
A rotation matrix can also serve as an operator to change the frame of reference for a vector. For instance, suppose that we have
A rotation matrix can serve as an operator to change the reference frame in which a vector is expressed.
We want to express p in {s} frame coordinates. We can do this by pre-multiplying
Click to reveal answer
Note that the subscript cancellation rule works here too.
If a point has coordinates
Another application (and the final one) of a rotation matrix is to rotate a vector or a frame. Here again, a rotation matrix is an operator that acts on a vector or a frame to rotate it.
Consider the three coordinate axes {s}, {b}, and {c} described as in the above figure. As we saw before, {b} is achieved by rotating the {s} frame by 90 degrees about the z-axis of the {s} frame.
Pre-multiplying
This vector represents the rotated

A rotation matrix can act as an operator to rotate a vector. For example, in this simulation, you can see that by multiplying a vector by a rotation operator that can rotate 90 degrees about the z-axis, the vector is rotated in the same coordinate frame by 90 degrees.
Note that to rotate a vector
A rotation matrix can also be used to rotate a frame. Suppose that we have the rotation operator R that can rotate a frame by 90 degrees about the z-axis:
Now let’s see what happens to a frame if we pre-multiply or post-multiply it by this rotation operator. Note that the choice of the z-axis to be from which frame depends on the pre-multiplication or post-multiplication of the rotation matrix. Now suppose the {s} and {c} coordinate frames that we had before:
The {c} frame orientation will be different depending on whether the rotation matrix representing its orientation with respect to the base frame (
If we pre-multiply by the rotation operator R defined above, then the rotation axis is the z-axis of the first subscript, which is s so that the rotation is about the z-axis of the {s} coordinate frame:
Pre-multiplication of a rotation matrix representing the orientation of one frame with respect to another by a rotation operator defined above (a rotation operator that can rotate a vector or a frame by 90 degrees about the z-axis), rotates the frame about the z-axis of the coordinate frame related to the first letter of the subscript which is s.
If we post-multiply by the rotation operator R defined above, then the rotation axis is the z-axis of the second subscript, which is c so that the rotation is about the z-axis of the {c} coordinate frame:
Post-multiplication of a rotation matrix representing the orientation of one frame with respect to another by a rotation operator defined above (a rotation operator that can rotate a vector or a frame by 90 degrees about the z-axis), rotates the frame around the z-axis of the coordinate frame related to the second letter of the subscript which is c.
Generally speaking, if
-
Coordinate frame {b’} is the new frame after a rotation by
$\theta$ about$\hat{\omega}_s = \hat{\omega}$ , and this means that the rotation axis is considered to be in the fixed frame {s}:$R_{sb'} = R R_{sb}$ . -
Coordinate frame {b”} is the new frame after a rotation by
$\theta$ about$\hat{\omega}_b = \hat{\omega}$ , and this means that the rotation axis is in the body frame {b}:$R_{sb"} = R_{sb} R$ .
So, for the rotation operator
The multiplication of
A vector
A) Multiplying
B) Multiplying
C) Multiplying
D) Multiplying
Rotation Operators about the x, y, and z Axes
Now let’s find general forms of rotation operators representing the rotations about the x, y, and z axes by
The rotation operator representing the rotation about the x-axis by

Using the figure below:
We can find the rotation operator representing the rotation about the x-axis as:
Click to reveal answer
With the same approach, rotation operators representing the rotations about the y-axis and the z-axis can be found as (draw them and show that the equations are correct):
Click to reveal answer
and
Click to reveal answer
Generally, the rotation about an arbitrary unit axis
by
Where:
We will see how to derive this rotation matrix in the coming lessons when talking about the exponential coordinates of rotation. For now, you can verify that it is correct by assuming
Visualize this rotation as the following figure:
The rotation about the arbitrary axis ῶ by θ.
Note that any
Now, let's finish up this lesson with an example.
Example: The Representation of the Orientation of the Elements in the Robot’s Workspace
Suppose that a camera and a gripper are attached to the end-effector of the industrial arm. The camera is used to observe the workpiece and position the end-effector in the right position, and the gripper is used to grip the workpiece. The overall system can be depicted in the figure below:

A camera is attached to the robot end-effector to observe the object and position the end-effector in the right position. Four reference frames are attached to different elements in the robot’s workspace, as shown in the figure. The orientation of one frame relative to the other can be implicitly represented by a rotation matrix. This example is adapted from the first textbook by Lynch et al.
Four frames are attached to different elements in the robot’s workspace, as shown above. {a} is the frame coincident with the space frame {s}, {b} is the gripper frame, {c} is the camera frame, and {d} is the workpiece frame.
The orientation of the workpiece frame relative to the base frame can be expressed by the rotation matrix
Click to reveal answer
This means that the two frames have the same orientation.
The orientation of the workpiece frame relative to the camera frame can be calculated as follows:
Click to reveal answer
Now suppose we have the rotation matrix representing the orientation of the camera frame relative to the gripper frame as:
To calculate the orientation of the gripper frame relative to the space frame
Click to reveal answer
Note that we used the inverse of a rotation matrix equals its transpose and the subscript cancellation rule to calculate the result.
Let's see another example.
Example: Successive Rotations of a Point about the Coordinate Axes of the Base Frame
Suppose p is a point in space with coordinates relative to the space frame as
point p in space and the corresponding vector representation in {s} frame.
Now suppose that p is rotated about the fixed-frame x-axis by 30 degrees, then about the fixed-frame y-axis by 135 degrees, and finally about the fixed-frame z-axis by -120 degrees. The rotation matrix that rotated p to the new location can be expressed as (note the order in which the rotations are written):
Click to reveal answer
These rotations can easily be calculated using the rotation operators about the coordinate axes provided above. Then the coordinates of the rotated point can be calculated as:
Click to reveal answer
The rotated point can be visualized as:
Vector representation of the rotated point p after going through a rotation by 30 degree about the x-axis of the base frame, then a rotation by 135 degree about the y-axis of the base frame, and finally a rotation by -120 degree about the z-axis of the base frame.
- Modern Robotics: Mechanics, Planning, and Control by Frank Park and Kevin Lynch
- A Mathematical Introduction to Robotic Manipulation by Murray, Lee, and Sastry
- Cao, C.T., Do, V.P. and Lee, B.R., 2019. A novel indirect calibration approach for robot positioning error compensation based on neural network and hand-eye vision. Applied Sciences, 9(9), p.1940.