Skip to content

Commit

Permalink
Mention order of M * v multiplication in all Vector.mul(Matrix) methods
Browse files Browse the repository at this point in the history
Because at first sight of a method call
`vector.mul(matrix)` the first assumption
is that it would be `v * M`, which it is not.
  • Loading branch information
httpdigest committed Jun 30, 2023
1 parent b2d3c67 commit 5b4d4c2
Show file tree
Hide file tree
Showing 12 changed files with 366 additions and 112 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/joml/Vector2d.java
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public Vector2d div(Vector2dc v, Vector2d dest) {
}

/**
* Multiply the given matrix <code>mat</code> with this Vector2d.
* Multiply the given matrix <code>mat</code> with this vector.
*
* @param mat
* the matrix to multiply this vector by
Expand All @@ -767,7 +767,7 @@ public Vector2d mul(Matrix2fc mat) {
}

/**
* Multiply the given matrix <code>mat</code> with this Vector2d.
* Multiply the given matrix <code>mat</code> with this vector.
*
* @param mat
* the matrix to multiply this vector by
Expand Down
22 changes: 20 additions & 2 deletions src/main/java/org/joml/Vector2dc.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ public interface Vector2dc {
/**
* Multiply the given matrix <code>mat</code> with <code>this</code> and store the
* result in <code>dest</code>.
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix to multiply this vector by
Expand All @@ -256,6 +259,9 @@ public interface Vector2dc {
/**
* Multiply the given matrix <code>mat</code> with <code>this</code> and store the
* result in <code>dest</code>.
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix to multiply this vector by
Expand All @@ -267,6 +273,9 @@ public interface Vector2dc {

/**
* Multiply the transpose of the given matrix with this Vector2f and store the result in <code>dest</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand All @@ -278,6 +287,9 @@ public interface Vector2dc {

/**
* Multiply the transpose of the given matrix with this Vector2f and store the result in <code>dest</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand All @@ -292,7 +304,10 @@ public interface Vector2dc {
* result in <code>dest</code>.
* <p>
* This method assumes the <code>z</code> component of <code>this</code> to be <code>1.0</code>.
*
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix to multiply this vector by
* @param dest
Expand All @@ -306,7 +321,10 @@ public interface Vector2dc {
* result in <code>dest</code>.
* <p>
* This method assumes the <code>z</code> component of <code>this</code> to be <code>0.0</code>.
*
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix to multiply this vector by
* @param dest
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/joml/Vector2f.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ public Vector2f set(double d) {

/**
* Set the x and y components to the supplied values.
* <p>
* Note that due to the <code>this</code> vector storing the components in float-precision,
* there is the possibility to lose precision.
*
* @param x
* the x component
Expand Down Expand Up @@ -990,7 +993,10 @@ public Vector2f mul(Matrix2dc mat, Vector2f dest) {
}

/**
* Multiply the transpose of the given matrix with this Vector2f store the result in <code>this</code>.
* Multiply the transpose of the given matrix with this vector and store the result in <code>this</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/org/joml/Vector2fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ public interface Vector2fc {

/**
* Multiply the given matrix with this Vector2f and store the result in <code>dest</code>.
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand All @@ -360,6 +363,9 @@ public interface Vector2fc {

/**
* Multiply the given matrix with this Vector2f and store the result in <code>dest</code>.
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand All @@ -371,6 +377,9 @@ public interface Vector2fc {

/**
* Multiply the transpose of the given matrix with this Vector3f and store the result in <code>dest</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand All @@ -385,7 +394,10 @@ public interface Vector2fc {
* result in <code>dest</code>.
* <p>
* This method assumes the <code>z</code> component of <code>this</code> to be <code>1.0</code>.
*
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix to multiply this vector by
* @param dest
Expand All @@ -399,7 +411,10 @@ public interface Vector2fc {
* result in <code>dest</code>.
* <p>
* This method assumes the <code>z</code> component of <code>this</code> to be <code>0.0</code>.
*
* <p>
* Note that this method performs the operation <code>M * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix to multiply this vector by
* @param dest
Expand Down
32 changes: 25 additions & 7 deletions src/main/java/org/joml/Vector3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ public Vector3d mulProject(Matrix4fc mat) {
}

/**
* Multiply the given matrix <code>mat</code> with this Vector3d.
* Multiply the given matrix <code>mat</code> with this vector.
*
* @param mat
* the matrix to multiply this vector by
Expand All @@ -1079,7 +1079,7 @@ public Vector3d mul(Matrix3fc mat) {
}

/**
* Multiply the given matrix <code>mat</code> with this Vector3d.
* Multiply the given matrix <code>mat</code> with this vector.
*
* @param mat
* the matrix to multiply this vector by
Expand Down Expand Up @@ -1162,7 +1162,10 @@ public Vector3d mul(Matrix3x2fc mat, Vector3d dest) {
}

/**
* Multiply the transpose of the given matrix with this Vector3d and store the result in <code>this</code>.
* Multiply the transpose of the given matrix with this vector and store the result in <code>this</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand All @@ -1183,7 +1186,10 @@ public Vector3d mulTranspose(Matrix3dc mat, Vector3d dest) {
}

/**
* Multiply the transpose of the given matrix with this Vector3d and store the result in <code>this</code>.
* Multiply the transpose of the given matrix with this vector and store the result in <code>this</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix
Expand Down Expand Up @@ -1323,6 +1329,9 @@ public Vector3d mulPosition(Matrix4x3fc mat, Vector3d dest) {
* Multiply the transpose of the given 4x4 matrix <code>mat</code> with <code>this</code>.
* <p>
* This method assumes the <code>w</code> component of <code>this</code> to be <code>1.0</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix whose transpose to multiply this vector by
Expand All @@ -1346,6 +1355,9 @@ public Vector3d mulTransposePosition(Matrix4dc mat, Vector3d dest) {
* Multiply the transpose of the given 4x4 matrix <code>mat</code> with <code>this</code>.
* <p>
* This method assumes the <code>w</code> component of <code>this</code> to be <code>1.0</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix whose transpose to multiply this vector by
Expand Down Expand Up @@ -1511,6 +1523,9 @@ public Vector3d mulDirection(Matrix4x3fc mat, Vector3d dest) {
* Multiply the transpose of the given 4x4 matrix <code>mat</code> with <code>this</code>.
* <p>
* This method assumes the <code>w</code> component of <code>this</code> to be <code>0.0</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix whose transpose to multiply this vector by
Expand All @@ -1534,6 +1549,9 @@ public Vector3d mulTransposeDirection(Matrix4dc mat, Vector3d dest) {
* Multiply the transpose of the given 4x4 matrix <code>mat</code> with <code>this</code>.
* <p>
* This method assumes the <code>w</code> component of <code>this</code> to be <code>0.0</code>.
* <p>
* Note that this method performs the operation <code>M^T * this</code>, where <code>M</code> is the provided matrix
* and thus interprets <code>this</code> as a <em>column</em> vector.
*
* @param mat
* the matrix whose transpose to multiply this vector by
Expand Down Expand Up @@ -1621,9 +1639,9 @@ public Quaterniond rotationTo(double toDirX, double toDirY, double toDirZ, Quate
/**
* Rotate this vector the specified radians around the given rotation axis.
* <p>
* If your rotation axis is either <code>(1, 0, 0)</code>, <code>(0, 1, 0)</code> or <code>(0, 0, 1)</code>
* you should use {@link #rotateX(double) rotateX()}, {@link #rotateY(double) rotateY()} or
* {@link #rotateZ(double) rotateZ()}, respectively, instead.
* If the rotation axis is either <code>(1, 0, 0)</code>, <code>(0, 1, 0)</code> or <code>(0, 0, 1)</code>,
* then {@link #rotateX(double) rotateX()}, {@link #rotateY(double) rotateY()} or
* {@link #rotateZ(double) rotateZ()}, respectively, should be used instead.
*
* @param angle
* the angle in radians
Expand Down
Loading

0 comments on commit 5b4d4c2

Please sign in to comment.