Pre-multiplication, right-handed coordinate system
Axis in matrix
⎣⎡X-Axis→Y-Axis→Z-Axis→Translate→m11m21m31m41m12m22m32m42m13m23m33m43m14m24m34m44⎦⎤
Translation Transformation
⎣⎡100Tx010Ty001Tz0001⎦⎤
Scale Transformation
⎣⎡Sx0000Sy0000Sz00001⎦⎤
Rotation Transformation
-
From Euler Angles
X - Axis⎣⎡10000cos(θ)−sin(θ)00sin(θ)cos(θ)00001⎦⎤Y - Axis⎣⎡cos(θ)0sin(θ)00100−sin(θ)0cos(θ)00001⎦⎤Z - Axis⎣⎡cos(θ)−sin(θ)00sin(θ)cos(θ)0000100001⎦⎤
-
From Quaternion
Quaternion defined Q:a+bi+cj+dk=(r,v)=(Qw,Qx,Qy,Qz)
⎣⎡1−2(Qy2+Qz2)2(QxQy−QzQw)2(QxQz+QyQw)02(QxQy+QzQw)1−2(Qx2+Qz2)2(QyQz−QxQw)02(QxQz−QyQw)2(QyQz+QxQw)1−2(Qx2+Qy2)00001⎦⎤
-
From Axis Angle
Axis angle defined U:cos(θ)+sin(θ)(u^x,u^y,u^z)
where :∣∣u^∣∣=1
⎣⎡(1−c)u^x2+c(1−c)u^xu^y−su^z(1−c)u^xu^z+su^y0(1−c)u^xu^y+su^z(1−c)u^y2+c(1−c)u^yu^z−su^x0(1−c)u^xu^z−su^y(1−c)u^yu^z+su^x(1−c)u^z2+c00001⎦⎤
Reflection Transformation
-
Axis Plane symmetry
XY Plane⎣⎡1000010000−100001⎦⎤XZ Plane⎣⎡10000−10000100001⎦⎤YZ Plane⎣⎡−1000010000100001⎦⎤
-
Axial symmetry
X - Axis⎣⎡10000−10000−100001⎦⎤Y - Axis⎣⎡−1000010000−100001⎦⎤Z - Axis⎣⎡−10000−10000100001⎦⎤
-
Central symmetry
⎣⎡−10000−10000−100001⎦⎤
-
Generic plane symmetry
Plane defined P:ax+by+cz+d=0
⎣⎡1−2a2−2ab−2ac−2ad−2ab1−2b2−2bc−2bd−2ac−2bc1−2c2−2cd0001⎦⎤
Shear Transformation
X - Axis⎣⎡1000Hy100Hz0100001⎦⎤Y - Axis⎣⎡1Hx0001000Hz100001⎦⎤Z - Axis⎣⎡10Hx001Hy000100001⎦⎤General⎣⎡1HxyHxz0Hyx1Hyz0HzxHzy100001⎦⎤
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 z∈[0,1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
General⎣⎡r−l200−r−lr+l0t−b20−t−bt+b00−f−n1−f−nn0001⎦⎤Symmetric⎣⎡w20000h20000−f−n1−f−nn0001⎦⎤Symmetric 2D⎣⎡w20000h20000−21210001⎦⎤
-
Clip Space z∈[−1,1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
General⎣⎡r−l200−r−lr+l0t−b20−t−bt+b00−f−n2−f−nf+n0001⎦⎤Symmetric⎣⎡w20000h20000−f−n2−f−nf+n0001⎦⎤Symmetric 2D⎣⎡w10000h10000−100001⎦⎤
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
α – angle between of left and right frustum planes of the perspective frustum
β – angle between of top and bottom frustum planes of the perspective frustum
-
Perspective Transformation [n,f], Clip Space z∈[0,1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b000−f−nf−f−nfn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)0000−f−nf−f−nfn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)0000−f−nf−f−nfn00−10⎦⎤
-
Perspective Transformation infinite far plane [n,∞], Clip Space z∈[0,1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b000−1−n00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)0000−1−n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)0000−1−n00−10⎦⎤
-
Perspective Transformation [n,f], Reversed Clip Space z∈[1,0]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b000f−nnf−nfn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)0000f−nnf−nfn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)0000f−nnf−nfn00−10⎦⎤
-
Perspective Transformation infinite far plane [n,∞], Reversed Clip Space z∈[1,0]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b0000n00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)00000n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)00000n00−10⎦⎤
-
Perspective Transformation [n,f], Clip Space z∈[−1,1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b000−f−nf+n−f−n2fn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)0000−f−nf+n−f−n2fn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)0000−f−nf+n−f−n2fn00−10⎦⎤
-
Perspective Transformation infinite far plane [n,∞], Clip Space z∈[−1,1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b000−1−2n00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)0000−1−2n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)0000−1−2n00−10⎦⎤
-
Perspective Transformation [n,f], Reversed Clip Space z∈[1,−1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b000f−nf+nf−n2fn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)0000f−nf+nf−n2fn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)0000f−nf+nf−n2fn00−10⎦⎤
-
Perspective Transformation infinite far plane [n,∞], Reversed Clip Space z∈[1,−1]
View Space |
Left-handed NDC Space |
Right-handed NDC Space |
|
---|---|---|---|
|
|
|
|
Frustum⎣⎡r−l2n0r−lr+l00t−b2nt−bt+b0001−1002n0⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0000cot(2α)000012n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0000hwcot(2β)000012n00−10⎦⎤
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
jx – jitter in NDC space in the x-direction
jy – jitter in NDC space in the y-direction
-
Jitter Orthographic Transformation Clip Space z∈[0,1]
General⎣⎡r−l200−r−lr(1+jx)+l(1−jx)0t−b20−t−bt(1+jy)+b(1−jy)00−f−n1−f−nn0001⎦⎤Symmetric⎣⎡w200−jx0h20−jy00−f−n1−f−nn0001⎦⎤Symmetric 2D⎣⎡w200−jx0h20−jy00−21210001⎦⎤
-
Jitter Orthographic Transformation Clip Space z∈[−1,1]
General⎣⎡r−l200−r−lr(1+jx)+l(1−jx)0t−b20−t−bt(1+jy)+b(1−jy)00−f−n2−f−nf+n0001⎦⎤Symmetric⎣⎡w200−jx0h20−jy00−f−n2−f−nf+n0001⎦⎤Symmetric 2D⎣⎡w100−jx0h10−jy00−100001⎦⎤
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
jx – jitter in NDC space in the x-direction
jy – jitter in NDC space in the y-direction
α – angle between of left and right frustum planes of the perspective frustum
β – angle between of top and bottom frustum planes of the perspective frustum
-
Jitter Perspective Transformation [n,f], Clip Space z∈[0,1]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)000−f−nf−f−nfn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy000−f−nf−f−nfn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy000−f−nf−f−nfn00−10⎦⎤
-
Jitter Perspective Transformation infinite far plane [n,∞], Clip Space z∈[0,1]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)000−1−n00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy000−1−n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy000−1−n00−10⎦⎤
-
Jitter Perspective Transformation [n,f], Reversed Clip Space z∈[1,0]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)000f−nnf−nfn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy000f−nnf−nfn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy000f−nnf−nfn00−10⎦⎤
-
Jitter Perspective Transformation infinite far plane [n,∞], Reversed Clip Space z∈[1,0]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)0000n00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy0000n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy0000n00−10⎦⎤
-
Jitter Perspective Transformation [n,f], Clip Space z∈[−1,1]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)000−f−nf+n−f−n2fn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy000−f−nf+n−f−n2fn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy000−f−nf+n−f−n2fn00−10⎦⎤
-
Jitter Perspective Transformation infinite far plane [n,∞], Clip Space z∈[−1,1]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)000−1−2n00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy000−1−2n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy000−1−2n00−10⎦⎤
-
Jitter Perspective Transformation [n,f], Reversed Clip Space z∈[1,−1]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)000f−nf+nf−n2fn00−10⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy000f−nf+nf−n2fn00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy000f−nf+nf−n2fn00−10⎦⎤
-
Jitter Perspective Transformation infinite far plane [n,∞], Reversed Clip Space z∈[1,−1]
Frustum⎣⎡r−l2n0r−lr(1+jx)+l(1−jx)00t−b2nt−bt(1+jy)+b(1−jy)0001−1002n0⎦⎤Symmetric Vertical FOV⎣⎡whcot(2α)0jx00cot(2α)jy00012n00−10⎦⎤Symmetric Horizontal FOV⎣⎡cot(2β)0jx00hwcot(2β)jy00012n00−10⎦⎤
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 – “Forward” vector
A – “Right” vector
B – “Up” vector
C=∣at−eye∣at−eye A=up×C B=C×A⎣⎡AxBxCx−(A⋅eye)AyByCy−(B⋅eye)AzBzCz−(C⋅eye)0001⎦⎤
-
“Look To” Transformation
dir – desired direction of the camera
up – “Up” direction of the camera
C – “Forward” vector
A – “Right” vector
B – “Up” vector
C=dir A=up×C B=C×A⎣⎡AxBxCx−dot(A,eye)AyByCy−dot(B,eye)AzBzCz−dot(C,eye)0001⎦⎤
Miscellaneous Matrices
-
Planar Shadow Projection
Plane defined P:Ax+By+Cz+D=0
Light position L:(Lx,Ly,Lz)
where w=0 for direction light
w=1 for point light
L=(Lx,Ly,Lx,w) P=(A,B,C,D) k=P⋅L⎣⎡k−PxLx−PxLy−PxLz−PxLw−PyLxk−PyLy−PyLz−PyLw−PzLx−PzLyk−PzLz−PzLw−PdLx−PdLy−PdLzk−PdLw⎦⎤