Skip to content

Commit 318ed32

Browse files
committed
p5.Matrix, update documentation import p5
1 parent 661c04e commit 318ed32

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/math/Matrices/Matrix.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,8 @@ export class Matrix extends MatrixInterface {
816816
* function setup() {
817817
*
818818
* // Assuming `matrix` is an instance of Matrix
819-
* const anotherMatrix = new p5.Matrix();
819+
* const anotherMatrix = new p5.Matrix(4);
820+
* const anotherMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
820821
* matrix.apply(anotherMatrix);
821822
*
822823
* // Applying a transformation using an array

src/math/p5.Matrix.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ function matrix(p5, fn) {
2323
* @param {Array} [mat4] column-major array literal of our 4×4 matrix
2424
* @example
2525
* // Creating a 3x3 matrix from an array using column major arrangement
26-
* const matrix = new Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]);
26+
* const matrix = new p5.Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]);
2727
*
2828
* // Creating a 4x4 identity matrix
29-
* const identityMatrix = new Matrix(4);
29+
* const identityMatrix = new p5.Matrix(4);
3030
*
3131
* // Adding two matrices
32-
* const matrix1 = new Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]);
33-
* const matrix2 = new Matrix([9, 8, 7, 6, 5, 4, 3, 2, 1]);
32+
* const matrix1 = new p5.Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]);
33+
* const matrix2 = new p5.Matrix([9, 8, 7, 6, 5, 4, 3, 2, 1]);
3434
* matrix1.add(matrix2); // matrix1 is now [10, 10, 10, 10, 10, 10, 10, 10, 10]
3535
*
3636
* // Setting an element in the matrix
@@ -72,30 +72,30 @@ function matrix(p5, fn) {
7272
* function setup() {
7373
*
7474
* // Create a 4x4 identity matrix
75-
* const matrix = new Matrix(4);
76-
* console.log("Original Matrix:", matrix.matrix);
75+
* const matrix = new p5.Matrix(4);
76+
* console.log("Original p5.Matrix:", matrix.matrix);
7777
*
7878
* // Add two matrices
79-
* const matrix1 = new Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]);
80-
* const matrix2 = new Matrix([9, 8, 7, 6, 5, 4, 3, 2, 1]);
79+
* const matrix1 = new p5.Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]);
80+
* const matrix2 = new p5.Matrix([9, 8, 7, 6, 5, 4, 3, 2, 1]);
8181
* matrix1.add(matrix2);
8282
* console.log("After Addition:", matrix1.matrix); // Output: [10, 10, 10, 10, 10, 10, 10, 10, 10]
8383
*
8484
* // Reset the matrix to an identity matrix
8585
* matrix.reset();
86-
* console.log("Reset Matrix:", matrix.matrix);
86+
* console.log("Reset p5.Matrix:", matrix.matrix);
8787
*
8888
* // Apply a scaling transformation
8989
* matrix.scale(2, 2, 2);
90-
* console.log("Scaled Matrix:", matrix.matrix);
90+
* console.log("Scaled p5.Matrix:", matrix.matrix);
9191
*
9292
* // Apply a rotation around the X-axis
9393
* matrix.rotate4x4(Math.PI / 4, 1, 0, 0);
94-
* console.log("Rotated Matrix (X-axis):", matrix.matrix);
94+
* console.log("Rotated p5.Matrix (X-axis):", matrix.matrix);
9595
*
9696
* // Apply a perspective transformation
9797
* matrix.perspective(Math.PI / 4, 1, 0.1, 100);
98-
* console.log("Perspective Matrix:", matrix.matrix);
98+
* console.log("Perspective p5.Matrix:", matrix.matrix);
9999
*
100100
* // Multiply a vector by the matrix
101101
* const vector = new Vector(1, 2, 3);

0 commit comments

Comments
 (0)