Pre-multiplication, right-handed coordinate system

Axis in matrix

[X-Axism11m12m13m14Y-Axism21m22m23m24Z-Axism31m32m33m34Translatem41m42m43m44] \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

[100001000010TxTyTz1] \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

[Sx0000Sy0000Sz00001] \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

X - AxisY - AxisZ - Axis[10000cos(θ)sin(θ)00sin(θ)cos(θ)00001][cos(θ)0sin(θ)00100sin(θ)0cos(θ)00001][cos(θ)sin(θ)00sin(θ)cos(θ)0000100001] \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+bi+cj+dk=(r,v)=(Qw,Qx,Qy,Qz)Q : a + b\mathbf{i} + c\mathbf{j} + d\mathbf{k} = (r, \vec{v}) = (Q_w, Q_x, Q_y, Q_z)

[12(Qy2+Qz2)2(QxQy+QzQw)2(QxQzQyQw)02(QxQyQzQw)12(Qx2+Qz2)2(QyQz+QxQw)02(QxQz+QyQw)2(QyQzQxQw)12(Qx2+Qy2)00001] \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(θ)+sin(θ)(u^x,u^y,u^z)U : \cos(\theta) + \sin(\theta)(\hat{u}_x, \hat{u}_y, \hat{u}_z)

where :u^=1: ||\hat{u}|| = 1

[(1c)u^x2+c(1c)u^xu^y+su^z(1c)u^xu^zsu^y0(1c)u^xu^ysu^z(1c)u^y2+c(1c)u^yu^z+su^x0(1c)u^xu^z+su^y(1c)u^yu^zsu^x(1c)u^z2+c00001] \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

XY PlaneXZ PlaneYZ Plane[1000010000100001][1000010000100001][1000010000100001] \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

X - AxisY - AxisZ - Axis[1000010000100001][1000010000100001][1000010000100001] \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

[1000010000100001] \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=0P : ax + by + cz + d = 0

[12a22ab2ac02ab12b22bc02ac2bc12c202ad2bd2cd1] \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

X - AxisY - AxisZ - AxisGeneral[1HyHz0010000100001][1000Hx1Hz000100001][10000100HxHy100001][1HyxHzx0Hxy1Hzy0HxzHyz100001] \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

ll – left coordinate of the orthographic frustum

rr – right coordinate of the orthographic frustum

bb – bottom coordinate of the orthographic frustum

tt – top coordinate of the orthographic frustum

nn – distance to the near plane of the orthographic frustum

ff – distance to the far plane of the orthographic frustum

ww – width of the near plane of the orthographic frustum

hh – height of the near plane of the orthographic frustum

  • Clip Space z[0,1]\mathbf{z \in \lbrack 0,1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

GeneralSymmetricSymmetric 2D[2rl00002tb00001fn0r+lrlt+btbnfn1][2w00002h00001fn000nfn1][2w00002h000012000121] \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 z[1,1]\mathbf{z \in \lbrack -1,1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

GeneralSymmetricSymmetric 2D[2rl00002tb00002fn0r+lrlt+btbf+nfn1][2w00002h00002fn000f+nfn1][1w00001h0000100001] \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

ll – left coordinate of the perspective frustum

rr – right coordinate of the perspective frustum

bb – bottom coordinate of the perspective frustum

tt – top coordinate of the perspective frustum

nn – distance to the near plane of the perspective frustum

ff – distance to the far plane of the perspective frustum

ww – width of the near plane of the perspective frustum

hh – 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 [n,f]\mathbf{\lbrack n,f \rbrack}, Clip Space z[0,1]\mathbf{z \in \lbrack 0,1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btbffn100fnfn0][hwcot(α2)0000cot(α2)0000ffn100fnfn0][cot(β2)0000whcot(β2)0000ffn100fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Clip Space z[0,1]\mathbf{z \in \lbrack 0,1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btb1100n0][hwcot(α2)0000cot(α2)00001100n0][cot(β2)0000whcot(β2)00001100n0] \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{h}{w}\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{w}{h}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} \end{array}

  • Perspective Transformation [n,f]\mathbf{\lbrack n,f \rbrack}, Reversed Clip Space z[1,0]\mathbf{z \in \lbrack 1,0 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btbnfn100fnfn0][hwcot(α2)0000cot(α2)0000nfn100fnfn0][cot(β2)0000whcot(β2)0000nfn100fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space z[1,0]\mathbf{z \in \lbrack 1,0 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btb0100n0][hwcot(α2)0000cot(α2)00000100n0][cot(β2)0000whcot(β2)00000100n0] \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{h}{w}\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{w}{h}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} \end{array}

  • Perspective Transformation [n,f]\mathbf{\lbrack n,f \rbrack}, Clip Space z[1,1]\mathbf{z \in \lbrack -1,1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btbf+nfn1002fnfn0][hwcot(α2)0000cot(α2)0000f+nfn1002fnfn0][cot(β2)0000whcot(β2)0000f+nfn1002fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Clip Space z[1,1]\mathbf{z \in \lbrack -1,1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btb11002n0][hwcot(α2)0000cot(α2)000011002n0][cot(β2)0000whcot(β2)000011002n0] \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{h}{w}\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{w}{h}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} \end{array}

  • Perspective Transformation [n,f]\mathbf{\lbrack n,f \rbrack}, Reversed Clip Space z[1,1]\mathbf{z \in \lbrack 1,-1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btbf+nfn1002fnfn0][hwcot(α2)0000cot(α2)0000f+nfn1002fnfn0][cot(β2)0000whcot(β2)0000f+nfn1002fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space z[1,1]\mathbf{z \in \lbrack 1,-1 \rbrack}

View Space

Left-handed NDC Space

Right-handed NDC Space

image

image

image

image

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r+lrlt+btb12n0010][hwcot(α2)0000cot(α2)000011002n0][cot(β2)0000whcot(β2)000011002n0] \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{h}{w}\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{w}{h}\cot(\frac{\beta}{2}) & 0 & 0\\ 0 & 0 & 1 & -1\\ 0 & 0 & 2n & 0\\ \end{bmatrix} \end{array}

Jitter Orthographic Transformation

ll – left coordinate of the orthographic frustum

rr – right coordinate of the orthographic frustum

bb – bottom coordinate of the orthographic frustum

tt – top coordinate of the orthographic frustum

nn – distance to the near plane of the orthographic frustum

ff – distance to the far plane of the orthographic frustum

ww – width of the near plane of the orthographic frustum

hh – height of the near plane of the orthographic frustum

jxj_x – jitter in NDC space in the x-direction

jyj_y – jitter in NDC space in the y-direction

  • Jitter Orthographic Transformation Clip Space z[0,1]\mathbf{z \in \lbrack 0,1 \rbrack}

GeneralSymmetricSymmetric 2D[2rl00002tb00001fn0r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tbnfn1][2w00002h00001fn0jxjynfn1][2w00002h0000120jxjy121] \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 z[1,1]\mathbf{z \in \lbrack -1,1 \rbrack}

GeneralSymmetricSymmetric 2D[2rl00002tb00002fn0r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tbf+nfn1][2w00002h00002fn0jxjyf+nfn1][1w00001h000010jxjy01] \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

ll – left coordinate of the perspective frustum

rr – right coordinate of the perspective frustum

bb – bottom coordinate of the perspective frustum

tt – top coordinate of the perspective frustum

nn – distance to the near plane of the perspective frustum

ff – distance to the far plane of the perspective frustum

ww – width of the near plane of the perspective frustum

hh – height of the near plane of the perspective frustum

jxj_x – jitter in NDC space in the x-direction

jyj_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 [n,f]\mathbf{\lbrack n,f \rbrack}, Clip Space z[0,1]\mathbf{z \in \lbrack 0,1 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tbffn100fnfn0][hwcot(α2)0000cot(α2)00jxjyffn100fnfn0][cot(β2)0000whcot(β2)00jxjyffn100fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Clip Space z[0,1]\mathbf{z \in \lbrack 0,1 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tb1100n0][hwcot(α2)0000cot(α2)00jxjy1100n0][cot(β2)0000whcot(β2)00jxjy1100n0] \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{h}{w}\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{w}{h}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & -1 & -1\\ 0 & 0 & -n & 0\\ \end{bmatrix} \end{array}

  • Jitter Perspective Transformation [n,f]\mathbf{\lbrack n,f \rbrack}, Reversed Clip Space z[1,0]\mathbf{z \in \lbrack 1,0 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tbnfn100fnfn0][hwcot(α2)0000cot(α2)00jxjynfn100fnfn0][cot(β2)0000whcot(β2)00jxjynfn100fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space z[1,0]\mathbf{z \in \lbrack 1,0 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tb0100n0][hwcot(α2)0000cot(α2)00jxjy0100n0][cot(β2)0000whcot(β2)00jxjy0100n0] \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{h}{w}\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{w}{h}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & 0 & -1\\ 0 & 0 & n & 0\\ \end{bmatrix} \end{array}

  • Jitter Perspective Transformation [n,f]\mathbf{\lbrack n,f \rbrack}, Clip Space z[1,1]\mathbf{z \in \lbrack -1,1 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tbf+nfn1002fnfn0][hwcot(α2)0000cot(α2)00jxjyf+nfn1002fnfn0][cot(β2)0000whcot(β2)00jxjyf+nfn1002fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Clip Space z[1,1]\mathbf{z \in \lbrack -1,1 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tb11002n0][hwcot(α2)0000cot(α2)00jxjy11002n0][cot(β2)0000whcot(β2)00jxjy11002n0] \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{h}{w}\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{w}{h}\cot(\frac{\beta}{2}) & 0 & 0\\ j_x & j_y & -1 & -1\\ 0 & 0 & -2n & 0\\ \end{bmatrix} \end{array}

  • Jitter Perspective Transformation [n,f]\mathbf{\lbrack n,f \rbrack}, Reversed Clip Space z[1,1]\mathbf{z \in \lbrack 1,-1 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tbf+nfn1002fnfn0][hwcot(α2)0000cot(α2)00jxjyf+nfn1002fnfn0][cot(β2)0000whcot(β2)00jxjyf+nfn1002fnfn0] \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{h}{w}\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{w}{h}\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 [n,]\mathbf{\lbrack n,\infty \rbrack}, Reversed Clip Space z[1,1]\mathbf{z \in \lbrack 1,-1 \rbrack}

FrustumSymmetric Vertical FOVSymmetric Horizontal FOV[2nrl00002ntb00r(1+jx)+l(1jx)rlt(1+jy)+b(1jy)tb12n0010][hwcot(α2)0000cot(α2)00jxjy11002n0][cot(β2)0000whcot(β2)00jxjy11002n0] \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{h}{w}\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{w}{h}\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

C\vec{C}“Forward” vector

A\vec{A}“Right” vector

B\vec{B}“Up” vector

C=ateyeateye\vec{C} = \frac{\vec{\textrm{at}} - \vec{\textrm{eye}}}{|\vec{\textrm{at}} - \vec{\textrm{eye}}|} A=up×C\vec{A} = \vec{\textrm{up}} \times \vec{C} B=C×A\vec{B} = \vec{C} \times \vec{A}

[AxAyAz0BxByBz0CxCyCz0(Aeye)(Beye)(Ceye)1] \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

C\vec{C}“Forward” vector

A\vec{A}“Right” vector

B\vec{B}“Up” vector

C=dir\vec{C} = \vec{\textrm{dir}} A=up×C\vec{A} = \vec{\textrm{up}} \times \vec{C} B=C×A\vec{B} = \vec{C} \times \vec{A}

[AxAyAz0BxByBz0CxCyCz0dot(A,eye)dot(B,eye)dot(C,eye)1] \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=0P: Ax + By + Cz + D = 0

Light position L:(Lx,Ly,Lz)L: (L_x, L_y, L_z)

where w=0w = 0 for direction light

w=1w = 1 for point light

L=(Lx,Ly,Lx,w)\vec{L} = (L_x, L_y, L_x, w) P=(A,B,C,D)\vec{P} = (A, B, C, D) k=PLk = \vec{P} \cdot \vec{L}

[kPxLxPyLxPzLxPdLxPxLykPyLyPzLyPdLyPxLzPyLzkPzLzPdLzPxLwPyLwPzLwkPdLw] \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}