Skip to main content
Geometric transformations map points from one coordinate frame to another. Representing them as homogeneous matrices allows any chain of transformations to be composed by matrix multiplication, and makes the hierarchy of transformation groups explicit.

Hierarchy of 2D transformations

Each class of 2D transformation preserves a strictly smaller set of geometric properties than the one below it.
ClassDOFPreservedMatrix form
Translation2Distances, angles(It01)\begin{pmatrix}I & \mathbf{t}\\ \mathbf{0}^\top & 1\end{pmatrix}
Euclidean (rigid)3Distances, angles(Rt01)\begin{pmatrix}R & \mathbf{t}\\ \mathbf{0}^\top & 1\end{pmatrix}
Similarity4Angles, ratios of lengths(sRt01)\begin{pmatrix}sR & \mathbf{t}\\ \mathbf{0}^\top & 1\end{pmatrix}
Affine6Parallelism, area ratios(At01)\begin{pmatrix}A & \mathbf{t}\\ \mathbf{0}^\top & 1\end{pmatrix}
Projective (homography)8Cross-ratio, collinearity(A~t~vv)\begin{pmatrix}\tilde{A} & \tilde{\mathbf{t}}\\ \mathbf{v}^\top & v\end{pmatrix}

Translation

m=Tm,T=(10tx01ty001)\mathbf{m}' = T\,\mathbf{m}, \qquad T = \begin{pmatrix}1 & 0 & t_x\\ 0 & 1 & t_y\\ 0 & 0 & 1\end{pmatrix}

Rotation by angle θ\theta

R(θ)=(cosθsinθsinθcosθ)R(\theta) = \begin{pmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{pmatrix} The full rigid-body matrix in homogeneous form: HEucl=(cosθsinθtxsinθcosθty001)H_{\text{Eucl}} = \begin{pmatrix}\cos\theta & -\sin\theta & t_x\\ \sin\theta & \cos\theta & t_y\\ 0 & 0 & 1\end{pmatrix}

Affine transformation

Haff=(a11a12txa21a22ty001)H_{\text{aff}} = \begin{pmatrix}a_{11} & a_{12} & t_x\\ a_{21} & a_{22} & t_y\\ 0 & 0 & 1\end{pmatrix} Parallel lines remain parallel under affine maps; angles and lengths in general do not.

Projective (homography)

H=(h11h12h13h21h22h23h31h32h33)H = \begin{pmatrix}h_{11} & h_{12} & h_{13}\\ h_{21} & h_{22} & h_{23}\\ h_{31} & h_{32} & h_{33}\end{pmatrix} defined up to scale (8 degrees of freedom). Straight lines map to straight lines, but parallelism is not preserved.

3D transformations

In 3D the same hierarchy applies. A rigid-body transformation uses a 3×33\times3 rotation matrix RR and a translation vector tR3\mathbf{t}\in\mathbb{R}^3: M=(Rt01)M\mathbf{M}' = \begin{pmatrix}R & \mathbf{t}\\ \mathbf{0}^\top & 1\end{pmatrix}\mathbf{M}

Rotation matrices and the Rodrigues formula

Any 3D rotation can be parameterised by an axis n^\hat{\mathbf{n}} (unit vector) and an angle θ\theta. The Rodrigues rotation formula gives: R=Icosθ+(1cosθ)n^n^+sinθ[n^]×R = I\cos\theta + (1-\cos\theta)\hat{\mathbf{n}}\hat{\mathbf{n}}^\top + \sin\theta\,[\hat{\mathbf{n}}]_\times where [n^]×[\hat{\mathbf{n}}]_\times is the skew-symmetric cross-product matrix: [n]×=(0nznynz0nxnynx0)[\mathbf{n}]_\times = \begin{pmatrix}0 & -n_z & n_y\\ n_z & 0 & -n_x\\ -n_y & n_x & 0\end{pmatrix} In MATLAB, the compact Rodrigues vector ω=θn^\boldsymbol{\omega} = \theta\hat{\mathbf{n}} encodes both axis and angle in 3 numbers, and the conversion is available via rodrig2R / R2rodrig.

3D-to-2D perspective projection

The full camera projection matrix PP maps a 3D world point M\mathbf{M} to a 2D image point m\mathbf{m}: mPM,P=K[R    t]\mathbf{m} \sim P\,\mathbf{M}, \qquad P = K\,[R\;|\;\mathbf{t}] where KK is the intrinsic matrix (see Camera Calibration): K=(fxscx0fycy001)K = \begin{pmatrix}f_x & s & c_x\\ 0 & f_y & c_y\\ 0 & 0 & 1\end{pmatrix}

MATLAB examples

% Interactive 2D transformation demo using Balu Toolbox
% 1. Go to the folder containing painting.png
%    cd ../images
% 2. Launch the GUI
Bmv_guihomography
% 3. Press Load and type 'painting.png'
% 4. Use the GUI buttons to apply:
%    - rotation, translation, similarity, affine, projective

Python examples

3D transformations (Colab)

Notebook covering rotation matrices, the Rodrigues formula, and 3D-to-2D perspective projection in Python.

Video lecture

Lecture: 2D transformations and homographies (2021)

Recorded class covering the full hierarchy of 2D transformations and their homogeneous matrix representations.

Key properties at a glance

Because every transformation is a matrix, composing two transformations is just matrix multiplication: Htotal=H2H1H_{\text{total}} = H_2 H_1. The order matters — matrix multiplication is not commutative in general.
For a rigid-body matrix (R,t)(R,\mathbf{t}) the inverse is (R,Rt)(R^\top, -R^\top\mathbf{t}), since rotation matrices are orthogonal (R1=RR^{-1} = R^\top). This is much cheaper than a general matrix inversion.
Translation: 2 (tx, ty). Euclidean: 3 (+angle). Similarity: 4 (+scale). Affine: 6 (full 2×2 matrix + translation). Projective: 8 (3×3 matrix up to scale). In 3D, rigid-body has 6 DOF (3 rotation + 3 translation).
Euclidean: distances and angles. Similarity: angles and length ratios. Affine: parallelism, ratios of collinear lengths, area ratios. Projective: cross-ratio of four collinear points, and collinearity.