diff --git a/src/main/java/org/joml/Vector3d.java b/src/main/java/org/joml/Vector3d.java
index 2cd8b097..de655a8a 100644
--- a/src/main/java/org/joml/Vector3d.java
+++ b/src/main/java/org/joml/Vector3d.java
@@ -1005,66 +1005,177 @@ public Vector3d mulProject(Matrix4dc mat, double w, Vector3d dest) {
return dest;
}
- public Vector3d mulProject(Matrix4dc mat, Vector3d dest) {
- double invW = 1.0 / Math.fma(mat.m03(), x, Math.fma(mat.m13(), y, Math.fma(mat.m23(), z, mat.m33())));
- double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30()))) * invW;
- double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31()))) * invW;
- double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32()))) * invW;
- dest.x = rx;
- dest.y = ry;
- dest.z = rz;
- return dest;
- }
-
/**
- * Multiply the given matrix mat
this Vector3d, perform perspective division.
+ * Multiply the given matrix mat
with this vector and perform perspective division.
*
* This method uses w=1.0
as the fourth vector component.
- *
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
* @param mat
* the matrix to multiply this vector by
* @return this
*/
public Vector3d mulProject(Matrix4dc mat) {
- double invW = 1.0 / Math.fma(mat.m03(), x, Math.fma(mat.m13(), y, Math.fma(mat.m23(), z, mat.m33())));
- double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30()))) * invW;
- double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31()))) * invW;
- double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32()))) * invW;
- this.x = rx;
- this.y = ry;
- this.z = rz;
- return this;
+ int prop = mat.properties();
+ if ((prop & Matrix4dc.PROPERTY_IDENTITY) != 0)
+ return this;
+ if ((prop & Matrix4dc.PROPERTY_TRANSLATION) != 0)
+ return mulProjectTranslation(mat, this);
+ if ((prop & Matrix4dc.PROPERTY_AFFINE) != 0)
+ return mulProjectAffine(mat, this);
+ return mulProjectGeneric(mat, this);
+ }
+ public Vector3d mulProject(Matrix4dc mat, Vector3d dest) {
+ int prop = mat.properties();
+ if ((prop & Matrix4dc.PROPERTY_IDENTITY) != 0)
+ return dest.set(this);
+ if ((prop & Matrix4dc.PROPERTY_TRANSLATION) != 0)
+ return mulProjectTranslation(mat, dest);
+ if ((prop & Matrix4dc.PROPERTY_AFFINE) != 0)
+ return mulProjectAffine(mat, dest);
+ return mulProjectGeneric(mat, dest);
}
-
public Vector3d mulProject(Matrix4fc mat, Vector3d dest) {
+ int prop = mat.properties();
+ if ((prop & Matrix4fc.PROPERTY_IDENTITY) != 0)
+ return dest.set(this);
+ if ((prop & Matrix4fc.PROPERTY_TRANSLATION) != 0)
+ return mulProjectTranslation(mat, dest);
+ if ((prop & Matrix4fc.PROPERTY_AFFINE) != 0)
+ return mulProjectAffine(mat, dest);
+ return mulProjectGeneric(mat, dest);
+ }
+ /**
+ * Multiply the given matrix mat
with this vector and perform perspective division.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulProjectTranslation(Matrix4dc mat) {
+ return mulPositionTranslation(mat, this);
+ }
+ public Vector3d mulProjectTranslation(Matrix4dc mat, Vector3d dest) {
+ return mulPositionTranslation(mat, dest);
+ }
+ /**
+ * Multiply the given matrix mat
with this vector and perform perspective division.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulProjectTranslation(Matrix4fc mat) {
+ return mulPositionTranslation(mat, this);
+ }
+ public Vector3d mulProjectTranslation(Matrix4fc mat, Vector3d dest) {
+ return mulPositionTranslation(mat, dest);
+ }
+ /**
+ * Multiply the given matrix mat
with this vector and perform perspective division.
+ *
+ * This method assumes that the matrix mat
represents only an affine transformation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulProjectAffine(Matrix4dc mat) {
+ return mulPositionAffine(mat, this);
+ }
+ public Vector3d mulProjectAffine(Matrix4dc mat, Vector3d dest) {
+ return mulPositionAffine(mat, dest);
+ }
+ /**
+ * Multiply the given matrix mat
with this vector and perform perspective division.
+ *
+ * This method assumes that the matrix mat
represents only an affine transformation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulProjectAffine(Matrix4fc mat) {
+ return mulPositionAffine(mat, this);
+ }
+ public Vector3d mulProjectAffine(Matrix4fc mat, Vector3d dest) {
+ return mulPositionAffine(mat, dest);
+ }
+ /**
+ * Multiply the given matrix mat
with this vector and perform perspective division.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulProjectGeneric(Matrix4dc mat) {
+ return mulProjectGeneric(mat, this);
+ }
+ public Vector3d mulProjectGeneric(Matrix4dc mat, Vector3d dest) {
+ double x = this.x, y = this.y, z = this.z;
double invW = 1.0 / Math.fma(mat.m03(), x, Math.fma(mat.m13(), y, Math.fma(mat.m23(), z, mat.m33())));
- double rx = (mat.m00() * x + mat.m10() * y + mat.m20() * z + mat.m30()) * invW;
- double ry = (mat.m01() * x + mat.m11() * y + mat.m21() * z + mat.m31()) * invW;
- double rz = (mat.m02() * x + mat.m12() * y + mat.m22() * z + mat.m32()) * invW;
- dest.x = rx;
- dest.y = ry;
- dest.z = rz;
+ dest.x = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30()))) * invW;
+ dest.y = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31()))) * invW;
+ dest.z = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32()))) * invW;
return dest;
}
-
/**
- * Multiply the given matrix mat
with this Vector3d, perform perspective division.
+ * Multiply the given matrix mat
with this vector and perform perspective division.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
*
* This method uses w=1.0
as the fourth vector component.
- *
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
* @param mat
* the matrix to multiply this vector by
* @return this
*/
- public Vector3d mulProject(Matrix4fc mat) {
+ public Vector3d mulProjectGeneric(Matrix4fc mat) {
+ return mulProjectGeneric(mat, this);
+ }
+ public Vector3d mulProjectGeneric(Matrix4fc mat, Vector3d dest) {
+ double x = this.x, y = this.y, z = this.z;
double invW = 1.0 / Math.fma(mat.m03(), x, Math.fma(mat.m13(), y, Math.fma(mat.m23(), z, mat.m33())));
- double rx = (mat.m00() * x + mat.m10() * y + mat.m20() * z + mat.m30()) * invW;
- double ry = (mat.m01() * x + mat.m11() * y + mat.m21() * z + mat.m31()) * invW;
- double rz = (mat.m02() * x + mat.m12() * y + mat.m22() * z + mat.m32()) * invW;
- this.x = rx;
- this.y = ry;
- this.z = rz;
- return this;
+ dest.x = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30()))) * invW;
+ dest.y = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31()))) * invW;
+ dest.z = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32()))) * invW;
+ return dest;
}
/**
@@ -1209,6 +1320,45 @@ public Vector3d mulTranspose(Matrix3fc mat, Vector3d dest) {
return dest;
}
+ /**
+ * Multiply the given 4x4 matrix mat
with this
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPosition(Matrix4dc mat) {
+ int prop = mat.properties();
+ if ((prop & Matrix4dc.PROPERTY_IDENTITY) != 0)
+ return this;
+ if ((prop & Matrix4dc.PROPERTY_TRANSLATION) != 0)
+ return mulPositionTranslation(mat, this);
+ if ((prop & Matrix4dc.PROPERTY_AFFINE) != 0)
+ return mulPositionAffine(mat, this);
+ return mulPositionGeneric(mat, this);
+ }
+ public Vector3d mulPosition(Matrix4dc mat, Vector3d dest) {
+ int prop = mat.properties();
+ if ((prop & Matrix4fc.PROPERTY_IDENTITY) != 0)
+ return dest.set(this);
+ if ((prop & Matrix4fc.PROPERTY_TRANSLATION) != 0)
+ return mulPositionTranslation(mat, dest);
+ if ((prop & Matrix4fc.PROPERTY_AFFINE) != 0)
+ return mulPositionAffine(mat, dest);
+ return mulPositionGeneric(mat, dest);
+ }
+ public Vector3d mulPosition(Matrix4fc mat, Vector3d dest) {
+ int prop = mat.properties();
+ if ((prop & Matrix4fc.PROPERTY_IDENTITY) != 0)
+ return dest.set(this);
+ if ((prop & Matrix4fc.PROPERTY_TRANSLATION) != 0)
+ return mulPositionTranslation(mat, dest);
+ if ((prop & Matrix4fc.PROPERTY_AFFINE) != 0)
+ return mulPositionAffine(mat, dest);
+ return mulPositionGeneric(mat, dest);
+ }
/**
* Multiply the given 4x4 matrix mat
with this
.
*
@@ -1219,32 +1369,156 @@ public Vector3d mulTranspose(Matrix3fc mat, Vector3d dest) {
* @return this
*/
public Vector3d mulPosition(Matrix4fc mat) {
- double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
- double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
- double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
- this.x = rx;
- this.y = ry;
- this.z = rz;
- return this;
+ int prop = mat.properties();
+ if ((prop & Matrix4fc.PROPERTY_IDENTITY) != 0)
+ return this;
+ if ((prop & Matrix4fc.PROPERTY_TRANSLATION) != 0)
+ return mulPositionTranslation(mat, this);
+ if ((prop & Matrix4fc.PROPERTY_AFFINE) != 0)
+ return mulPositionAffine(mat, this);
+ return mulPositionGeneric(mat, this);
}
-
/**
* Multiply the given 4x4 matrix mat
with this
.
*
+ * This method assumes that the matrix mat
represents only a translation.
+ *
* This method assumes the w
component of this
to be 1.0
.
- *
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
* @param mat
* the matrix to multiply this vector by
* @return this
*/
- public Vector3d mulPosition(Matrix4dc mat) {
- double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
- double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
- double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
- this.x = rx;
- this.y = ry;
- this.z = rz;
- return this;
+ public Vector3d mulPositionTranslation(Matrix4dc mat) {
+ return mulPositionTranslation(mat, this);
+ }
+ public Vector3d mulPositionTranslation(Matrix4dc mat, Vector3d dest) {
+ dest.x = this.x + mat.m30();
+ dest.y = this.y + mat.m31();
+ dest.z = this.z + mat.m32();
+ return dest;
+ }
+ /**
+ * Multiply the given 4x4 matrix mat
with this
.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPositionTranslation(Matrix4fc mat) {
+ return mulPositionTranslation(mat, this);
+ }
+ public Vector3d mulPositionTranslation(Matrix4fc mat, Vector3d dest) {
+ dest.x = this.x + mat.m30();
+ dest.y = this.y + mat.m31();
+ dest.z = this.z + mat.m32();
+ return dest;
+ }
+ /**
+ * Multiply the given 4x4 matrix mat
with this
.
+ *
+ * This method assumes that the matrix mat
represents an affine transformation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPositionAffine(Matrix4dc mat) {
+ return mulPositionAffine(mat, this);
+ }
+ public Vector3d mulPositionAffine(Matrix4dc mat, Vector3d dest) {
+ double x = this.x, y = this.y, z = this.z;
+ dest.x = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, mat.m20() * z)) + mat.m30();
+ dest.y = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, mat.m21() * z)) + mat.m31();
+ dest.z = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, mat.m22() * z)) + mat.m32();
+ return dest;
+ }
+ /**
+ * Multiply the given 4x4 matrix mat
with this
.
+ *
+ * This method assumes that the matrix mat
represents an affine transformation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPositionAffine(Matrix4fc mat) {
+ return mulPositionAffine(mat, this);
+ }
+ public Vector3d mulPositionAffine(Matrix4fc mat, Vector3d dest) {
+ double x = this.x, y = this.y, z = this.z;
+ dest.x = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, mat.m20() * z)) + mat.m30();
+ dest.y = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, mat.m21() * z)) + mat.m31();
+ dest.z = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, mat.m22() * z)) + mat.m32();
+ return dest;
+ }
+ /**
+ * Multiply the given 4x4 matrix mat
with this
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPositionGeneric(Matrix4dc mat) {
+ return mulPositionGeneric(mat, this);
+ }
+ public Vector3d mulPositionGeneric(Matrix4dc mat, Vector3d dest) {
+ double x = this.x, y = this.y, z = this.z;
+ dest.x = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
+ dest.y = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
+ dest.z = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
+ return dest;
+ }
+ /**
+ * Multiply the given 4x4 matrix mat
with this
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPositionGeneric(Matrix4fc mat) {
+ return mulPositionGeneric(mat, this);
+ }
+ public Vector3d mulPositionGeneric(Matrix4fc mat, Vector3d dest) {
+ double x = this.x, y = this.y, z = this.z;
+ dest.x = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
+ dest.y = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
+ dest.z = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
+ return dest;
}
/**
@@ -1257,35 +1531,37 @@ public Vector3d mulPosition(Matrix4dc mat) {
* @return this
*/
public Vector3d mulPosition(Matrix4x3dc mat) {
+ int prop = mat.properties();
+ if ((prop & Matrix4x3fc.PROPERTY_IDENTITY) != 0)
+ return this;
+ if ((prop & Matrix4x3fc.PROPERTY_TRANSLATION) != 0)
+ return mulPositionTranslation(mat, this);
+ return mulPositionGeneric(mat);
+ }
+ public Vector3d mulPositionTranslation(Matrix4x3dc mat, Vector3d dest) {
double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
- this.x = rx;
- this.y = ry;
- this.z = rz;
- return this;
+ dest.x = rx;
+ dest.y = ry;
+ dest.z = rz;
+ return dest;
}
-
/**
- * Multiply the given 4x3 matrix mat
with this
.
+ * Multiply the given 4x3 matrix mat
, representing only a translation, with this
.
+ *
+ * This method only works when mat
only represents a translation.
*
* This method assumes the w
component of this
to be 1.0
.
- *
+ *
* @param mat
* the matrix to multiply this vector by
* @return this
*/
- public Vector3d mulPosition(Matrix4x3fc mat) {
- double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
- double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
- double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
- this.x = rx;
- this.y = ry;
- this.z = rz;
- return this;
+ public Vector3d mulPositionTranslation(Matrix4x3dc mat) {
+ return mulPositionTranslation(mat, this);
}
-
- public Vector3d mulPosition(Matrix4dc mat, Vector3d dest) {
+ public Vector3d mulPositionGeneric(Matrix4x3dc mat, Vector3d dest) {
double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
@@ -1294,8 +1570,42 @@ public Vector3d mulPosition(Matrix4dc mat, Vector3d dest) {
dest.z = rz;
return dest;
}
+ /**
+ * Multiply the given 4x3 matrix mat
with this
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPositionGeneric(Matrix4x3dc mat) {
+ return mulPositionGeneric(mat, this);
+ }
- public Vector3d mulPosition(Matrix4fc mat, Vector3d dest) {
+ /**
+ * Multiply the given 4x3 matrix mat
with this
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPosition(Matrix4x3fc mat) {
+ int prop = mat.properties();
+ if ((prop & Matrix4x3fc.PROPERTY_IDENTITY) != 0)
+ return this;
+ if ((prop & Matrix4x3fc.PROPERTY_TRANSLATION) != 0)
+ return mulPositionTranslation(mat, this);
+ return mulPositionGeneric(mat, this);
+ }
+ public Vector3d mulPositionTranslation(Matrix4x3fc mat) {
+ return mulPositionTranslation(mat, this);
+ }
+ public Vector3d mulPositionTranslation(Matrix4x3fc mat, Vector3d dest) {
double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
@@ -1304,8 +1614,21 @@ public Vector3d mulPosition(Matrix4fc mat, Vector3d dest) {
dest.z = rz;
return dest;
}
-
- public Vector3d mulPosition(Matrix4x3dc mat, Vector3d dest) {
+ /**
+ * Multiply the given 4x3 matrix mat
with this
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @return this
+ */
+ public Vector3d mulPositionGeneric(Matrix4x3fc mat) {
+ return mulPositionGeneric(mat, this);
+ }
+ public Vector3d mulPositionGeneric(Matrix4x3fc mat, Vector3d dest) {
double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
double rz = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
@@ -1315,6 +1638,15 @@ public Vector3d mulPosition(Matrix4x3dc mat, Vector3d dest) {
return dest;
}
+ public Vector3d mulPosition(Matrix4x3dc mat, Vector3d dest) {
+ int prop = mat.properties();
+ if ((prop & Matrix4x3fc.PROPERTY_IDENTITY) != 0)
+ return dest.set(this);
+ if ((prop & Matrix4x3fc.PROPERTY_TRANSLATION) != 0)
+ return mulPositionTranslation(mat, dest);
+ return mulPositionGeneric(mat, dest);
+ }
+
public Vector3d mulPosition(Matrix4x3fc mat, Vector3d dest) {
double rx = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
double ry = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
diff --git a/src/main/java/org/joml/Vector3dc.java b/src/main/java/org/joml/Vector3dc.java
index a27c341f..4c436ec5 100644
--- a/src/main/java/org/joml/Vector3dc.java
+++ b/src/main/java/org/joml/Vector3dc.java
@@ -486,6 +486,120 @@ public interface Vector3dc {
*/
Vector3d mulProject(Matrix4fc mat, Vector3d dest);
+ /**
+ * Multiply the given matrix mat
with this vector, perform perspective division
+ * and store the result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulProjectTranslation(Matrix4fc mat, Vector3d dest);
+
+ /**
+ * Multiply the given matrix mat
with this vector, perform perspective division
+ * and store the result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulProjectTranslation(Matrix4dc mat, Vector3d dest);
+
+ /**
+ * Multiply the given matrix mat
with this vector, perform perspective division
+ * and store the result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only an affine transformation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulProjectAffine(Matrix4fc mat, Vector3d dest);
+
+ /**
+ * Multiply the given matrix mat
with this vector, perform perspective division
+ * and store the result in dest
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulProjectGeneric(Matrix4fc mat, Vector3d dest);
+
+ /**
+ * Multiply the given matrix mat
with this vector, perform perspective division
+ * and store the result in dest
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulProjectGeneric(Matrix4dc mat, Vector3d dest);
+
+ /**
+ * Multiply the given matrix mat
with this vector, perform perspective division
+ * and store the result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only an affine transformation.
+ *
+ * This method uses w=1.0
as the fourth vector component.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulProjectAffine(Matrix4dc mat, Vector3d dest);
+
/**
* Multiply the given matrix mat
with this
and store the
* result in dest
.
@@ -610,8 +724,68 @@ public interface Vector3dc {
* Multiply the given 4x4 matrix mat
with this
and store the
* result in dest
.
*
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
* This method assumes the w
component of this
to be 1.0
.
- *
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionGeneric(Matrix4dc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x4 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes that the matrix mat
represents an affine transformation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionAffine(Matrix4dc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x4 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionTranslation(Matrix4dc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x4 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
* @param mat
* the matrix to multiply this vector by
* @param dest
@@ -620,6 +794,63 @@ public interface Vector3dc {
*/
Vector3d mulPosition(Matrix4fc mat, Vector3d dest);
+ /**
+ * Multiply the given 4x4 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionGeneric(Matrix4fc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x4 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes that the matrix mat
represents an affine transformation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionAffine(Matrix4fc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x4 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionTranslation(Matrix4fc mat, Vector3d dest);
+
/**
* Multiply the given 4x3 matrix mat
with this
and store the
* result in dest
.
@@ -641,8 +872,49 @@ public interface Vector3dc {
* Multiply the given 4x3 matrix mat
with this
and store the
* result in dest
.
*
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
* This method assumes the w
component of this
to be 1.0
.
- *
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionGeneric(Matrix4x3dc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x3 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionTranslation(Matrix4x3dc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x3 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
* @param mat
* the matrix to multiply this vector by
* @param dest
@@ -651,6 +923,44 @@ public interface Vector3dc {
*/
Vector3d mulPosition(Matrix4x3fc mat, Vector3d dest);
+ /**
+ * Multiply the given 4x3 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method makes no assumptions about the properties of the matrix mat
.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionGeneric(Matrix4x3fc mat, Vector3d dest);
+
+ /**
+ * Multiply the given 4x3 matrix mat
with this
and store the
+ * result in dest
.
+ *
+ * This method assumes that the matrix mat
represents only a translation.
+ *
+ * This method assumes the w
component of this
to be 1.0
.
+ *
+ * Note that this method performs the operation M * this
, where M
is the provided matrix
+ * and thus interprets this
as a column vector.
+ *
+ * @param mat
+ * the matrix to multiply this vector by
+ * @param dest
+ * will hold the result
+ * @return dest
+ */
+ Vector3d mulPositionTranslation(Matrix4x3fc mat, Vector3d dest);
+
/**
* Multiply the transpose of the given 4x4 matrix mat
with this
and store the
* result in dest
.