Skip to content
Snippets Groups Projects
Commit cbe30678 authored by Christoph-Anton Schwierz's avatar Christoph-Anton Schwierz
Browse files

matrixProduct()

parent 1d2d814b
Branches
No related tags found
No related merge requests found
......@@ -72,4 +72,21 @@ export function vecCrossProduct(vecOne: Array<number>, vecTwo: Array<number>){
return crossProduct;
}
export function matrixProduct(a: Array<number>, b: Array<number>){
// for 3x3 matrix only
//[
// 0 1 2
// 3 4 5
// 6 7 8
// ]
return [
//row 1
a[0]*b[0] + a[1]*b[3] + a[2]*b[6], a[0]*b[1] + a[1]*b[4] + a[2]*b[7], a[0]*b[2] + a[1]*b[5] + a[2]*b[8],
//row 2
a[3]*b[0] + a[4]*b[3] + a[5]*b[6], a[3]*b[1] + a[4]*b[4] + a[5]*b[7], a[3]*b[2] + a[4]*b[5] + a[5]*b[8],
//row 3
a[6]*b[0] + a[7]*b[3] + a[8]*b[6], a[6]*b[1] + a[7]*b[4] + a[8]*b[7], a[6]*b[2] + a[7]*b[5] + a[8]*b[8],
]
}
//
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment