Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

3D transformations

Clear, exam-focused notes on 3D transformations: definitions, matrix forms in homogeneous coordinates, composition, inverses, axis-angle rotation (Rodrigues), worked numerical examples, common mistakes and exam guidance.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

3D transformations convert points and vectors between coordinate frames and move, scale or rotate models in a scene. An engineer uses them when building graphics pipelines (model → world → view → projection), doing CAD/CAM operations, robotics kinematics, and when writing or using APIs like OpenGL or DirectX.

Key ideas

  • Vector vs point: a point has position (x,y,z); a vector represents direction and magnitude and is invariant under translation. In homogeneous coordinates we keep this distinction with w = 1 for points and w = 0 for pure direction vectors.

  • Translation: shifting every point by a constant vector t = (tx,ty,tz). Translation is not a purely linear map in R3 but is affine; representable as a linear map in homogeneous 4D.

  • Scaling: multiplying coordinates by scale factors sx, sy, sz from the origin. Uniform scaling preserves shape (up to size), non-uniform scaling stretches differently along axes.

  • Rotation: rigid motion about an axis through the origin that preserves lengths and angles. A rotation matrix is orthogonal (its columns/rows form an orthonormal basis) with determinant +1. (Assumption: right-handed coordinate system and column-vector convention: v' = M v.)

  • Homogeneous coordinates: represent a 3D point (x,y,z) as a 4-vector (x,y,z,1). Using 4×4 matrices lets translation be expressed as matrix multiplication: v'_h = M v_h. This is the standard method in graphics pipelines.

  • Standard 3×3 rotation matrices about axes (derived below) follow from rotating the basis vectors. To derive Rz(θ): draw the x-y plane, mark original basis e_x at (1,0) and e_y at (0,1). After rotation by θ about z, e_x maps to (cosθ, sinθ) and e_y maps to (-sinθ, cosθ) if using column vectors that transform basis columns; assembling these column images gives Rz.

  • Composition: applying transformations in sequence corresponds to matrix multiplication. If you first apply S, then R, then T to column vector v, the combined matrix is M = T·R·S and v' = M·v. The rightmost matrix acts first. Order matters: matrix multiplication is non-commutative.

  • Affine transformation: a map x ↦ A x + t where A is 3×3 and t is translation. In homogeneous form: [A t; 0 1]. Affine transforms preserve straight lines and parallelism but not necessarily lengths or angles.

  • Inverse transforms: a transform is invertible if and only if the linear part A is invertible (det(A) ≠ 0). For a homogeneous matrix M = [A t; 0 1], M^{-1} = [A^{-1} -A^{-1} t; 0 1]. For a pure rotation matrix R, R^{-1} = R^T because rotation matrices are orthonormal.

  • Axis–angle and Rodrigues' formula: a rotation by angle θ around a unit axis u (|u|=1) has a closed form called Rodrigues' rotation formula, useful for rotating vectors without building a full 4×4 matrix. Matrix form: R = I cosθ + [u]× sinθ + u u^T (1 - cosθ), where [u]× is the skew-symmetric cross-product matrix.

  • Right-hand rule: by convention, a positive rotation angle rotates counterclockwise when looking along the axis direction from the origin toward the tip of the axis vector (i.e., thumb points along axis, fingers curl in positive rotation direction).

What to draw for exam derivations:

  • For Rz(θ): draw x-y plane, show e_x and e_y arrows before and after rotation; label (cosθ, sinθ) etc. Write the 3×3 matrix whose columns are images of basis vectors.
  • For homogeneous matrix for T(t): draw a point P(x,y,z), a translation vector t, and P' = P + t; write 4-vector forms and the 4×4 matrix.

Formulas

R_x(θ) = [[1, 0, 0],[0, cosθ, -sinθ],[0, sinθ, cosθ]] — R_x(θ) rotates about x-axis by angle θ; θ in radians.

  • Symbols: θ (rad) angle of rotation. Matrix entries are dimensionless.

R_y(θ) = [[cosθ, 0, sinθ],[0, 1, 0],[-sinθ, 0, cosθ]] — rotation about y-axis.

R_z(θ) = [[cosθ, -sinθ, 0],[sinθ, cosθ, 0],[0, 0, 1]] — rotation about z-axis.

T(tx,ty,tz) = [[1,0,0,tx],[0,1,0,ty],[0,0,1,tz],[0,0,0,1]] — homogeneous translation matrix; tx,ty,tz in metres (m).

S(sx,sy,sz) = [[sx,0,0,0],[0,sy,0,0],[0,0,sz,0],[0,0,0,1]] — homogeneous scaling; scale factors dimensionless. Sh(sh_xy,sh_xz,sh_yx,sh_yz,sh_zx,sh_zy) = [[1,sh_xy,sh_xz,0],[sh_yx,1,sh_yz,0],[sh_zx,sh_zy,1,0],[0,0,0,1]] — homogeneous shear; shear factors dimensionless (e.g., x' = x + sh_xy·y + sh_xz·z).

M_affine = [[A, t],[0, 1]] — 4×4 matrix with 3×3 A and 3×1 t, where A acts on directions and t translates points.

v_h' = M v_h — homogeneous-vector transform; v_h and v_h' are 4×1, last component 1 for points. For pure direction vectors, use w = 0 so translation has no effect.

M_combined = T · R · S — example of composition; order important. Rotate/scale about a pivot point p: M = T(p) · R (or S) · T(-p).

M^{-1} = [[A^{-1}, -A^{-1} t],[0,1]] — inverse of affine matrix (requires det(A) ≠ 0). Normal transform: for surface normals n, use n' ∝ (A^{-1})^T n (or with full 4×4, n' ∝ (M^{-1})^T n), then renormalize.

Rodrigues: v' = v cosθ + (u × v) sinθ + u(u · v)(1 - cosθ) — rotate vector v (m) about unit axis u (dimensionless) by θ (rad). Result v' has same units as v.

If R is a rotation matrix then R^{-1} = R^T and det(R) = +1 — properties of proper rotations.

Units: positions and translations in metres (m); scale factors dimensionless; angles in radians (rad). Matrix entries mixing lengths and dimensionless quantities are valid because homogeneous coordinates separate translation via the extra coordinate. In a 4×4 affine matrix, only the last column (translation) carries length units; the 3×3 linear block and bottom row are dimensionless; w is unitless.

Worked examples

Example 1 — compose scale, rotate about z, translate (numerical). Given: point P = (1.0, 2.0, 3.0) m. Apply scaling S with sx=2, sy=0.5, sz=1. Then rotate about z by θ = 90° = π/2 rad. Then translate by t = (1.0, -2.0, 0.5) m. Use column-vector convention. Steps:

  1. Write S as 3×3 acting on coordinates: S3 = diag(2,0.5,1). Apply to P: S3·P = (2·1.0, 0.5·2.0, 1·3.0) = (2.0, 1.0, 3.0) m.
  2. Rotation about z by 90°: Rz = [[0,-1,0],[1,0,0],[0,0,1]]. Apply to result: Rz·(2.0,1.0,3.0) = (-1.0, 2.0, 3.0) m.
  3. Translate by t: add component-wise P' = (-1.0 + 1.0, 2.0 - 2.0, 3.0 + 0.5) = (0.0, 0.0, 3.5) m. Final answer: P' = (0.0, 0.0, 3.5) m. (Also can be written in homogeneous matrix form M = T·R·S and multiply 4×4 matrices then 4×1 vector.)

Example 2 — rotate a vector about an arbitrary axis using Rodrigues' formula. Given: unit axis u = (1,1,0)/√2, point (vector) v = (1,0,0) m, angle θ = 45° = π/4 rad. Compute u explicitly: u = (1/√2, 1/√2, 0) ≈ (0.70710678, 0.70710678, 0). Compute dot and cross: u·v = 0.70710678. u × v = (0, 0, -1/√2) ≈ (0, 0, -0.70710678). cosθ = √2/2 ≈ 0.70710678, sinθ = 0.70710678. Apply Rodrigues: v cosθ = (0.70710678, 0, 0) m. (u × v) sinθ = (0, 0, -0.70710678 * 0.70710678) = (0, 0, -0.5) m. u(u·v)(1-cosθ): scalar s = (u·v)(1-cosθ) = 0.70710678*(1-0.70710678) ≈ 0.20710678. Multiply by u: (0.207106780.70710678, 0.207106780.70710678, 0) ≈ (0.14644661, 0.14644661, 0) m. Sum components: v' ≈ (0.70710678+0.14644661, 0+0.14644661, 0-0.5) = (0.85355339, 0.14644661, -0.5) m. Final answer: v' ≈ (0.8535534, 0.1464466, -0.5) m.

Example 3 — inverse of an affine transform (short model answer). Given M = [A t; 0 1] with A = [[2,0,0],[0,3,0],[0,0,4]] and t = (1,2,3) m. Compute M^{-1}. A^{-1} = diag(1/2, 1/3, 1/4). Then -A^{-1} t = (-0.5, -0.6666667, -0.75) m. So M^{-1} = [[1/2,0,0,-0.5],[0,1/3,0,-0.6666667],[0,0,1/4,-0.75],[0,0,0,1]].

Common mistakes

  • Multiplying matrices in the wrong order (apply transformations left-to-right instead of right-to-left for column-vector convention).
  • Mixing degrees and radians when plugging into cos/sin.
  • Not normalising an axis vector before using Rodrigues' formula (gives wrong magnitude).
  • Assuming rotation matrices commute with scaling or other rotations (they generally do not).
  • Using row-vector instead of column-vector convention without changing multiplication order; confusion over whether M·v or v·M applies.
  • Forgetting that non-uniform scaling changes lengths differently and may turn rotations into non-orthonormal A, so inverse is not transpose. Negative scaling introduces a reflection (det(A) < 0), flips handedness, and requires care with normal orientation (use the inverse–transpose).

For your exam

Kinds of questions:

  • Definitions: explain homogeneous coordinates, affine transformation, rotation matrix properties.
  • Short notes: compare affine vs linear transforms, right-hand rule, properties of rotation matrices.
  • Derivations: derive rotation matrix about x/y/z (draw basis vectors); derive homogeneous translation matrix; derive yaw–pitch–roll (Euler angles) rotation matrices and discuss order/gimbal lock; derive change-of-basis and the lookAt view matrix.
  • Numericals: apply a given sequence of transforms to a point (show matrices and steps, give units).
  • Proofs: show that rotation matrices are orthonormal and inverse equals transpose; show inverse of affine matrix formula.
  • Diagram questions: draw before/after basis vectors when rotating; show translation vector and resulting point. What full-marks answers include:
  • State conventions (column-vector, right-handed) at the start.
  • Draw labelled diagrams where asked (basis vectors, angles, axis).
  • Show intermediate matrices and multiplication order; show numeric intermediate vectors and final numeric answer with units.
  • If using Rodrigues or an axis, show normalization step explicitly.

Quick check

  1. What is the homogeneous 4×4 matrix for translation by (3 m, -1 m, 0.2 m)?
  2. If R is a rotation matrix, what is R^{-1} and what is det(R)?
  3. Using column-vector convention, if you first rotate then translate, what is the combined matrix order?

Answers: 1) [[1,0,0,3],[0,1,0,-1],[0,0,1,0.2],[0,0,0,1]] 2) R^{-1} = R^T, det(R) = +1 3) Combined M = T · R (apply R first, then T).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?