Pre-multiplication, right-handed coordinate system
Axis in matrix
\begin{array}{c} \begin{bmatrix*}[r] \color{red} \textrm{X-Axis} \rightarrow & \color{red} \mathbf{m_{11}} & \color{red} \mathbf{m_{12}} & \color{red} \mathbf{m_{13}} & \color{gray} m_{14}\\ \color{green} \textrm{Y-Axis} \rightarrow & \color{green} \mathbf{m_{21}} & \color{green} \mathbf{m_{22}} & \color{green} \mathbf{m_{23}} & \color{gray} m_{24}\\ \color{blue} \textrm{Z-Axis} \rightarrow & \color{blue} \mathbf{m_{31}} & \color{blue} \mathbf{m_{32}} & \color{blue} \mathbf{m_{33}} & \color{gray} m_{34}\\ \textrm{Translate} \rightarrow & \mathbf{m_{41}} & \mathbf{m_{42}} & \mathbf{m_{43}} & \color{gray} m_{44}\\ \end{bmatrix*} \end{array}
Translation Transformation
\begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ T_x & T_y & T_z & 1\\ \end{bmatrix}
Scale Transformation
\begin{bmatrix} S_x & 0 & 0 & 0\\ 0 & S_y & 0 & 0\\ 0 & 0 & S_z & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix}
Rotation Transformation
-
From Euler Angles
\begin{array}{ccc} \textrm{X - Axis} & \textrm{Y - Axis} & \textrm{Z - Axis} \\ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & \cos(\theta) & \sin(\theta) & 0\\ 0 & -\sin(\theta) & \cos(\theta) & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \cos(\theta) & 0 & -\sin(\theta) & 0\\ 0 & 1 & 0 & 0\\ \sin(\theta) & 0 & \cos(\theta) & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \cos(\theta) & \sin(\theta) & 0 & 0\\ -\sin(\theta) & \cos(\theta) & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \end{array}
-
From Quaternion
Quaternion defined Q : a + b\mathbf{i} + c\mathbf{j} + d\mathbf{k} = (r, \vec{v}) = (Q_w, Q_x, Q_y, Q_z)
\begin{bmatrix} 1 - 2(Q_y^2 + Q_z^2) & 2(Q_xQ_y + Q_zQ_w) & 2(Q_xQ_z - Q_yQ_w) & 0\\ 2(Q_xQ_y - Q_zQ_w) & 1 - 2(Q_x^2 + Q_z^2) & 2(Q_yQ_z + Q_xQ_w) & 0\\ 2(Q_xQ_z + Q_yQ_w) & 2(Q_yQ_z - Q_xQ_w) & 1 - 2(Q_x^2 + Q_y^2) & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix}
-
From Axis Angle
Axis angle defined U : \cos(\theta) + \sin(\theta)(\hat{u}_x, \hat{u}_y, \hat{u}_z)
where : ||\hat{u}|| = 1
\begin{bmatrix} (1-c)\hat{u}_x^2 + c & (1-c)\hat{u}_x\hat{u}_y + s\hat{u}_z & (1-c)\hat{u}_x\hat{u}_z - s\hat{u}_y & 0\\ (1-c)\hat{u}_x\hat{u}_y - s\hat{u}_z & (1-c)\hat{u}_y^2 + c & (1-c)\hat{u}_y\hat{u}_z + s\hat{u}_x & 0\\ (1-c)\hat{u}_x\hat{u}_z + s\hat{u}_y & (1-c)\hat{u}_y\hat{u}_z - s\hat{u}_x & (1-c)\hat{u}_z^2 + c & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix}
Reflection Transformation
-
Axis Plane symmetry
\begin{array}{ccc} \textrm{XY Plane} & \textrm{XZ Plane} & \textrm{YZ Plane}\\ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & -1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} -1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \end{array}
-
Axial symmetry
\begin{array}{ccc} \textrm{X - Axis} & \textrm{Y - Axis} & \textrm{Z - Axis} \\ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & -1 & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} -1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} -1 & 0 & 0 & 0\\ 0 & -1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \end{array}
-
Central symmetry
\begin{bmatrix} -1 & 0 & 0 & 0\\ 0 & -1 & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix}
-
Generic plane symmetry
Plane defined P : ax + by + cz + d = 0
\begin{bmatrix} 1-2a^2 & -2ab & -2ac & 0\\ -2ab & 1-2b^2 & -2bc & 0\\ -2ac & -2bc & 1-2c^2 & 0\\ -2ad & -2bd & -2cd & 1\\ \end{bmatrix}
Shear Transformation
\begin{array}{cccc} \textrm{X - Axis} & \textrm{Y - Axis} & \textrm{Z - Axis} & \textrm{General}\\ \begin{bmatrix} 1 & H_y & H_z & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} 1 & 0 & 0 & 0\\ H_x & 1 & H_z & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ H_x & H_y & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} 1 & H_y^x & H_z^x & 0\\ H_x^y & 1 & H_z^y & 0\\ H_x^z & H_y^z & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \end{array}
Planar Projections Transformation
Orthographic Transformation
l – left coordinate of the orthographic frustum
r – right coordinate of the orthographic frustum
b – bottom coordinate of the orthographic frustum
t – top coordinate of the orthographic frustum
n – distance to the near plane of the orthographic frustum
f – distance to the far plane of the orthographic frustum
w – width of the near plane of the orthographic frustum
h – height of the near plane of the orthographic frustum
-
Clip Space \mathbf{z \in \lbrack 0,1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{General} & \textrm{Symmetric} & \textrm{Symmetric 2D} \\ \begin{bmatrix} \frac{2}{r-l} & 0 & 0 & 0\\ 0 & \frac{2}{t-b} & 0 & 0\\ 0 & 0 & -\frac{1}{f-n} & 0\\ -\frac{r+l}{r-l} & -\frac{t+b}{t-b} & -\frac{n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{1}{f-n} & 0\\ 0 & 0 & -\frac{n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{1}{2} & 0\\ 0 & 0 & \frac{1}{2} & 1\\ \end{bmatrix} \end{array}
-
Clip Space \mathbf{z \in \lbrack -1,1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{General} & \textrm{Symmetric} & \textrm{Symmetric 2D} \\ \begin{bmatrix} \frac{2}{r-l} & 0 & 0 & 0\\ 0 & \frac{2}{t-b} & 0 & 0\\ 0 & 0 & -\frac{2}{f-n} & 0\\ -\frac{r+l}{r-l} & -\frac{t+b}{t-b} & -\frac{f+n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{2}{f-n} & 0\\ 0 & 0 & -\frac{f+n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{1}{w} & 0 & 0 & 0\\ 0 & \frac{1}{h} & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \end{array}
Perspective Transformation
l – left coordinate of the perspective frustum
r – right coordinate of the perspective frustum
b – bottom coordinate of the perspective frustum
t – top coordinate of the perspective frustum
n – distance to the near plane of the perspective frustum
f – distance to the far plane of the perspective frustum
w – width of the near plane of the perspective frustum
h – height of the near plane of the perspective frustum
\alpha – angle between of left and right frustum planes of the perspective frustum
\beta – angle between of top and bottom frustum planes of the perspective frustum
-
Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Clip Space \mathbf{z \in \lbrack 0,1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & -\frac{f}{f-n} & -1\\ 0 & 0 & -\frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & -\frac{f}{f-n} & -1\\ 0 & 0 & -\frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & -\frac{f}{f-n} & -1\\ 0 & 0 & -\frac{fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Clip Space \mathbf{z \in \lbrack 0,1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} \end{array}
-
Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,0 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & \frac{n}{f-n} & -1\\ 0 & 0 & \frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & \frac{n}{f-n} & -1\\ 0 & 0 & \frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & \frac{n}{f-n} & -1\\ 0 & 0 & \frac{fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,0 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} \end{array}
-
Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Clip Space \mathbf{z \in \lbrack -1,1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & -\frac{f+n}{f-n} & -1\\ 0 & 0 & -\frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & -\frac{f+n}{f-n} & -1\\ 0 & 0 & -\frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & -\frac{f+n}{f-n} & -1\\ 0 & 0 & -\frac{2fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Clip Space \mathbf{z \in \lbrack -1,1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} \end{array}
-
Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,-1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & \frac{f+n}{f-n} & -1\\ 0 & 0 & \frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & \frac{f+n}{f-n} & -1\\ 0 & 0 & \frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & \frac{f+n}{f-n} & -1\\ 0 & 0 & \frac{2fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,-1 \rbrack}
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r+l}{r-l} & \frac{t+b}{t-b} & 1 & 2n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ 0 & 0 & 1 & -1\\ 0 & 0 & 2n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & 1 & -1\\ 0 & 0 & 2n & 0\\ \end{bmatrix} \end{array}
Jitter Orthographic Transformation
l – left coordinate of the orthographic frustum
r – right coordinate of the orthographic frustum
b – bottom coordinate of the orthographic frustum
t – top coordinate of the orthographic frustum
n – distance to the near plane of the orthographic frustum
f – distance to the far plane of the orthographic frustum
w – width of the near plane of the orthographic frustum
h – height of the near plane of the orthographic frustum
j_x – jitter in NDC space in the x-direction
j_y – jitter in NDC space in the y-direction
-
Jitter Orthographic Transformation Clip Space \mathbf{z \in \lbrack 0,1 \rbrack}
\begin{array}{ccc} \textrm{General} & \textrm{Symmetric} & \textrm{Symmetric 2D} \\ \begin{bmatrix} \frac{2}{r-l} & 0 & 0 & 0\\ 0 & \frac{2}{t-b} & 0 & 0\\ 0 & 0 & -\frac{1}{f-n} & 0\\ -\frac{r(1+j_x)+l(1-j_x)}{r-l} & -\frac{t(1+j_y)+b(1-j_y)}{t-b} & -\frac{n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{1}{f-n} & 0\\ -j_x & -j_y & -\frac{n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{1}{2} & 0\\ -j_x & -j_y & \frac{1}{2} & 1\\ \end{bmatrix} \end{array}
-
Jitter Orthographic Transformation Clip Space \mathbf{z \in \lbrack -1,1 \rbrack}
\begin{array}{ccc} \textrm{General} & \textrm{Symmetric} & \textrm{Symmetric 2D} \\ \begin{bmatrix} \frac{2}{r-l} & 0 & 0 & 0\\ 0 & \frac{2}{t-b} & 0 & 0\\ 0 & 0 & -\frac{2}{f-n} & 0\\ -\frac{r(1+j_x)+l(1-j_x)}{r-l} & -\frac{t(1+j_y)+b(1-j_y)}{t-b} & -\frac{f+n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{2}{f-n} & 0\\ -j_x & -j_y & -\frac{f+n}{f-n} & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{1}{w} & 0 & 0 & 0\\ 0 & \frac{1}{h} & 0 & 0\\ 0 & 0 & -1 & 0\\ -j_x & -j_y & 0 & 1\\ \end{bmatrix} \end{array}
Jitter Perspective Transformation
l – left coordinate of the perspective frustum
r – right coordinate of the perspective frustum
b – bottom coordinate of the perspective frustum
t – top coordinate of the perspective frustum
n – distance to the near plane of the perspective frustum
f – distance to the far plane of the perspective frustum
w – width of the near plane of the perspective frustum
h – height of the near plane of the perspective frustum
j_x – jitter in NDC space in the x-direction
j_y – jitter in NDC space in the y-direction
\alpha – angle between of left and right frustum planes of the perspective frustum
\beta – angle between of top and bottom frustum planes of the perspective frustum
-
Jitter Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Clip Space \mathbf{z \in \lbrack 0,1 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & -\frac{f}{f-n} & -1\\ 0 & 0 & -\frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & -\frac{f}{f-n} & -1\\ 0 & 0 & -\frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & -\frac{f}{f-n} & -1\\ 0 & 0 & -\frac{fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Jitter Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Clip Space \mathbf{z \in \lbrack 0,1 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} \end{array}
-
Jitter Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,0 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & \frac{n}{f-n} & -1\\ 0 & 0 & \frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & \frac{n}{f-n} & -1\\ 0 & 0 & \frac{fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & \frac{n}{f-n} & -1\\ 0 & 0 & \frac{fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Jitter Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,0 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} \end{array}
-
Jitter Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Clip Space \mathbf{z \in \lbrack -1,1 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & -\frac{f+n}{f-n} & -1\\ 0 & 0 & -\frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & -\frac{f+n}{f-n} & -1\\ 0 & 0 & -\frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & -\frac{f+n}{f-n} & -1\\ 0 & 0 & -\frac{2fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Jitter Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Clip Space \mathbf{z \in \lbrack -1,1 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} \end{array}
-
Jitter Perspective Transformation \mathbf{\lbrack n,f \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,-1 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & \frac{f+n}{f-n} & -1\\ 0 & 0 & \frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & \frac{f+n}{f-n} & -1\\ 0 & 0 & \frac{2fn}{f-n} & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & \frac{f+n}{f-n} & -1\\ 0 & 0 & \frac{2fn}{f-n} & 0\\ \end{bmatrix} \end{array}
-
Jitter Perspective Transformation infinite far plane \mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space \mathbf{z \in \lbrack 1,-1 \rbrack}
\begin{array}{ccc} \textrm{Frustum} & \textrm{Symmetric Vertical FOV} & \textrm{Symmetric Horizontal FOV} \\ \begin{bmatrix} \frac{2n}{r-l} & 0 & 0 & 0\\ 0 & \frac{2n}{t-b} & 0 & 0\\ \frac{r(1+j_x)+l(1-j_x)}{r-l} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 1 & 2n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & 0 & 0\\ 0 & \cot(\frac{\alpha}{2}) & 0 & 0\\ j_x & j_y & 1 & -1\\ 0 & 0 & 2n & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & 0 & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & 1 & -1\\ 0 & 0 & 2n & 0\\ \end{bmatrix} \end{array}
Camera Transformations
-
“Look At” Transformation
at – position of the point at which the camera will be pointing at
eye – position of the camera
up – “Up” direction of the camera
\vec{C} – “Forward” vector
\vec{A} – “Right” vector
\vec{B} – “Up” vector
\vec{C} = \frac{\vec{\textrm{at}} - \vec{\textrm{eye}}}{|\vec{\textrm{at}} - \vec{\textrm{eye}}|} \vec{A} = \vec{\textrm{up}} \times \vec{C} \vec{B} = \vec{C} \times \vec{A}\begin{bmatrix} \vec{A}_x & \vec{A}_y & \vec{A}_z & 0\\ \vec{B}_x & \vec{B}_y & \vec{B}_z & 0\\ \vec{C}_x & \vec{C}_y & \vec{C}_z & 0\\ -(\vec{A} \cdot \vec{\textrm{eye}}) & -(\vec{B} \cdot \vec{\textrm{eye}}) & -(\vec{C} \cdot \vec{\textrm{eye}}) & 1\\ \end{bmatrix}
-
“Look To” Transformation
dir – desired direction of the camera
up – “Up” direction of the camera
\vec{C} – “Forward” vector
\vec{A} – “Right” vector
\vec{B} – “Up” vector
\vec{C} = \vec{\textrm{dir}} \vec{A} = \vec{\textrm{up}} \times \vec{C} \vec{B} = \vec{C} \times \vec{A}\begin{bmatrix} \vec{A}_x & \vec{A}_y & \vec{A}_z & 0\\ \vec{B}_x & \vec{B}_y & \vec{B}_z & 0\\ \vec{C}_x & \vec{C}_y & \vec{C}_z & 0\\ -dot(A, eye) & -dot(B, eye) & -dot(C, eye) & 1\\ \end{bmatrix}
Miscellaneous Matrices
-
Planar Shadow Projection
Plane defined P: Ax + By + Cz + D = 0
Light position L: (L_x, L_y, L_z)
where w = 0 for direction light
w = 1 for point light
\vec{L} = (L_x, L_y, L_x, w) \vec{P} = (A, B, C, D) k = \vec{P} \cdot \vec{L}\begin{bmatrix} k - \vec{P}_x \vec{L}_x & -\vec{P}_y \vec{L}_x & -\vec{P}_z \vec{L}_x & -\vec{P}_d \vec{L}_x \\ -\vec{P}_x \vec{L}_y & k - \vec{P}_y \vec{L}_y & -\vec{P}_z \vec{L}_y & -\vec{P}_d \vec{L}_y \\ -\vec{P}_x \vec{L}_z & -\vec{P}_y \vec{L}_z & k - \vec{P}_z \vec{L}_z & -\vec{P}_d \vec{L}_z \\ -\vec{P}_x \vec{L}_w & -\vec{P}_y \vec{L}_w & -\vec{P}_z \vec{L}_w & k - \vec{P}_d \vec{L}_w \\ \end{bmatrix}