Linear Algebra · Theory · M4
M4-T5 — Orthogonal Matrices
Orthogonal matrices turn the plane without stretching it. They are rotations and reflections, and they are numerically perfect.
Every rotation of a robot is an orthogonal matrix. So are the Householder reflections inside a QR solver, and the orthogonal factors of the SVD. They all share one property that you have just met in a basis: perpendicular unit columns. This lesson collects what follows from it, and why these matrices are the safe building blocks of numerical robotics.
Learning objectives
After this lesson, you should be able to:
- Define an orthogonal matrix and state QᵀQ = QQᵀ = I, Q⁻¹ = Qᵀ.
- Show that orthogonal matrices preserve lengths, dot products and angles, and have determinant ±1.
- Distinguish rotations (det +1) from reflections (det −1) and give examples of each.
- Explain why orthogonal matrices do not amplify errors and where they are used in robotics software.
Introduction and motivation
When a robot changes frames, it should not change the length of anything: a wall that is 3 m long must still be 3 m long after the conversion. The matrices that guarantee this are exactly the orthogonal ones, and their inverse is free (a transpose). They also underlie the most reliable algorithms in numerical linear algebra, so a lot of the course rests on them.
The intuition
An orthogonal matrix is a square matrix whose columns are an orthonormal basis. As a transformation it sends the standard axes to a new set of perpendicular unit vectors, so it moves every shape rigidly: lengths and angles are unchanged. It can rotate the plane, or flip it in a mirror, but it cannot stretch, squash or shear.
Interactive figure. A two by two matrix acts on the unit square and an F-shaped outline. For perpendicular unit columns the picture is rotated or mirrored without distortion and the determinant is plus or minus one. This figure needs JavaScript to be interactive.
Geometric and physical interpretation
Geometric view. The columns of Q are the images of the unit axes: perpendicular unit vectors. The whole plane is carried rigidly, as if printed on a rotating (or flipping) transparency. Physical view. A rigid body's orientation is described by an orthogonal matrix with determinant +1: turning a body does not change the distance between any two of its points. A matrix with determinant −1 is a mirror: it exists mathematically but corresponds to no physical rotation, so seeing it in a calibration is a red flag.
The mathematics
- Q
- a square matrix with orthonormal columns.
- Qᵀ
- its transpose: for an orthogonal matrix, also its inverse.
- SO(n)
- the set of rotations: orthogonal matrices with det = +1 (Module 7).
Definition and consequences
QᵀQ = I ⇔ Qᵀ = Q⁻¹ ⇒ Q Qᵀ = I (the rows are orthonormal too)
What it means. Perpendicular unit columns are the same as QᵀQ = I. Then the transpose is the inverse, and because inverses commute with the matrix, the rows are orthonormal as well.
Preserving geometry
‖Q x‖ = ‖x‖ (Q x)·(Q y) = x·y angle(Qx, Qy) = angle(x, y)
What it means. Since lengths and dot products are unchanged, so are angles. This is the sense in which an orthogonal matrix is a rigid motion of the origin-fixed plane or space.
Determinant
det Q = +1 (rotation) or det Q = −1 (reflection)
What it means. The area (volume) scale factor must be 1 in size because shapes are not stretched; the sign records whether orientation is flipped.
Closure
Q₁, Q₂ orthogonal ⇒ Q₁Q₂ orthogonal, Q₁⁻¹ orthogonal
What it means. Composing rigid motions gives a rigid motion, and undoing one gives one. This closure is why chains of frame changes stay rigid.
Orthogonal ⇔ QᵀQ = I. Then Q⁻¹ = Qᵀ, lengths and angles are preserved, det = ±1, and condition number 1.
Step-by-step derivation: length, dot product and determinant
Preserving dot products and lengths. Start from QᵀQ = I.
(Qx)·(Qy) = (Qx)ᵀ(Qy) = xᵀQᵀQy, using(AB)ᵀ = BᵀAᵀ.- Substitute
QᵀQ = I:= xᵀy = x·y. Dot products are preserved. - Setting
y = xgives‖Qx‖² = ‖x‖², so lengths are preserved. Since angles come fromcos θ = x·y/(‖x‖‖y‖), angles are preserved as well.
The determinant. Take the determinant of QᵀQ = I and use det(AB) = det A det B and det Aᵀ = det A: (det Q)² = 1, so det Q = ±1.
The rows are orthonormal. From QᵀQ = I the matrix Qᵀ is the inverse of Q, and an inverse also works from the other side: QQᵀ = I. The entries of QQᵀ are the dot products of the rows of Q, so the rows are orthonormal too.
Closure. If Q₁ and Q₂ are orthogonal, (Q₁Q₂)ᵀ(Q₁Q₂) = Q₂ᵀQ₁ᵀQ₁Q₂ = Q₂ᵀQ₂ = I.
Condition number 1. Because ‖Qx‖ = ‖x‖ for every x, Q stretches no direction more than another: the ratio of the largest to smallest stretch is 1, the best possible. Errors in x reach Qx neither amplified nor reduced.
Reflections. For a unit vector u, H = I − 2uuᵀ reflects across the plane perpendicular to u. It is orthogonal: HᵀH = (I − 2uuᵀ)² = I − 4uuᵀ + 4u(uᵀu)uᵀ = I, using uᵀu = 1. Householder QR is built from such matrices.
A worked example: checking, applying and distinguishing
Let Q = [[0.6, −0.8], [0.8, 0.6]] (a rotation by about 53.13°).
- Orthogonal?
QᵀQ = [[0.36 + 0.64, −0.48 + 0.48], [−0.48 + 0.48, 0.64 + 0.36]] = I. ✓ - Length.
Q (3, 4) = (1.8 − 3.2, 2.4 + 2.4) = (−1.4, 4.8), and‖(−1.4, 4.8)‖² = 1.96 + 23.04 = 25 = ‖(3, 4)‖². ✓ - Inverse.
Q⁻¹ = Qᵀ = [[0.6, 0.8], [−0.8, 0.6]]. Applying it to(−1.4, 4.8)returns(−0.84 + 3.84, 1.12 + 2.88) = (3, 4). ✓ - Determinant.
det Q = 0.36 + 0.64 = 1: a rotation. - A reflection.
H = [[1, 0], [0, −1]]is orthogonal withdet H = −1: it flips y. - Not orthogonal.
[[1, 1], [0, 1]](a shear) has columns that are not perpendicular, and it changes length: it sends (0, 1) of length 1 to (1, 1) of length 1.414.
Robotics application
Rotations. The rotation matrices of Module 7 are the orthogonal matrices with determinant +1. Their inverse is the transpose, which is why converting back from the robot frame to the sensor frame is cheap and exact. See rotation matrices, quaternions and poses.
Drift repair. A rotation matrix updated from gyro integration slowly stops being orthogonal. Detect it with max|QᵀQ − I| and repair by replacing Q with the nearest orthogonal matrix (computed with the SVD in Module 6).
Numerical building blocks. QR (Householder reflections) and SVD both factor a matrix into orthogonal pieces plus something simple. Because orthogonal factors do not amplify errors, algorithms built on them are the gold standard for stability; Module 5 and Module 6 use this heavily.
Calibration checks. A calibrated rotation between two sensor frames must be orthogonal with determinant +1. A determinant of −1 means a mirrored axis; an off-diagonal entry of QᵀQ far from zero means a shear or a scale difference was hidden in the calibration.
Engineering implications and limitations
Practical rules
- Invert by transposing. Never call a general inverse on a rotation matrix. The transpose is exact, free and well-conditioned.
- Monitor orthogonality. Track
‖QᵀQ − I‖in any code that updates a rotation incrementally, and re-orthogonalise when it exceeds a tolerance such as 10⁻⁹. - Also check the determinant. Orthogonality alone allows reflections. A proper rotation needs
det Q = +1; test both. - Prefer the SVD for repair. The nearest orthogonal matrix to a drifted M with SVD
M = UΣVᵀisUVᵀ. It treats all axes fairly, unlike Gram-Schmidt, which favours the first. - Precision of stored matrices. A rotation stored in single precision is orthogonal only to about 10⁻⁷; for long integrations keep a double-precision state or use a minimal parametrisation (quaternion, Module 7).
Limits
Orthogonal matrices have exactly the same input and output dimension, and they describe rigid maps fixing the origin. Translations are not orthogonal matrices; adding them requires the homogeneous form of Module 7, whose 4 × 4 matrices are not orthogonal even though their rotation block is.
Common misconceptions
“A matrix with orthogonal columns is orthogonal.”
The columns must be orthonormal: unit length as well as perpendicular. A matrix with perpendicular columns of different lengths scales space and is not orthogonal (it is a rotation times a diagonal scaling).
“An orthogonal matrix is always a rotation.”
Only if det = +1. A reflection is orthogonal with det = −1.
“Orthogonal matrices must be symmetric.”
Rarely: rotation matrices by angles other than 0 and 180 degrees are not symmetric. Symmetric orthogonal matrices are special (reflections and 180° turns).
“Any invertible matrix can be inverted by its transpose.”
Only orthogonal ones. For a general matrix Aᵀ and A⁻¹ are different.
Engineering takeaways
- An orthogonal matrix has orthonormal columns: QᵀQ = I, so Q⁻¹ = Qᵀ and the rows are orthonormal too.
- It preserves lengths, dot products and angles: ‖Qx‖ = ‖x‖ and (Qx)·(Qy) = x·y.
- det Q = +1 for a rotation and −1 for a reflection.
- Products and inverses of orthogonal matrices are orthogonal; the condition number is 1.
- Rotations, Householder reflections and the factors of the SVD are orthogonal: the numerically safest matrices.
References and further reading
Primary papers and authoritative documentation.
- MIT 18.06SC Linear Algebra (OCW): lecture on orthogonal matrices
- Modern Robotics (Lynch and Park), free preprint: chapter 3: the properties of rotation matrices
- 3Blue1Brown, Essence of Linear Algebra: rotations and orthogonality
- Boyd and Vandenberghe, Introduction to Applied Linear Algebra (VMLS): the chapter on orthogonal matrices and QR; the site did not load when we last checked
Knowledge check
Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.
Question 1
Is Q = [[0, 1], [−1, 0]] orthogonal? What is its determinant and what does it do to the point (2, 1)?
Explanation
Columns (0, −1) and (1, 0) are perpendicular unit vectors, and QᵀQ = I, so Q is orthogonal. det Q = 0·0 − 1·(−1) = +1, so it is a rotation (by −90°, i.e. clockwise a quarter turn). Q(2, 1) = (1, −2): the length √5 is preserved.
Question 2
A rotation matrix updated from gyro data now satisfies max|QᵀQ − I| = 3·10⁻⁴. Why is this a problem, and how can you repair it without changing the rotation much?
Explanation
Treating such a matrix as a rotation introduces a systematic error: lengths are no longer preserved (by up to ~10⁻⁴ per use) and Qᵀ is no longer an accurate inverse, and the errors compound as the matrix keeps being multiplied. Repair it by replacing Q with the nearest orthogonal matrix (via the SVD, M = UΣVᵀ → UVᵀ), then check det = +1.
Question 3
Why does the condition number of an orthogonal matrix equal 1, and why does that make orthogonal factors desirable in algorithms?
Explanation
Q preserves the length of every vector, so no direction is stretched more than another: the ratio of largest to smallest stretch is 1, the minimum possible. An error in the input appears in the output at the same size, never magnified. Algorithms that work by applying orthogonal factors therefore add essentially no error beyond rounding, which is why QR and SVD are the preferred tools.
What’s next
The last lesson of this module studies a different use of symmetric matrices: quadratic forms, the expressions that give squared lengths, energies and uncertainty ellipses.
Related content
Nothing below is required to finish this lesson.
- BeforeM4-T4: The Gram-Schmidt Process
Turn independent vectors into an orthonormal basis step by step, and recognise its numerical weakness.
- BeforeM2-T4: Matrices as Linear Transformations
Read the columns of a matrix as where the basis vectors land, and recognise scaling, rotation, reflection and shear.
Get notified when the next lesson and new labs are released.
One email per new lesson or lab.