Skip to content

Commit

Permalink
Add Matrix3.quadraticFormProduct() (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdigest committed Dec 28, 2020
1 parent a26ae03 commit 5a73b16
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/org/joml/Matrix3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -4707,4 +4707,19 @@ public boolean isFinite() {
Math.isFinite(m20) && Math.isFinite(m21) && Math.isFinite(m22);
}

public double quadraticFormProduct(double x, double y, double z) {
double Axx = m00 * x + m10 * y + m20 * z;
double Axy = m01 * x + m11 * y + m21 * z;
double Axz = m02 * x + m12 * y + m22 * z;
return x * Axx + y * Axy + z * Axz;
}

public double quadraticFormProduct(Vector3dc v) {
return quadraticFormProduct(v.x(), v.y(), v.z());
}

public double quadraticFormProduct(Vector3fc v) {
return quadraticFormProduct(v.x(), v.y(), v.z());
}

}
29 changes: 28 additions & 1 deletion src/org/joml/Matrix3dc.java
Original file line number Diff line number Diff line change
Expand Up @@ -1591,4 +1591,31 @@ public interface Matrix3dc {
*/
boolean isFinite();

}
/**
* Compute <code>(x, y, z)^T * this * (x, y, z)</code>.
*
* @param v
* the vector to multiply
* @return the result
*/
double quadraticFormProduct(double x, double y, double z);

/**
* Compute <code>v^T * this * v</code>.
*
* @param v
* the vector to multiply
* @return the result
*/
double quadraticFormProduct(Vector3dc v);

/**
* Compute <code>v^T * this * v</code>.
*
* @param v
* the vector to multiply
* @return the result
*/
double quadraticFormProduct(Vector3fc v);

}
11 changes: 11 additions & 0 deletions src/org/joml/Matrix3f.java
Original file line number Diff line number Diff line change
Expand Up @@ -4116,4 +4116,15 @@ public boolean isFinite() {
Math.isFinite(m20) && Math.isFinite(m21) && Math.isFinite(m22);
}

public float quadraticFormProduct(float x, float y, float z) {
float Axx = m00 * x + m10 * y + m20 * z;
float Axy = m01 * x + m11 * y + m21 * z;
float Axz = m02 * x + m12 * y + m22 * z;
return x * Axx + y * Axy + z * Axz;
}

public float quadraticFormProduct(Vector3fc v) {
return quadraticFormProduct(v.x(), v.y(), v.z());
}

}
18 changes: 18 additions & 0 deletions src/org/joml/Matrix3fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -1513,4 +1513,22 @@ public interface Matrix3fc {
*/
boolean isFinite();

/**
* Compute <code>v^T * this * v</code>.
*
* @param v
* the vector to multiply
* @return the result
*/
float quadraticFormProduct(Vector3fc v);

/**
* Compute <code>(x, y, z)^T * this * (x, y, z)</code>.
*
* @param v
* the vector to multiply
* @return the result
*/
float quadraticFormProduct(float x, float y, float z);

}

0 comments on commit 5a73b16

Please sign in to comment.