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

Method multiplyVec4

src/math/Matrices/Matrix.js:1383–1393  ·  view source on GitHub ↗

* Applies a matrix to a vector with x, y, z, w components and returns the result as an array. * * This method multiplies the current matrix by a 4D vector (x, y, z, w) and computes the resulting vector. * It is commonly used in 3D graphics for transformations such as translation, rotation,

(x, y, z, w)

Source from the content-addressed store, hash-verified

1381 * }
1382 */
1383 multiplyVec4(x, y, z, w) {
1384 const result = new Array(4);
1385 const m = this.matrix;
1386
1387 result[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
1388 result[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
1389 result[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
1390 result[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
1391
1392 return result;
1393 }
1394
1395 /**
1396 * Applies a matrix to a vector. The fourth component is set to 1.

Callers 3

multiplyPointMethod · 0.95
multiplyDirectionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected