MCPcopy Index your code
hub / github.com/processing/p5.js / mult

Method mult

src/math/Matrices/Matrix.js:542–562  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 6

copyMethod · 0.95
#mult4x4Method · 0.95
#mult3x3Method · 0.95
#multNxNMethod · 0.95
isPerfectSquareFunction · 0.85
isMatrixArrayFunction · 0.70

Tested by

no test coverage detected