Guest User

column-major post-multiplication

a guest
Mar 26th, 2026
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1.  
  2. multiply(mat4) { /* use this and mat4 for obtaining dot products (each new element) */
  3. let t = this.array;
  4. let m = mat4.array;
  5.  
  6. return new Matrix4([ t[0]*m[0] + t[1]*m[4] + t[2]*m[8] + t[3]*m[12], /**/
  7. t[0]*m[1] + t[1]*m[5] + t[2]*m[9] + t[3]*m[13], /**/
  8. t[0]*m[2] + t[1]*m[6] + t[2]*m[10] + t[3]*m[14], /**/
  9. t[0]*m[3] + t[1]*m[7] + t[2]*m[11] + t[3]*m[15], /**/
  10. t[4]*m[0] + t[5]*m[4] + t[6]*m[8] + t[7]*m[12], /**/
  11. t[4]*m[1] + t[5]*m[5] + t[6]*m[9] + t[7]*m[13], /**/
  12. t[4]*m[2] + t[5]*m[6] + t[6]*m[10] + t[7]*m[14], /**/
  13. t[4]*m[3] + t[5]*m[7] + t[6]*m[11] + t[7]*m[15], /**/
  14. t[8]*m[0] + t[9]*m[4] + t[10]*m[8] + t[11]*m[12], /**/
  15. t[8]*m[1] + t[9]*m[5] + t[10]*m[9] + t[11]*m[13], /**/
  16. t[8]*m[2] + t[9]*m[6] + t[10]*m[10] + t[11]*m[14], /**/
  17. t[8]*m[3] + t[9]*m[7] + t[10]*m[11] + t[11]*m[15], /**/
  18. t[12]*m[0] + t[13]*m[4] + t[14]*m[8] + t[15]*m[12], /**/
  19. t[12]*m[1] + t[13]*m[5] + t[14]*m[9] + t[15]*m[13],
  20. t[12]*m[2] + t[13]*m[6] + t[14]*m[10] + t[15]*m[14], /**/
  21. t[12]*m[3] + t[13]*m[7] + t[14]*m[11] + t[15]*m[15] ]);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment