* Multiplies the current matrix with another matrix or matrix-like array. * * This method supports several types of input: * - Another Matrix instance * - A matrix-like array (must be a perfect square, e.g., 4x4 or 3x3) * - Multiple arguments that form a perfect square matrix *
(multMatrix)
| 540 | * } |
| 541 | */ |
| 542 | mult(multMatrix) { |
| 543 | let _src; |
| 544 | if (multMatrix === this || multMatrix === this.matrix) { |
| 545 | _src = this.copy().matrix; // only need to allocate in this rare case |
| 546 | } else if (multMatrix instanceof Matrix) { |
| 547 | _src = multMatrix.matrix; |
| 548 | } else if (isMatrixArray(multMatrix) && isPerfectSquare(multMatrix)) { |
| 549 | _src = multMatrix; |
| 550 | } else if (isPerfectSquare(Array.from(arguments))) { |
| 551 | _src = Array.from(arguments); |
| 552 | } else { |
| 553 | return; // nothing to do. |
| 554 | } |
| 555 | if (this.#sqDimention === 4 && _src.length === 16) { |
| 556 | return this.#mult4x4(_src); |
| 557 | } else if (this.#sqDimention === 3 && _src.length === 9) { |
| 558 | return this.#mult3x3(_src); |
| 559 | } else { |
| 560 | return this.#multNxN(_src); |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | /** |
| 565 | * Takes a vector and returns the vector resulting from multiplying to that vector by this matrix from left. This function is only for 3x3 matrices. |
nothing calls this directly
no test coverage detected