x |
y |
z |
w |
This is the transpose of the row vector [x y z w], so we can also refer to it as [x y z w]T.
We generally "normalize" this vector by scaling it so that w = 1. For example, we would convert [4 6 8 2]T to [2 3 4 1]T. The exception is a point at infinity (ie: a direction vector), in which case w = 0.
x' | a | b | c | d | x | ||
y' | ← | e | f | g | h | × | y |
z' | i | j | k | l | × | z | |
w' | m | n | o | p | w |
The following are convenient primitive matrices:
The identity matrix transforms a point to itself:
x | 1 | 0 | 0 | 0 | x | ||
y | ← | 0 | 1 | 0 | 0 | × | y |
y | 0 | 0 | 1 | 0 | × | z | |
w | 0 | 0 | 0 | 1 | w |
A translation matrix translates the position of a point:
x+a | 1 | 0 | 0 | a | x | ||
y+b | ← | 0 | 1 | 0 | b | × | y |
z+c | 0 | 0 | 1 | c | × | z | |
0 | 0 | 0 | 1 | w |
There are three primitive axes of rotation: X, Y, and Z, respectively:
1 | 0 | 0 | 0 | x | |||
cosθ y - sinθ z | ← | 0 | cosθ | -sinθ | 0 | × | y |
sinθ y + cosθ z | 0 | sinθ | cosθ | 0 | × | z | |
0 | 0 | 0 | 1 | w |
sinθ z + cosθ x | cosθ | 0 | sinθ | 0 | x | ||
← | 0 | 1 | 0 | 0 | × | y | |
cosθ z - sinθ x | -sinθ | 0 | cosθ | 0 | × | z | |
0 | 0 | 0 | 1 | w |
cosθ x - sinθ y | cosθ | -sinθ | 0 | 0 | x | ||
sinθ x + cosθ y | ← | sinθ | cosθ | 0 | 0 | × | y |
0 | 0 | 1 | 0 | × | z | ||
0 | 0 | 0 | 1 | w |
A scale matrix scales a point about the origin:
ax | a | 0 | 0 | 0 | x | ||
by | ← | 0 | b | 0 | 0 | × | y |
cz | 0 | 0 | c | 0 | × | z | |
w | 0 | 0 | 0 | 1 | w |
Perspective in Z:
x/z | x | 1 | 0 | 0 | 0 | x | |||
y/z | ← | y | ← | 0 | 1 | 0 | 0 | × | y |
w/z | w | 0 | 0 | 0 | 1 | × | z | ||
z | 0 | 0 | 1 | 0 | w |