Skip to content

Commit 9d5d076

Browse files
committed
p5.Matrix add rotate4x4 sketch documentation
1 parent d884182 commit 9d5d076

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/math/Matrices/Matrix.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,19 @@ export class Matrix extends MatrixInterface {
10121012
* - [0, 0, 1] rotates around the z-axis. *
10131013
* @chainable
10141014
* inspired by Toji's gl-matrix lib, mat4 rotation
1015+
*
1016+
* @example
1017+
* // p5.js script example
1018+
* <div class="norender"><code>
1019+
* function setup() {
1020+
* const matrix = new p5.Matrix(4); // Create a 4x4 identity matrix
1021+
* console.log("Original Matrix:", matrix.matrix.slice().toString()); // [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
1022+
*
1023+
* // Translate the matrix by a 3D vector
1024+
* matrix.rotate4x4(Math.PI, [1,0,0]);
1025+
* console.log("After rotation of PI degrees on vector [1,0,0]:", matrix.matrix.slice().toString()); // [1,0,0,0,0,-1,1.2246468525851679e-16,0,0,-1.2246468525851679e-16,-1,0,0,0,0,1]
1026+
* }
1027+
* </code></div>
10151028
*/
10161029
rotate4x4(a, x, y, z) {
10171030
if (x instanceof Vector) {

0 commit comments

Comments
 (0)