0% found this document useful (0 votes)
3K views1 page

Maths Cheat Sheet

- Matrix multiplication is done by multiplying the rows of the first matrix with the columns of the second matrix. - Vectors can be added by completing the triangle formed by their components. - Translation, scaling, and rotation transformations are represented by matrices. - Unit vectors have a length of 1 and represent direction. - The dot product of vectors returns a scalar value that can be used to calculate the angle between vectors. - The cross product of vectors produces a vector perpendicular to the plane of the two original vectors.

Uploaded by

s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views1 page

Maths Cheat Sheet

- Matrix multiplication is done by multiplying the rows of the first matrix with the columns of the second matrix. - Vectors can be added by completing the triangle formed by their components. - Translation, scaling, and rotation transformations are represented by matrices. - Unit vectors have a length of 1 and represent direction. - The dot product of vectors returns a scalar value that can be used to calculate the angle between vectors. - The cross product of vectors produces a vector perpendicular to the plane of the two original vectors.

Uploaded by

s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

3d Maths Cheat Sheet

Vectors

Matrix * Matrix
Each cell (row, col) in AB is:
P
n

Column-Order Homogeneous Matrix

A(row, 1) B(1, col) + + A(row, n) B(n, col)


Wherehn is dimensionality
ih
iof matrix.
h
i
a b
e f
ae + bg af + bh
AB =
=
c d
g h
ce + dg cf + dh
i=1

Vector Addition
The sum of 2 vectors completes the triangle.

Translation, Scaling, and Rotation

1
0
0
0

also a = c b and b = c a

Unit Vectors - Normalised Vectors


Used to represent a direction or normal. Length of 1.
~
= A
A
~
||A||

~ is the length or magnitude of A.


~
Where ||A||

Dot Product of 2 Vectors


Can be used
Pn to get the angle between 2 vectors.
~B
~ =
A
A B = A1 B1 + A2 B2 + + An Bn
i=1 i i

B)

The dot product returns a single scalar value. = arccos(A


= arccos(

~ B
~
A
~
~ )
||A||||
B||

Where arccos is inverse cosine cos1 .

Cross Product of 2 Vectors


Produces a vector perpendicular to the plane containing the 2
vectors.

(rows of A with columns of B)

Matrix Determinant
For a 2x2 or 3x3 matrix use the Rule of Sarrus; add products of
top-left to bottom-right diagonals, subtract products of opposite
diagonals.
#
"
a b c
d e f
Its determinant |M | is:
M =
g h i
|M | = aei + bf g + cdh ceg bdi af h
For 4x4 use Laplace Expansion; each top-row value * the 3x3 matrix
made of all other rows and columns:
|M | = aM1 bM2 + cM3 dM4
See http://www.euclideanspace.com/maths/algebra/matrix/
functions/determinant/fourD/index.htm

Matrix Transpose
Flip matrix over its main diagonal. In special case of orthonormal
xyz matrix then inverse is the transpose. Can use to switch
between
" row-major
# and column-major
"
# matrices.
a b c
a d g
d e f
b e h
M =
MT =
g h i
c f i

"

"

"

a1
b1
a2 b3 a3 b2
a2
b2
a3 b1 a1 b3

=
a3
b3
a1 b2 a2 b1
To compute surface normals from 2 edges:
N = normalize (cross (A, B));

Matrices
Identity Matrix
All 0,"except the top-left
to bottom-right diagonal.
#
1 0 0
0 1 0
I3 =
0 0 1
if AB = I then A is the inverse of B and vice versa.

Matrix
* Vector
"
#" #
a
d
g

b
e
h

c
f
i

x
y
z

"
=

ax + by + cz
dx + ey + f z
gx + hy + iz

Commonly
used in OpenGLmaths
libraries

Vx
Xx Yx Zx Tx
Xy Yy Zy Ty Vy
v0 =
Vz
Xz Yz Zz Tz
1
0
0
0
1

Matrix Inverse
Use an inverse matrix to reverse its transformation, or to
transform relative to another object.
M M 1 = I Where I is the identity matrix.
If the determinant of a matrix is 0, then there is no inverse. The
inverse can be found by multiplying the determinant with a large
matrix of cofactors. For the long formula see
http://www.cg.info.hiroshima-cu.ac.jp/~miyazaki/
knowledge/teche23.html
Use the transpose of an inverse model matrix to transform
normals: n0 = n(M 1 )T

Homogeneous Matrices
Row-Order Homogeneous Matrix
Commonly used in Direct3D
maths libraries
Xx Xy Xz 0

 Yx Y y Yz 0
0

v = Vx Vy Vz 1
Zx Zy Zz 0
Tx
Ty
Tz 1

0 0
1 0
column order T =
0 1
0 0

1
0
0
0 cos() sin()
Rx =
0 sin()
cos()
0
0
0

cos()
0 sin()
0
1
0
Ry =
sin() 0 cos()
0
0
0

cos() sin() 0
sin()
cos()
0
Rz =
0
0
1
0
0
0

View Matrix

Sx
0
Tx
0
Sy
Ty
S=
0
0
Tz
0
0
1

0
0
(column-order)
0
1

0
0
(column-order)
0
1

0
0
(column-order)
0
1

0
0
Sz
0

0
0
0
1

Rx
Ry
Rz
Px
Ux
Uy
Uz
Py

(column-order)
V =
Fx Fy Fz Pz
0
0
0
1
Where U is a vector pointing up, F forward, and P is world position
of camera.

1 0
0
0
0 0 1 0
Birds-eye view V =
0 1
0
0
0 0
0
1

Projection Matrix

Sx
0
0
0
0
Sy
0
0
P =
(column-order)
0
0
Sz Pz
0
0
1
0
Sx = (2 near)/(range aspect + range aspect)
Sy = near/range
Sz = (f ar + near)/(f ar near)
Pz = (2 f ar near)/(f ar near)
range = tan(f ov/2) near
revision 4. 5 Oct 2012
Dr Anton Gerdelan, [email protected], Trinity College Dublin, Ireland.
LATEX template from http://www.stdout.org/winston/latex/
Thanks Micha
el, Amoss, and Veronica!

You might also like