diff --git a/algebra.mjs b/algebra.mjs new file mode 100644 index 0000000..4a565b6 --- /dev/null +++ b/algebra.mjs @@ -0,0 +1,36 @@ +export function calcRotationMatrix(vec, rad) { + // Equation used from: + // https://people.eecs.berkeley.edu/~ug/slide/pipeline/assignments/as5/rotation.html + let A = glMatrix.mat3.fromValues( + 0, + -vec[2], + vec[1], + vec[2], + 0, + -vec[0], + -vec[1], + vec[0], + 0, + ); + + let I = glMatrix.mat3.create(); + + // Matrix Exponential + let Mpow = glMatrix.mat3.create(); + glMatrix.mat3.mul(Mpow, A, A); + + let M1 = glMatrix.mat3.create(); + let M2 = glMatrix.mat3.create(); + + // Scalar Multiplications + glMatrix.mat3.multiplyScalar(M1, A, Math.sin(rad)); + glMatrix.mat3.multiplyScalar(M2, Mpow, 1 - Math.cos(rad)); + + // Matrix Addition + let M3 = glMatrix.mat3.create(); + let Q = glMatrix.mat3.create(); + glMatrix.mat3.add(M3, I, M1); + glMatrix.mat3.add(Q, M3, M2); + + return Q; +} diff --git a/bg.webp b/bg.webp new file mode 100644 index 0000000..ab06ba2 Binary files /dev/null and b/bg.webp differ diff --git a/index.html b/index.html index 290c63e..6994526 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,31 @@