2D Homogeneous Vectors and Matrix transformations


We represent a point in 2D by its homogeneous form, as a column vector:

x
y
w

This is the transpose of the row vector [x y w], so we can also refer to it as [x y w]T.

We generally "normalize" this vector by scaling it so that w = 1. For example, we would convert [4 6 2]T to [2 3 1]T. The exception is a point at infinity (ie: a direction vector), in which case w = 0.


We represent transformations of points in 2D by 3×3 matrices:
x'       a   b   c       x
y'   ←   d   e   f   ×   y
w'       g   h   i       w

The following are convenient primitive matrices:

The identity matrix transforms a point to itself:

x       1   0   0       x
y   ←   0   1   0   ×   y
w       0   0   1       w

A translation matrix translates the position of a point:

x+a       1   0   a       x
y+b   ←   0   1   b   ×   y
w       0   0   1       w

A rotation matrix rotates points about the origin:

 cosθ x + sinθ y        cosθ   sinθ   0       x
-sinθ x + cosθ y   ←   -sinθ   cosθ   0   ×   y
w
       0   0   1       w

A scale matrix scales a point about the origin:

ax       a   0   0       x
by   ←   0   b   0   ×   y
w       0   0   1       w