Math foundations · topic A1 · 40 hours
Linear algebra & rigid-body rotation
Every coordinate transform a robot performs is matrix arithmetic. Quaternions, rotation matrices, and Lie groups are the shared language of everything downstream — kinematics, calibration, optimization. Skip this and the rest of the stack stays a black box.
What to learn
- Converting between the four pose representations (rotation matrix / rotation vector / quaternion / Euler angles), and when each is the right choice
- Homogeneous transforms SE(3): composition, inversion, and the difference between transforming a point and transforming a direction vector (whether the translation applies)
- Quaternion double cover (q and −q encode the same rotation), normalization, and slerp interpolation
- Euler-angle gimbal lock: why you never interpolate or integrate in Euler angles
- Hand-computing a camera → arm-tip → base coordinate chain, stating which frame every step lives in
The lesson · plain words
In plain words: every part on a robot, every millisecond, is answering the same question — «where am I, and which way am I facing?» The math that answers those two questions is this entire page. It is not hard; it only has many symbols. This page turns every symbol back into words.
You learned in school that a point on a line takes 1 number, on a plane 2, in space 3. Robotics adds exactly one new trouble: 3 numbers say «where» but not «facing» — standing in the same spot, pointing at the ceiling and pointing at the door are completely different poses. Orientation takes another 3 numbers. Six numbers together; roboticists call the package a «pose». Everything on this page is about how to store and compute these 6 numbers properly.
Rotation matrices: a lookup table of coordinates
Rotation matrices sound intimidating; they are really a three-column lookup table: where the x, y, z axes of the new frame point inside the old frame. Copy the three columns down and you have the 3×3 matrix. There is no further mystery.
Two practical payoffs: transforming any point is a single matrix multiply (9 multiply-adds, microseconds); and a rotation matrix never breaks — no angle fails to compute. The cost: of the 9 numbers only 3 are free; the other 6 are trailing constraints. In the figure below, drag the point on the circle and watch the matrix entries follow live — a matrix is not a table, it is the ledger of a rotation.
Interactive figure · drag it and see
Quaternions: 4 numbers doing the job of 9
Quaternions are not mysticism; they are the 3D upgrade of «complex multiplication = rotation» (the complex-number version is the figure below): 4 numbers encoding «around which axis, by how many degrees». They save memory, interpolate smoothly, and multiply faster than matrices; the cost is that humans cannot read them. The engineering convention in one sentence: store and transmit quaternions; convert to Euler angles only when a human has to look.
One trap you must know: q and −q encode the same rotation (the double cover). To test whether two quaternions «point the same way», check the sign of their dot product first — which is why every quaternion interpolation routine checks signs before blending.
Interactive figure · drag it and see
Gimbal lock: why Euler angles «twitch»
Euler angles mean rotating about three axes in turn (say yaw about z, then pitch about the new y, then roll about the new x). The three axes behave like the three rings of a gimbal: when the middle ring reaches 90°, the outer and inner rings point along the same direction — three degrees of freedom collapse into two. At that instant the program «does not know which axis to move», the pose flips near the singularity, and to the eye it looks like «the motor twitched».
Remember the conclusion: Euler angles are for humans, not for computation — above all, never interpolate or integrate in them.
| Representation | Numbers | Strength | Fatal flaw | Used for |
|---|---|---|---|---|
| Rotation matrix | 9 | Intuitive, never singular | 6 redundant numbers | Derivation, textbooks |
| Quaternion | 4 | Smooth interpolation, fast | Unreadable, ±q double | Storage, transport, state |
| Euler angles | 3 | Humans read them | Gimbal lock | UI display, logs |
| Rotation vector | 3 | Cheapest, no singularity | Cannot compose directly | Optimization variables, Lie algebra |
Interactive figure · drag it and see
The coordinate chain: a robot's world is a metro transfer
The camera reports «the cup is at (0.2, 0.1, 0.8) in my frame»; the arm needs «where is the cup in the base frame». Two transfers in between: the camera is bolted to the arm tip (one fixed rotation + translation), and the tip sits in the base frame through another rotation + translation. The homogeneous transform (SE(3)) packs each rotation + translation into one 4×4 matrix, multiplied down the chain — like riding a metro: at each stop you only need «which way is the next stop from here».
A detail people get wrong for a lifetime: transforming a point adds the translation (a point has a position); transforming a direction vector does not (a direction has only an orientation). Same matrix — the difference is whether the trailing coordinate is 1 or 0.
Interactive figure · drag it and see
Computing backwards: from base coordinates back to tip coordinates
The previous figure ran forward: tip-frame coordinates, one rotation and one translation, base-frame coordinates. Half of real engineering runs the other way — a sensor sees the target in base coordinates and asks «where should the tip go». So you must also compute backwards.
Backwards is not «divide». The inverse of a rotation is its transpose: swap rows and columns; pull off the translation first, then rotate: p_t = Rᵀ(p_b − t). Why do the order and the sign both flip? Forward is «rotate, then translate»; backwards must «translate back, then rotate back».
Watch the figure: the point never moves, only the ledger does. It flips direction by itself every few seconds; use the button to flip it by hand. Note the numbers inside Rᵀ are the same as in R, rows and columns swapped — which is why inverting a transform in robotics costs almost nothing.
Interactive figure · drag it and see
Three sentences to take away
① A rotation matrix is a coordinate lookup table; ② a quaternion is a 4-number rotation — store poses with it; ③ Euler angles are for display — keep them out of the math. Get these three and you are ahead of many people who «have used tf but cannot say why». Full proofs and hand computations wait in the derivation layer.
Three questions — do you really get it?
1. The decisive engineering reason to store orientation in quaternions rather than Euler angles is?
- AIt saves memory
- BInherently higher precision
- CNo gimbal lock, smooth interpolation
Show answer
C. Memory is a side benefit; the core issue is that Euler angles have gimbal lock and interpolation flips near the singular pose. Quaternion interpolation (slerp) is smooth end to end.
2. Applying the same homogeneous transform to a point versus to a direction vector differs how?
- AA point gets a trailing 1 (receives translation), a vector gets 0 (does not)
- BNo difference
- CA vector must be normalized, a point must not
Show answer
A. Translation means something for position and nothing for direction — the trailing 1 or 0 decides whether the translation column is added.
3. Geometrically, the three column vectors of a rotation matrix are?
- AWhere the new frame's three axes point in the old frame
- BThree eigenvalues
- CThe rotation axis and angle
Show answer
A. Hence each column has unit length and the columns are mutually perpendicular — those 6 constraints are the 6 redundant numbers.
Keep going deeper
Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.
How it fails in the field
- Interpolating in Euler angles: the pose flips near a singularity and to the eye it looks like «the motor twitched»
- Not normalizing quaternions: slow pose drift that gets misdiagnosed as an encoder problem
- Mixing up change of basis with transformation of coordinates: the formula looks right, the direction is wrong, and calibration stays 3 cm off no matter what
You have learned enough when
The Chinese edition carries the full topic page for Linear algebra & rigid-body rotation, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/A1/.