Case Study 2 — Where Is the Robot's Hand? Rotation Matrices in a Two-Joint Arm
Field: robotics / mechanical engineering. A second use of the rotation matrix derived in Chapter 7 — this time to locate the end of a jointed arm in space.
The problem
A simple robot arm is bolted to a table. It has two rigid links connected by motorized joints that rotate. You command joint angles, and you need to know: where is the hand? This is the central question of forward kinematics, and at its heart is the rotation matrix you derived in Chapter 7 — applied once per joint, and combined by tracking how each link's frame turns relative to the one before it.
We'll work in the plane (a "planar 2R arm," two revolute joints). Link 1 has length $\ell_1 = 3$ and link 2 has length $\ell_2 = 2$. Joint 1 sits at the origin; it rotates the first link by angle $\theta_1$. At the end of link 1, joint 2 rotates the second link by an additional angle $\theta_2$ relative to link 1.
Step 1 — One link is one rotation matrix
Point the first link along its own local "forward" direction — the vector $(\ell_1, 0)$, length $\ell_1$ pointing east in the link's own frame. Rotating it by the joint angle $\theta_1$ uses exactly the matrix from §7.5.3: $$R(\theta_1) = \begin{bmatrix}\cos\theta_1 & -\sin\theta_1\\ \sin\theta_1 & \cos\theta_1\end{bmatrix}.$$ So the position of joint 2 (the elbow), measured from the base, is $$\mathbf{p}_{\text{elbow}} = R(\theta_1)\begin{bmatrix}\ell_1\\ 0\end{bmatrix} = \begin{bmatrix}\ell_1\cos\theta_1\\ \ell_1\sin\theta_1\end{bmatrix}.$$ This is the weighted-sum-of-columns product in action: $\ell_1$ copies of the first column $(\cos\theta_1, \sin\theta_1)$ plus $0$ copies of the second. The elbow sits a distance $\ell_1$ from the base, in the direction $\theta_1$ — exactly what a rotation should give.
Step 2 — The second link rotates in a frame that's already turned
Here is the subtlety, and it is pure Chapter 7. The second link's angle $\theta_2$ is measured relative to link 1, but we want the hand's position in the base frame. The second link, in its own local frame, points along $(\ell_2, 0)$. To express it in the base frame we must undo two layers of rotation: first turn by $\theta_2$ (link 2 relative to link 1), then turn by $\theta_1$ (link 1 relative to the base). Tracking the link's forward vector through both rotations — exactly "combine transformations by following the vector through each step" from §7.6 — its base-frame direction is $$R(\theta_1)\,R(\theta_2)\begin{bmatrix}\ell_2\\ 0\end{bmatrix}.$$ Two rotations in a row compose, and from Exercise 7.23 we know rotations add their angles: $R(\theta_1)R(\theta_2) = R(\theta_1 + \theta_2)$ (a fact we prove cleanly in Chapter 8, but can already trust from "turn $\theta_2$, then $\theta_1$, is turn $\theta_1+\theta_2$"). So the hand position is the elbow plus the rotated second link: $$\mathbf{p}_{\text{hand}} = \mathbf{p}_{\text{elbow}} + R(\theta_1+\theta_2)\begin{bmatrix}\ell_2\\ 0\end{bmatrix} = \begin{bmatrix}\ell_1\cos\theta_1 + \ell_2\cos(\theta_1+\theta_2)\\ \ell_1\sin\theta_1 + \ell_2\sin(\theta_1+\theta_2)\end{bmatrix}.$$ That clean formula — the standard forward-kinematics equation for a 2R arm — fell out of nothing but the Chapter 7 rotation matrix and the idea that rotations compose by adding angles.
Step 3 — Compute a real configuration
Set $\theta_1 = 30°$ and $\theta_2 = 45°$. Then the hand should be at $$\Big(3\cos30° + 2\cos75°,\ \ 3\sin30° + 2\sin75°\Big).$$
# Forward kinematics of a planar 2R arm via rotation matrices.
import numpy as np
def R(deg):
t = np.radians(deg)
return np.array([[np.cos(t), -np.sin(t)],
[np.sin(t), np.cos(t)]])
l1, l2 = 3.0, 2.0
th1, th2 = 30.0, 45.0
elbow = R(th1) @ np.array([l1, 0]) # joint-2 position
hand = elbow + R(th1 + th2) @ np.array([l2, 0])
print("elbow =", np.round(elbow, 3))
print("hand =", np.round(hand, 3))
# sanity: hand can be no farther than l1 + l2 from the base
print("reach =", round(float(np.linalg.norm(hand)), 3), "<=", l1 + l2)
elbow = [2.598 1.5 ]
hand = [3.116 3.432]
reach = 4.635 <= 5.0
The elbow lands at $(2.598, 1.5)$ — distance exactly $3$ from the base, in the $30°$ direction, as it must. The hand lands at $(3.116, 3.432)$, a distance $4.635$ from the base, comfortably within the maximum reach $\ell_1+\ell_2 = 5$ (which the arm achieves only when fully straightened, $\theta_2 = 0$). Every number traces back to the rotation matrix you derived from "where do the basis vectors go?"
Why this matters
Forward kinematics is the bedrock of robotics: before a robot can plan a motion, weld a seam, or place a surgical instrument, it must compute where its parts are from its joint angles, and that computation is a chain of rotation matrices. Real arms work in 3D with six or seven joints, and each joint contributes a $3\times 3$ rotation (Chapter 21 generalizes our $2\times 2$ rotation to 3D); translations between joints are folded in with the homogeneous-coordinate trick of Chapter 12, so an entire arm's pose becomes a product of $4\times 4$ matrices. But the conceptual core is exactly this chapter's: a rotation is a matrix, built from where the basis vectors go, and a sequence of rotations composes into a single transformation.
There's a deeper payoff hiding here too. Because each rotation matrix preserves length (it's orthogonal, $\det = 1$), the links never stretch or shrink as the arm moves — the geometry the chapter promised (rotations preserve distances and angles) is precisely what makes the arm a rigid mechanism. And the inverse problem — "what joint angles put the hand at a target?" — is inverse kinematics, which leads to solving systems and, when the arm has redundant joints, to projections and least squares (Chapters 9, 17, 19). The humble $2\times 2$ rotation matrix is the doorway.
Try it yourself
- Set $\theta_2 = 0$ (arm straight) and confirm the hand reaches the maximum distance $\ell_1 + \ell_2 = 5$ from the base.
- Use
visualize_2don $R(30°)$ to see the rotation that places link 1, then on $R(75°)$ for the second link's base-frame orientation. Confirm both have determinant $1$ (rigid, no stretching). - Sweep $\theta_1$ from $0°$ to $360°$ with $\theta_2$ fixed at $45°$, compute the hand position at each step, and plot the trace. You should get a circle — the arm's reachable boundary for that elbow angle. Explain why it's a circle in terms of rotations preserving length.