This method multiplies a matrix and a vector [x, y, z] and returns the resulting vector:
*[(a11 x) + (a12 y) + (a13 z), (a21 x) + (a22 y) + (a23 z), (a31 x) + (a32 y) + (a33 z)]**
Multiplication (Mat3f * float)
This method multiplies a matrix and a scalar (s) and returns the resulting matrix:
*[(a11 s) , (a21 s), (a31 s), (a12 s), (a22 s), (a32 s), (a13 s), (a23 s), (a33 s)]**
Determinant
This method calculates the determinant of a matrix and returns its value (float):
*(a11 det(A11)) - (a21 det(A21)) + (a31 det(A31))**
[det(Aij) is the 2x2 matrix determinant of matrix A minus the ith row and jth column]
Adjoint
This method will return the adjoint matrix:
[det(A11), -det(A12), det(A13), -det(A21), det(A22), -det(A23), det(A31), -det(A32), det(A33)]
Inverse
This method calculates the inverse of a matrix and returns the inverted matrix:
*(1 / det(A)) adj(A)**
Translation Matrix
This method returns the translation matrix for 2 given values (tx, ty):
[1, 0, tx, 0, 1, ty, 0, 0, 1]
Rotation Matrix
This method returns the rotation matrix for a given angle(θ):
[cos(θ), -sin(θ), 0, sin(θ), cos(θ), 0, 0, 0, 1]
Scale Matrix
This method returns the scale matrix for 2 given scaling values (float sx, sy):
[sx, 0, 0, 0, sy, 0, 0, 0, 1]
This method multiplies a matrix and a vector [x, y, z, w] and returns the resulting vector:
[(a11 x) + (a12 y) + (a13 z) + (a14 w), (a21 x) + (a22 y) + (a23 z) + (a24 w), (a31 x) + (a32 y) + (a33 z) + (a34 w), (a41 x) + (a42 y) + (a43 z) + (a44 w)]
Multiplication (Mat4f * float)
This method multiplies a matrix and a scalar (s) and returns the resulting matrix:
[(a11 s) , (a21 s), (a31 s), (a41 s), (a12 s), (a22 s), (a32 s), (a42 s), (a13 s), (a23 s), (a33 s), (a43 s), (a14 s), (a24 s), (a34 s), (a44 s)]
Determinant
This method calculates the determinant of a matrix and returns its value (float):
(a11 det(A11)) - (a21 det(A21)) + (a31 det(A31) - (a41 det(A41))[det(Aij) is the 3x3 matrix determinant of matrix A minus the ith row and jth column]
Adjoint
This method will return the adjoint matrix:
[det(A11), -det(A12), det(A13), -det(A14), -det(A21), det(A22), -det(A23), det(A24), det(A31), -det(A32), det(A33), -det(A34),
-det(A41), det(A42), -det(A43), det(A44)]
Inverse
This method calculates the inverse of a matrix and returns the inverted matrix:
*(1 / det(A)) adj(A)**
Translation Matrix
This method returns the translation matrix for 2 given values (float tx, ty, tz):
[1, 0, 0, tx, 0, 1, 0, ty, 0, 0, 1, tz, 0, 0, 0, 1]
Rotation Matrix
This method returns the rotation matrix for a given angle (θ) and axis (x, y or z):
Rx = [0, cos(θ),-sin(θ), 0, 0,sin(θ), cos(θ), 0, 1, 0, 0, 0, 0, 0, 0, 1]
Ry = [-sin(θ), 0, cos(θ), 0, cos(θ), 0, sin(θ), 0, 0, 1, 0, 0, 0, 0, 0, 1]
Rz = [cos(θ), -sin(θ), 0, 0, sin(θ), cos(θ), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
Scale Matrix
This method returns the scale matrix for 2 given scaling values (float sx, sy, sz):
[sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1]
Introduction
We have been asked to work on 2x2, 3x3 and 4x4 matrices for the GPR5204 class. For this task, we will use column-based matrices.
2x2 Matrix
Addition
This method adds 2 matrices and returns the resulting matrix: [(a11 + b11), (a21 + b21), (a12 + b12), (a22 + b22)].
Substraction
This method substract 2 matrices and returns the resulting matrix: [(a11 - b11), (a21 - b21), (a12 - b12), (a22 - b22)].
Multiplication (Mat2f * Mat2f)
This method multiplies 2 matrices and returns the resulting matrix (will use loops to calculate the matrix): [(a11 b11) + (a12 b21) , (a21 b11) + (a22 b21), (a11 b12) + (a12 b22), (a21 b12) + (a22 b22)]
Multiplication (Mat2f * Vec2f)
This method multiplies a matrix and a vector [x, y] and returns the resulting vector: [(a11 x) + (a12 y) , (a21 x) + (a22 y)]
Multiplication (Mat2f * float)
This method multiplies a matrix and a scalar (s) and returns the resulting matrix: [(a11 s) , (a21 s), (a12 s), (a22 s)]
Determinant
This method calculates the determinant of a matrix and returns its value (float): (a11 a22) - (a12 a21)
Inverse
This method calculates the inverse of a matrix and returns the inverted matrix: *(1 / det(A)) [a22, -a12, -a21, a11]**
3x3 Matrix
Addition
This method adds 2 matrices and returns the resulting matrix: [(a11 + b11), (a21 + b21), (a31 + b31), (a12 + b12), (a22 + b22), (a32 + b32), (a13 + b13), (a23 + b23), (a33 + b33)].
Substraction
This method substract 2 matrices and returns the resulting matrix: [(a11 - b11), (a21 - b21), (a31 - b31), (a12 - b12), (a22 - b22), (a32 - b32), (a13 - b13), (a23 - b23), (a33 - b33)].
Multiplication (Mat3f * Mat3f)
This method multiplies 2 matrices and returns the resulting matrix(will use loops to calculate the matrix): *[(a11 b11) + (a12 b21) + (a13 b31) , (a21 b11) + (a22 b21) + (a23 b31), (a31 b11) + (a32 b21) + (a33 b31), (a11 b12) + (a12 b22) + (a13 b32), (a21 b12) + (a22 b22) + (a23 b32), (a31 b12) + (a32 b22) + (a33 b32), (a11 b13) + (a12 b23) + (a13 b33), (a21 b13) + (a22 b23) + (a23 b33), (a31 b13) + (a32 b23) + (a33 b33)]**
Multiplication (Mat3f * Vec3f)
This method multiplies a matrix and a vector [x, y, z] and returns the resulting vector: *[(a11 x) + (a12 y) + (a13 z), (a21 x) + (a22 y) + (a23 z), (a31 x) + (a32 y) + (a33 z)]**
Multiplication (Mat3f * float)
This method multiplies a matrix and a scalar (s) and returns the resulting matrix: *[(a11 s) , (a21 s), (a31 s), (a12 s), (a22 s), (a32 s), (a13 s), (a23 s), (a33 s)]**
Determinant
This method calculates the determinant of a matrix and returns its value (float): *(a11 det(A11)) - (a21 det(A21)) + (a31 det(A31))** [det(Aij) is the 2x2 matrix determinant of matrix A minus the ith row and jth column]
Adjoint
This method will return the adjoint matrix: [det(A11), -det(A12), det(A13), -det(A21), det(A22), -det(A23), det(A31), -det(A32), det(A33)]
Inverse
This method calculates the inverse of a matrix and returns the inverted matrix: *(1 / det(A)) adj(A)**
Translation Matrix
This method returns the translation matrix for 2 given values (tx, ty): [1, 0, tx, 0, 1, ty, 0, 0, 1]
Rotation Matrix
This method returns the rotation matrix for a given angle(θ): [cos(θ), -sin(θ), 0, sin(θ), cos(θ), 0, 0, 0, 1]
Scale Matrix
This method returns the scale matrix for 2 given scaling values (float sx, sy): [sx, 0, 0, 0, sy, 0, 0, 0, 1]
4x4 Matrix
Addition
This method adds 2 matrices and returns the resulting matrix: [(a11 + b11), (a21 + b21), (a31 + b31), (a41 + b41), (a12 + b12), (a22 + b22), (a32 + b32), (a42 + b42), (a13 + b13), (a23 + b23), (a33 + b33), (a43+ b43), (a14 + b14), (a24 + b24), (a34 + b34), (a44 + b44)].
Substraction
This method substract 2 matrices and returns the resulting matrix: [(a11 - b11), (a21 - b21), (a31 - b31), (a41 - b41), (a12 - b12), (a22 - b22), (a32 - b32), (a42 - b42), (a13 - b13), (a23 - b23), (a33 - b33), (a43- b43), (a14 - b14), (a24 - b24), (a34 - b34), (a44 - b44)].
Multiplication (Mat4f * Mat4f)
This method multiplies 2 matrices and returns the resulting matrix (will use loops to calculate the matrix): [(a11 b11) + (a12 b21) + (a13 b31) + (a14 b41), (a21 b11) + (a22 b21) + (a23 b31) + (a24 b41), (a31 b11) + (a32 b21) + (a33 b31) + (a34 b41), (a41 b11) + (a42 b21) + (a43 b31) + (a44 b41), (a11 b12) + (a12 b22) + (a13 b32) + (a14 b42), (a21 b12) + (a22 b22) + (a23 b32) + (a24 b42), (a31 b12) + (a32 b22) + (a33 b32) + (a34 b42), (a41 b12) + (a42 b22) + (a43 b32) + (a44 b42), (a11 b13) + (a12 b23) + (a13 b33) + (a14 b43), (a21 b13) + (a22 b23) + (a23 b33) + (a24 b43), (a31 b13) + (a32 b23) + (a33 b33) + (a34 b43), (a41 b13) + (a42 b23) + (a43 b33) + (a44 b43), (a11 b14) + (a12 b24) + (a13 b34) + (a14 b44), (a21 b14) + (a22 b24) + (a23 b34) + (a24 b44), (a31 b14) + (a32 b24) + (a33 b34) + (a34 b44), (a41 b14) + (a42 b24) + (a43 b34) + (a44 b44)]
Multiplication (Mat4f * Vec4f)
This method multiplies a matrix and a vector [x, y, z, w] and returns the resulting vector: [(a11 x) + (a12 y) + (a13 z) + (a14 w), (a21 x) + (a22 y) + (a23 z) + (a24 w), (a31 x) + (a32 y) + (a33 z) + (a34 w), (a41 x) + (a42 y) + (a43 z) + (a44 w)]
Multiplication (Mat4f * float)
This method multiplies a matrix and a scalar (s) and returns the resulting matrix: [(a11 s) , (a21 s), (a31 s), (a41 s), (a12 s), (a22 s), (a32 s), (a42 s), (a13 s), (a23 s), (a33 s), (a43 s), (a14 s), (a24 s), (a34 s), (a44 s)]
Determinant
This method calculates the determinant of a matrix and returns its value (float): (a11 det(A11)) - (a21 det(A21)) + (a31 det(A31) - (a41 det(A41)) [det(Aij) is the 3x3 matrix determinant of matrix A minus the ith row and jth column]
Adjoint
This method will return the adjoint matrix: [det(A11), -det(A12), det(A13), -det(A14), -det(A21), det(A22), -det(A23), det(A24), det(A31), -det(A32), det(A33), -det(A34), -det(A41), det(A42), -det(A43), det(A44)]
Inverse
This method calculates the inverse of a matrix and returns the inverted matrix: *(1 / det(A)) adj(A)**
Translation Matrix
This method returns the translation matrix for 2 given values (float tx, ty, tz): [1, 0, 0, tx, 0, 1, 0, ty, 0, 0, 1, tz, 0, 0, 0, 1]
Rotation Matrix
This method returns the rotation matrix for a given angle (θ) and axis (x, y or z): Rx = [0, cos(θ),-sin(θ), 0, 0,sin(θ), cos(θ), 0, 1, 0, 0, 0, 0, 0, 0, 1] Ry = [-sin(θ), 0, cos(θ), 0, cos(θ), 0, sin(θ), 0, 0, 1, 0, 0, 0, 0, 0, 1] Rz = [cos(θ), -sin(θ), 0, 0, sin(θ), cos(θ), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
Scale Matrix
This method returns the scale matrix for 2 given scaling values (float sx, sy, sz): [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1]