Skip to the lesson
FixTheRobot Explore Robotics / Linear Algebra / M7 Rotations and Rigid-Body Transformations / M7-T4

Linear Algebra · Theory · M7

M7-T4 — SO(3)

A 3D rotation is a 3 × 3 matrix that preserves lengths and handedness. Those two conditions leave exactly three free numbers.

  • Lesson 4 of 9
  • Module 7: Rotations and Rigid-Body Transformations
  • Rotations and rigid bodies
  • About 8 minutes to read

Rotation matrices are not arbitrary 3 × 3 arrays: they live in a curved three-dimensional subset of nine-dimensional matrix space. Knowing the defining conditions lets you validate a matrix, repair one that has drifted, extract the angle and axis, and understand why rotations are the subject of Lie-group methods in Module 10.

Learning objectives

After this lesson, you should be able to:

  • State the definition of SO(3): RᵀR = I and det R = +1.
  • Show closure, identity and inverse, and count three degrees of freedom.
  • Extract the rotation angle from the trace and the axis from the eigenvector with eigenvalue 1.
  • Project a drifted matrix back onto SO(3) with the SVD.

Introduction and motivation

A flight controller multiplies tiny rotation matrices thousands of times a second. Rounding makes the product slightly non-orthogonal: columns that are no longer perpendicular unit vectors. After a minute the “rotation” also scales and shears the vehicle's vectors, and the attitude estimate is garbage. The cure is to know exactly what a valid rotation matrix is and to project back onto that set regularly.

The intuition

A rotation must keep every length and angle, which means its columns have to be unit vectors that are mutually perpendicular (an orthonormal frame). It must also keep the right-hand rule, so it cannot be a mirror image. Those are the only two requirements. Because an orthonormal frame has three directions each pinned by the previous ones, only three numbers are really free.

SO(3): the group of rotationsA diagram of the defining properties of the rotation group: closure under multiplication, an identity, an inverse equal to the transpose, and the constraints orthogonality and determinant plus one that cut nine entries down to three degrees of freedom.R ∈ SO(3) ⇔ Rᵀ R = I and det R = +1 closureR₁R₂ ∈ SO(3)compose freely inverseR⁻¹ = Rᵀno matrix inversion identityI ∈ SO(3)no rotation 9 − 6 = 3degrees of freedom6 orthonormality conditions Not commutative: R₁R₂ ≠ R₂R₁ in general.
SO(3) is closed under composition, has inverse equal to the transpose, and has three degrees of freedom.

Interactive figure. A wireframe box rotated by roll, pitch and yaw. The readout shows the rotation matrix and the checks that its determinant is one and that its transpose times itself is the identity. This figure needs JavaScript to be interactive.

Whatever angles you choose, the readout reports det R = 1 and RᵀR − I = 0: those checks are the definition. Try pitch 90° to reach an edge of the angle description while R remains a perfectly valid rotation.

Geometric and physical interpretation

Geometric view. Orthogonality preserves dot products: (Ru)·(Rv) = uᵀRᵀRv = u·v, hence lengths and angles. A determinant of +1 additionally preserves orientation; a matrix with RᵀR = I and det = −1 is a reflection or an improper rotation. Euler's theorem. Every rotation in 3D is a turn by one angle about one fixed axis: the axis is the eigenvector with eigenvalue 1. Physical view. A rigid robot body has exactly three rotational degrees of freedom, matching dim SO(3) = 3.

The mathematics

SO(3)
the special orthogonal group in 3D: all rotation matrices.
O(3)
all orthogonal matrices (rotations and reflections).
θ, n
the rotation angle and unit axis of Euler's theorem.
tr R
the trace, the sum of the diagonal entries.

Definition

SO(3) = { R ∈ ℝ³ˣ³ : Rᵀ R = I,  det R = +1 }

What it means. Orthogonality gives the six independent conditions (three unit lengths, three perpendicularities) that remove six degrees of freedom from nine entries; det = +1 chooses the right-handed half.

Group axioms

R₁, R₂ ∈ SO(3) ⇒ R₁R₂ ∈ SO(3);   I ∈ SO(3);   R ∈ SO(3) ⇒ R⁻¹ = Rᵀ ∈ SO(3)

What it means. Composing two rotations gives a rotation, doing nothing is a rotation, and every rotation can be undone by a rotation. Matrix multiplication is associative, so these make SO(3) a group; it is not commutative.

Angle and axis

cos θ = (tr R − 1)/2        R n = n   (n is the eigenvector with eigenvalue 1)

What it means. The trace gives the angle (the other two eigenvalues are e^(±iθ), which sum with 1 to the trace 1 + 2 cos θ). The axis is the line of vectors the rotation leaves unchanged.

SO(3) = orthogonal matrices with determinant +1. They compose, invert by transposing, have three degrees of freedom, and each is a turn about one axis by one angle.

Step-by-step derivation: closure, determinant ±1, and the angle formula

  1. Closure. If R₁ᵀR₁ = I and R₂ᵀR₂ = I, then (R₁R₂)ᵀ(R₁R₂) = R₂ᵀR₁ᵀR₁R₂ = R₂ᵀR₂ = I. And det(R₁R₂) = det R₁ det R₂ = 1.
  2. Inverse. RᵀR = I says Rᵀ is a left inverse of the square matrix R, hence the inverse. Also (Rᵀ)ᵀ Rᵀ = R Rᵀ = I and det Rᵀ = 1, so Rᵀ ∈ SO(3).
  3. Determinant ±1. 1 = det(RᵀR) = (det R)², so det R = ±1; the condition det R = +1 picks the proper rotations.
  4. Degrees of freedom. The equation RᵀR = I is a symmetric matrix equation, so it has 6 independent entries, i.e. 6 constraints on 9 numbers, leaving 3.
  5. Axis (Euler's theorem). Eigenvalues of R have magnitude 1 (because ‖Rv‖ = ‖v‖), their product is det R = 1, and complex ones come in conjugate pairs. In 3D this forces the eigenvalue set {1, e^(iθ), e^(−iθ)}, so an eigenvector with eigenvalue 1 always exists: that is the axis.
  6. Angle. The trace is the sum of eigenvalues: tr R = 1 + 2 cos θ, so cos θ = (tr R − 1)/2. The trace gives only |θ|; the sign follows from the axis direction.

Nearest rotation (projection onto SO(3)). Given a nearly-orthogonal matrix A = UΣVᵀ, the closest orthogonal matrix in the Frobenius norm is U Vᵀ, obtained by setting every singular value to 1. If det(UVᵀ) = −1, flip the sign of the last column of U first: R = U diag(1, 1, det(UVᵀ)) Vᵀ (the same formula as in the Kabsch/Umeyama registration algorithm). Gram-Schmidt on the columns is a cheaper, order-dependent alternative.

Why orthogonal matrices are stable. cond(R) = 1: multiplication by R neither amplifies nor shrinks errors, which is why rotations are numerically benign.

A worked example: checking, reading and repairing a rotation

  • Checking. R = [[0, −1, 0], [0, 0, 1], [−1, 0, 0]]: the columns (0, 0, −1), (−1, 0, 0), (0, 1, 0) are unit and mutually perpendicular. Its determinant is 0·(0·0 − 1·0) − (−1)(0·0 − 1·(−1)) + 0 = 1·(1) = 1. So R ∈ SO(3).
  • Angle. The trace is 0, so cos θ = (0 − 1)/2 = −0.5 and θ = 120°.
  • Axis. Solve R n = n: try n = (−1, 1, 1)/√3. Then R(−1, 1, 1) = (0·(−1) − 1·1 + 0, 0 + 0 + 1, −1·(−1) + 0 + 0) = (−1, 1, 1) ✓. So this is a 120° turn about the axis (−1, 1, 1)/√3, which cycles the three coordinate axes.
  • A reflection. diag(1, 1, −1) has RᵀR = I but det = −1: orthogonal, yet not a rotation (it mirrors z).
  • Repairing a drifted matrix. Start from Rz(30°) and add 0.02 to every entry (simulated drift): the matrix has det = 1.0546 and AᵀA has diagonal 1.056, 1.016, 1.041, so it stretches vectors by up to 3 %. Setting its singular values to 1 gives R = UVᵀ, with det = 1, RᵀR = I and each entry within 0.0085 of the true Rz(30°).

Robotics application

Attitude filters. The orientation of a UAV or ground robot is integrated from gyro readings; the matrix or quaternion is re-normalised every step to stay in SO(3); see quaternion-based orientation.

Scan registration. The optimal alignment of two LiDAR clouds is found with an SVD-based projection onto SO(3) (Kabsch), so the answer is a valid rotation, not just a best-fit matrix; see ICP fundamentals and rotation matrices, quaternions and poses.

Calibration. Estimating a camera-to-IMU rotation by linear algebra returns an unconstrained 3 × 3; projecting onto SO(3) gives a physically valid extrinsic; see extrinsic calibration.

Mobile robots. Checking det R = +1 catches a mirrored map caused by a sign error in a mounted sensor.

Engineering implications and limitations

Practical rules

  • Test validity with two numbers. ‖RᵀR − I‖ small (say below 1e-9) and det R close to +1. Reject or repair a matrix otherwise.
  • Repair with the SVD, not by dividing columns. Normalising columns one by one does not restore perpendicularity. Use U diag(1, 1, det(UVᵀ)) Vᵀ.
  • Do not use arccos on the raw trace. Rounding can push (tr − 1)/2 just outside [−1, 1]; clip it before arccos, and use a method based on the skew part near θ = 0 or π, where the formula loses accuracy.
  • Near 180° the axis is ill-defined. The skew-symmetric part vanishes; extract the axis from the symmetric part (R + I)/2 instead.
  • Use unit quaternions or Lie-algebra updates for long integrations. They have 4 or 3 numbers with a single constraint (or none), so drift is easier to control.

Limits

SO(3) is a curved manifold, not a vector space: you cannot add rotations, average them entrywise or take standard Euclidean differences. The Lie-algebra tools of Module 10 provide the correct notions of difference, mean and uncertainty.

Common misconceptions

“Any orthogonal matrix is a rotation.”

Orthogonal matrices with determinant −1 are reflections. A rotation needs det = +1.

“A rotation has nine free parameters.”

It has three: orthonormality imposes six constraints.

“Rotations form a vector space.”

The sum of two rotation matrices is not a rotation. Only products stay in SO(3).

“The trace gives the full rotation.”

The trace gives only the angle magnitude. The axis (and the sign of the angle) must come from elsewhere.

Engineering takeaways

  1. SO(3) = {R : RᵀR = I, det R = +1}: lengths, angles and handedness are preserved.
  2. Rotations are closed under multiplication, include the identity and invert by transposing; the group is not commutative.
  3. Nine entries minus six orthonormality constraints leave three degrees of freedom.
  4. Euler's theorem: every rotation is an angle θ about an axis n, with cos θ = (tr R − 1)/2 and R n = n.
  5. Repair drift by projecting onto SO(3) with the SVD: R = U diag(1, 1, det(UVᵀ)) Vᵀ.

References and further reading

Primary papers and authoritative documentation.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

Is R = [[0, 1, 0], [−1, 0, 0], [0, 0, 1]] a rotation? If so, find its angle and axis.

Explanation

Columns (0, −1, 0), (1, 0, 0), (0, 0, 1) are orthonormal, and det = 0·(0 − 0) − 1·(−1·1 − 0) + 0 = 1, so it is in SO(3). Trace = 1, cos θ = 0, θ = 90°, and the eigenvector for eigenvalue 1 is (0, 0, 1): a −90° turn about z (it is Rz(−90°)).

Question 2

After many integrations a matrix has AᵀA = diag(1.02, 1.00, 0.98) and positive determinant ≈ 1.0. What does it do to a unit vector along its first axis, and how would you repair it?

Explanation

It scales that direction: the length becomes √1.02 = 1.01, and the third axis by √0.98 = 0.99. Repair with the SVD: set the singular values (here √1.02, 1, √0.98) to 1, giving R = UVᵀ, then check det = +1.

Question 3

Why is a mirror image (reflection) not a physically possible rigid motion even though it preserves distances?

Explanation

A reflection has determinant −1: it reverses handedness (a left hand becomes a right hand). A rigid body cannot be continuously moved into its mirror image, and the continuous family of rotations from the identity only reaches determinant +1. Transforming a body with a det −1 matrix is almost always a frame-convention bug.

What’s next

Rotation matrices alone cannot move a robot: they fix the origin. To describe a full rigid motion, rotation plus translation, we use a trick that folds both into a single matrix product: homogeneous coordinates.

Next lesson

M7-T5 — Homogeneous Transformations

Combine rotation and translation in one matrix using homogeneous coordinates.

Nothing below is required to finish this lesson.