@@ -812,22 +812,20 @@ export class Matrix extends MatrixInterface {
812
812
* @returns {Matrix } The current matrix after applying the transformation.
813
813
*
814
814
* @example
815
+ * <div class="norender"><code>
816
+ * function setup() {
817
+ *
815
818
* // Assuming `matrix` is an instance of Matrix
816
819
* const anotherMatrix = new p5.Matrix();
817
820
* matrix.apply(anotherMatrix);
818
821
*
819
- * @example
820
822
* // Applying a transformation using an array
821
823
* const matrixArray = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
822
824
* matrix.apply(matrixArray);
823
825
*
824
- * @example
825
826
* // Applying a transformation using individual arguments
826
827
* matrix.apply(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
827
828
*
828
- * // p5.js script example
829
- * <div class="norender"><code>
830
- * function setup() {
831
829
*
832
830
* // Create a 4x4 identity matrix
833
831
* const matrix = new p5.Matrix(4);
@@ -988,9 +986,29 @@ export class Matrix extends MatrixInterface {
988
986
}
989
987
990
988
/**
989
+ * Rotate the Matrix around a specified axis by a given angle.
990
+ *
991
+ * This method applies a rotation transformation to the matrix, modifying its orientation
992
+ * in 3D space. The rotation is performed around the provided axis, which can be defined
993
+ * as a `p5.Vector` or an array of numbers representing the x, y, and z components of the axis.
991
994
* Rotate our Matrix around an axis by the given angle.
992
- * @param {Number } a The angle of rotation in radians
993
- * @param {p5.Vector|Number[] } axis the axis(es) to rotate around
995
+ * @param {Number } a The angle of rotation in radians.
996
+ * Angles in radians are a measure of rotation, where 2π radians
997
+ * represent a full circle (360 degrees). For example:
998
+ * - π/2 radians = 90 degrees (quarter turn)
999
+ * - π radians = 180 degrees (half turn)
1000
+ * - 2π radians = 360 degrees (full turn)
1001
+ * Use `Math.PI` for π or `p5`'s `PI` constant if using p5.js.
1002
+ * @param {p5.Vector|Number[] } axis The axis or axes to rotate around.
1003
+ * This defines the direction of the rotation.
1004
+ * - If using a `p5.Vector`, it should represent
1005
+ * the x, y, and z components of the axis.
1006
+ * - If using an array, it should be in the form
1007
+ * [x, y, z], where x, y, and z are numbers.
1008
+ * For example:
1009
+ * - [1, 0, 0] rotates around the x-axis.
1010
+ * - [0, 1, 0] rotates around the y-axis.
1011
+ * - [0, 0, 1] rotates around the z-axis. *
994
1012
* @chainable
995
1013
* inspired by Toji's gl-matrix lib, mat4 rotation
996
1014
*/
0 commit comments