Post-multiplication, right-handed coordinate system as in OpenGL®
Fixed function pipeline of OpenGL® 1 and 2 use a post-multiplication right-handed coordinate system.
Axis in matrix
\begin{array}{c} \begin{bmatrix} \color{red} \textrm{X-Axis} & \color{green} \textrm{Y-Axis} & \color{blue} \textrm{Z-Axis} & \textrm{Translate} \\ \color{red} \downarrow & \color{green} \downarrow & \color{blue} \downarrow & \downarrow \\ \color{red} \mathbf{m_{11}} & \color{green} \mathbf{m_{12}} & \color{blue} \mathbf{m_{13}} & \mathbf{m_{14}}\\ \color{red} \mathbf{m_{21}} & \color{green} \mathbf{m_{22}} & \color{blue} \mathbf{m_{23}} & \mathbf{m_{24}}\\ \color{red} \mathbf{m_{31}} & \color{green} \mathbf{m_{32}} & \color{blue} \mathbf{m_{33}} & \mathbf{m_{34}}\\ \color{gray} m_{41} & \color{gray} m_{42} & \color{gray} m_{43} & \color{gray} m_{44}\\ \end{bmatrix} \end{array}
Translation Transformation
\begin{bmatrix} 1 & 0 & 0 & T_x\\ 0 & 1 & 0 & T_y\\ 0 & 0 & 1 & T_z\\ 0 & 0 & 0 & 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
-
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 & -2ad\\ -2ab & 1-2b^2 & -2bc & -2bd\\ -2ac & -2bc & 1-2c^2 & -2cd\\ 0 & 0 & 0 & 1\\ \end{bmatrix}
Shear Transformation
\begin{array}{cccc} \textrm{X - Axis} & \textrm{Y - Axis} & \textrm{Z - Axis} & \textrm{General}\\ \begin{bmatrix} 1 & 0 & 0 & 0\\ H_y & 1 & 0 & 0\\ H_z & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} 1 & H_x & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & H_z & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} 1 & 0 & H_x & 0\\ 0 & 1 & H_y & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} 1 & H_x^y & H_x^z & 0\\ H_y^x & 1 & H_y^z & 0\\ H_z^x & H_z^y & 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 & -\frac{r+l}{r-l}\\ 0 & \frac{2}{t-b} & 0 & -\frac{t+b}{t-b}\\ 0 & 0 & -\frac{1}{f-n} & -\frac{n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{1}{f-n} & -\frac{n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{1}{w} & 0 & 0 & 0\\ 0 & \frac{1}{h} & 0 & 0\\ 0 & 0 & -\frac{1}{2} & \frac{1}{2}\\ 0 & 0 & 0 & 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 & -\frac{r+l}{r-l}\\ 0 & \frac{2}{t-b} & 0 & -\frac{t+b}{t-b}\\ 0 & 0 & -\frac{2}{f-n} & -\frac{f+n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{h} & 0 & 0\\ 0 & 0 & -\frac{2}{f-n} & -\frac{f+n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & 0\\ 0 & \frac{2}{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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & -\frac{f}{f-n} & -\frac{fn}{f-n}\\ 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 & -\frac{f}{f-n} & -\frac{fn}{f-n}\\ 0 & 0 & -1 & 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} & -\frac{fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & -1 & -n\\ 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 & -n\\ 0 & 0 & -1 & 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 & -n\\ 0 & 0 & -1 & 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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & \frac{n}{f-n} & \frac{fn}{f-n}\\ 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 & \frac{n}{f-n} & \frac{fn}{f-n}\\ 0 & 0 & -1 & 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} & \frac{fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & 0 & n\\ 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 & 0 & n\\ 0 & 0 & -1 & 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 & n\\ 0 & 0 & -1 & 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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & -\frac{f+n}{f-n} & -\frac{2fn}{f-n}\\ 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 & -\frac{f+n}{f-n} & -\frac{2fn}{f-n}\\ 0 & 0 & -1 & 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} & -\frac{2fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & -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 & -2n\\ 0 & 0 & -1 & 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 & -2n\\ 0 & 0 & -1 & 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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & \frac{f+n}{f-n} & \frac{2fn}{f-n}\\ 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 & \frac{f+n}{f-n} & \frac{2fn}{f-n}\\ 0 & 0 & -1 & 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} & \frac{2fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r+l}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t+b}{t-b} & 0\\ 0 & 0 & 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 & 2n\\ 0 & 0 & -1 & 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 & 2n\\ 0 & 0 & -1 & 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 & -\frac{r(1+j_x)+l(1-j_x)}{r-l}\\ 0 & \frac{2}{t-b} & 0 & -\frac{t(1+j_y)+b(1-j_y)}{t-b}\\ 0 & 0 & -\frac{1}{f-n} & -\frac{n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & -j_x\\ 0 & \frac{2}{h} & 0 & -j_y\\ 0 & 0 & -\frac{1}{f-n} & -\frac{n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{1}{w} & 0 & 0 & -j_x\\ 0 & \frac{1}{h} & 0 & -j_y\\ 0 & 0 & -\frac{1}{2} & \frac{1}{2}\\ 0 & 0 & 0 & 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 & -\frac{r(1+j_x)+l(1-j_x)}{r-l}\\ 0 & \frac{2}{t-b} & 0 & -\frac{t(1+j_y)+b(1-j_y)}{t-b}\\ 0 & 0 & -\frac{2}{f-n} & -\frac{f+n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & -j_x\\ 0 & \frac{2}{h} & 0 & -j_y\\ 0 & 0 & -\frac{2}{f-n} & -\frac{f+n}{f-n}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} & \begin{bmatrix} \frac{2}{w} & 0 & 0 & -j_x\\ 0 & \frac{2}{h} & 0 & -j_y\\ 0 & 0 & -1 & 0\\ 0 & 0 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & -\frac{f}{f-n} & -\frac{fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & -\frac{f}{f-n} & -\frac{fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & -\frac{f}{f-n} & -\frac{fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & -1 & -n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & -1 & -n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & -1 & -n\\ 0 & 0 & -1 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & \frac{n}{f-n} & \frac{fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & \frac{n}{f-n} & \frac{fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & \frac{n}{f-n} & \frac{fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & 0 & n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & 0 & n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & 0 & n\\ 0 & 0 & -1 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & -\frac{f+n}{f-n} & -\frac{2fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & -\frac{f+n}{f-n} & -\frac{2fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & -\frac{f+n}{f-n} & -\frac{2fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & -1 & -2n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & -1 & -2n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & -1 & -2n\\ 0 & 0 & -1 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & \frac{f+n}{f-n} & \frac{2fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & \frac{f+n}{f-n} & \frac{2fn}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & \frac{f+n}{f-n} & \frac{2fn}{f-n}\\ 0 & 0 & -1 & 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 & \frac{r(1+j_x)+l(1-j_x)}{r-l} & 0\\ 0 & \frac{2n}{t-b} & \frac{t(1+j_y)+b(1-j_y)}{t-b} & 0\\ 0 & 0 & 1 & 2n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \frac{w}{h}\cot(\frac{\alpha}{2}) & 0 & j_x & 0\\ 0 & \cot(\frac{\alpha}{2}) & j_y & 0\\ 0 & 0 & 1 & 2n\\ 0 & 0 & -1 & 0\\ \end{bmatrix} & \begin{bmatrix} \cot(\frac{\beta}{2}) & 0 & j_x & 0\\ 0 & \frac{h}{w}\cot(\frac{\beta}{2}) & j_y & 0\\ 0 & 0 & 1 & 2n\\ 0 & 0 & -1 & 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 & -(\vec{A} \cdot \vec{\textrm{eye}})\\ \vec{B}_x & \vec{B}_y & \vec{B}_z & -(\vec{B} \cdot \vec{\textrm{eye}})\\ \vec{C}_x & \vec{C}_y & \vec{C}_z & -(\vec{C} \cdot \vec{\textrm{eye}})\\ 0 & 0 & 0 & 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 & -(\vec{A} \cdot \vec{\textrm{eye}})\\ \vec{B}_x & \vec{B}_y & \vec{B}_z & -(\vec{B} \cdot \vec{\textrm{eye}})\\ \vec{C}_x & \vec{C}_y & \vec{C}_z & -(\vec{C} \cdot \vec{\textrm{eye}})\\ 0 & 0 & 0 & 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}_x \vec{L}_y & -\vec{P}_x \vec{L}_z & -\vec{P}_x \vec{L}_w \\ -\vec{P}_y \vec{L}_x & k - \vec{P}_y \vec{L}_y & -\vec{P}_y \vec{L}_z & -\vec{P}_y \vec{L}_w \\ -\vec{P}_z \vec{L}_x & -\vec{P}_z \vec{L}_y & k - \vec{P}_z \vec{L}_z & -\vec{P}_z \vec{L}_w \\ -\vec{P}_w \vec{L}_x & -\vec{P}_w \vec{L}_y & -\vec{P}_w \vec{L}_z & k - \vec{P}_w \vec{L}_w \\ \end{bmatrix}