JOVANA
Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Rotation Matrices: Writing Down a Turn

How a 3×3 grid of numbers captures orientation exactly, and why its columns are just the rotated axes.

Why orientation needs a number, not a word

A robot has to agree with itself about which way its hand is pointing. "Tilted a bit to the left" is fine for a person, but a computer needs something it can store, compare, and multiply. That something is the rotation matrix: a small, fixed-size block of numbers that pins down orientation exactly, with no ambiguity and no leftover guesswork.

Remember the setup from earlier rungs: every measurement lives in some coordinate frame, and a robot juggles many of them at once — a world frame bolted to the floor, and a body frame riding on the moving part. A rotation matrix is the precise statement of how one frame is turned relative to another. Once you have it, you can answer questions like "if the camera sees the cup over there, where is it for the gripper?"

The trick: each column is a rotated axis

Here is the whole idea in one sentence. Take the body frame's three unit arrows — the little x, y, z axes painted on the moving part — and ask where each one points after the turn, written in the world frame's numbers. Stack those three answers side by side as columns, and you have built the rotation matrix. The first column is where the body's x-axis landed, the second is where y landed, the third is where z landed.

That is why the matrix is 3×3 and not, say, a single angle. In flat 2D, one number (the turn angle) is enough. In 3D you can turn around three independent directions, and you need to record where all three axes ended up — three columns of three numbers each. The grid is not arbitrary bookkeeping; it is literally a snapshot of the rotated axes.

Multiplying: rotating a point, chaining turns

The payoff is that the matrix does real work by ordinary multiplication. Take any point written as a position vector, multiply the matrix by it, and out comes that same point after the rotation. You do not need trigonometry every time — the nine numbers already encode the turn, and matrix-times-vector just blends the columns in the right amounts. A computer can do millions of these per second without ever thinking about angles.

Even better, turns chain by multiplying matrices together. Rotate by A, then by B, and the combined turn is the single matrix you get from B times A. So a long arm with many joints, each adding its own twist, collapses into one product you compute once. This is exactly the composing-transforms idea you will lean on everywhere — though note the order matters: B times A is generally not A times B, because turning then tilting does not equal tilting then turning.

2D rotation by angle t (the simplest case):

    [ cos t   -sin t ]
    [ sin t    cos t ]

Column 1 = where the x-axis lands = (cos t, sin t)
Column 2 = where the y-axis lands = (-sin t, cos t)

Rotate a point p = (px, py):

    new_px = cos t * px  -  sin t * py
    new_py = sin t * px  +  cos t * py
The 2D rotation matrix made of two rotated axes; 3D is the same idea with a third column.

SO(3): the family of clean rotations

Not every 3×3 grid is a valid rotation. A real rotation never stretches, squashes, or mirrors space — it only turns it. The set of all matrices that pass this test has a name: the special orthogonal group SO(3). Think of it as the membership club for honest rotations; the three-columns-are-axes picture from earlier is precisely what membership looks like.

Two simple properties define the club. First, orthogonality: the three columns are unit-length and at right angles to each other — that is just "the rotated axes are still a clean, square set of axes." Second, the determinant equals +1, which forbids the sneaky mirror-flip that would turn a right hand into a left hand. Together they guarantee the matrix is a pure turn and nothing else.

Orthogonality hands you a lovely freebie: to undo a rotation, you just flip the matrix across its diagonal (its transpose) instead of doing expensive inverse arithmetic. "Where is the cup for the gripper?" and "where is the gripper for the cup?" are then one cheap step apart. This is the practical reason robotics code stores orientation as a rotation matrix even though it costs nine numbers.