From dd67c91abd2e5f549fe35f590f37c5d6c732a100 Mon Sep 17 00:00:00 2001
From: Sven Göthel
* Frustum plane's normals will point to the inside of the viewing frustum,
* as required by the {@link Frustum} class.
*
* See Graphics Gems Code,
* MatrixTrace.
@@ -1003,9 +1003,9 @@ public class Quaternion {
*
* @return this quaternion for chaining.
* @see Matrix4f#getRotation(Quaternion)
- * @see #setFromMatrix(float, float, float, float, float, float, float, float, float)
+ * @see #setFromMat(float, float, float, float, float, float, float, float, float)
*/
- public Quaternion setFromMatrix(final Matrix4f m) {
+ public Quaternion setFromMat(final Matrix4f m) {
return m.getRotation(this);
}
@@ -1021,8 +1021,8 @@ public class Quaternion {
* @param matrix float[16] store for the resulting normalized column matrix 4x4
* @return the given matrix store
* @see Matrix-FAQ Q54
- * @see #setFromMatrix(Matrix4f)
- * @see #setFromMatrix(float, float, float, float, float, float, float, float, float)
+ * @see #setFromMat(Matrix4f)
+ * @see #setFromMat(float, float, float, float, float, float, float, float, float)
*/
public final float[] toMatrix(final float[] matrix) {
// pre-multiply scaled-reciprocal-magnitude to reduce multiplications
@@ -1086,7 +1086,7 @@ public class Quaternion {
* @param matrix store for the resulting normalized column matrix 4x4
* @return the given matrix store
* @see Matrix-FAQ Q54
- * @see #setFromMatrix(float, float, float, float, float, float, float, float, float)
+ * @see #setFromMat(float, float, float, float, float, float, float, float, float)
* @see Matrix4f#setToRotation(Quaternion)
*/
public final Matrix4f toMatrix(final Matrix4f matrix) {
@@ -1105,7 +1105,7 @@ public class Quaternion {
* @return this quaternion for chaining.
*/
public final Quaternion setFromAxes(final Vec3f xAxis, final Vec3f yAxis, final Vec3f zAxis) {
- return setFromMatrix(xAxis.x(), yAxis.x(), zAxis.x(),
+ return setFromMat(xAxis.x(), yAxis.x(), zAxis.x(),
xAxis.y(), yAxis.y(), zAxis.y(),
xAxis.z(), yAxis.z(), zAxis.z());
}
diff --git a/src/jogl/classes/com/jogamp/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/math/geom/Frustum.java
index 6efc2529c..7d35fab97 100644
--- a/src/jogl/classes/com/jogamp/math/geom/Frustum.java
+++ b/src/jogl/classes/com/jogamp/math/geom/Frustum.java
@@ -78,7 +78,7 @@ import com.jogamp.math.Vec4f;
*
*
@@ -357,26 +357,26 @@ public class Frustum { * @param fovDesc {@link Frustum} {@link FovDesc} * @return given matrix for chaining * @see Matrix4f#setToPerspective(FovHVHalves, float, float) - * @see Matrix4f#updateFrustumPlanes(Frustum) + * @see Matrix4f#getFrustum(Frustum) * @see Matrix4f#getFrustum(Frustum, FovDesc) */ public Matrix4f updateByFovDesc(final Matrix4f m, final FovDesc fovDesc) { m.setToPerspective(fovDesc.fovhv, fovDesc.zNear, fovDesc.zFar); - m.updateFrustumPlanes(this); + setFromMat(m); return m; } /** * Calculate the frustum planes in world coordinates - * using the passed premultiplied P*MV (column major order) matrix. + * using the passed column major order matrix, usually a projection (P) or premultiplied P*MV matrix. *
* Frustum plane's normals will point to the inside of the viewing frustum, * as required by this class. *
- * @see Matrix4f#updateFrustumPlanes(Frustum) + * @see Matrix4f#getFrustum(Frustum) */ - public Frustum updateFrustumPlanes(final Matrix4f pmv) { - return pmv.updateFrustumPlanes(this); + public Frustum setFromMat(final Matrix4f pmv) { + return pmv.getFrustum(this); } /** diff --git a/src/jogl/classes/com/jogamp/math/util/PMVMatrix4f.java b/src/jogl/classes/com/jogamp/math/util/PMVMatrix4f.java index 7d02904be..650289d1f 100644 --- a/src/jogl/classes/com/jogamp/math/util/PMVMatrix4f.java +++ b/src/jogl/classes/com/jogamp/math/util/PMVMatrix4f.java @@ -1259,7 +1259,7 @@ public class PMVMatrix4f { if( null == frustum ) { frustum = new Frustum(); } - getPMv().updateFrustumPlanes(frustum); + frustum.setFromMat(getPMv()); dirtyBits &= ~FRUSTUM; } return frustum; diff --git a/src/test/com/jogamp/opengl/test/junit/math/Matrix4fb.java b/src/test/com/jogamp/opengl/test/junit/math/Matrix4fb.java index 9a7d9f7ff..d76040904 100644 --- a/src/test/com/jogamp/opengl/test/junit/math/Matrix4fb.java +++ b/src/test/com/jogamp/opengl/test/junit/math/Matrix4fb.java @@ -1032,11 +1032,11 @@ public class Matrix4fb { * Returns the rotation [m[0+0*4] .. m[2+2*4]] fields converted to a Quaternion. * @param res resulting Quaternion * @return the resulting Quaternion for chaining. - * @see Quaternion#setFromMatrix(float, float, float, float, float, float, float, float, float) + * @see Quaternion#setFromMat(float, float, float, float, float, float, float, float, float) * @see #setToRotation(Quaternion) */ public final Quaternion getRotation(final Quaternion res) { - res.setFromMatrix(m[0+0*4], m[0+1*4], m[0+2*4], m[1+0*4], m[1+1*4], m[1+2*4], m[2+0*4], m[2+1*4], m[2+2*4]); + res.setFromMat(m[0+0*4], m[0+1*4], m[0+2*4], m[1+0*4], m[1+1*4], m[1+2*4], m[2+0*4], m[2+1*4], m[2+2*4]); return res; } diff --git a/src/test/com/jogamp/opengl/test/junit/math/TestQuaternion01NOUI.java b/src/test/com/jogamp/opengl/test/junit/math/TestQuaternion01NOUI.java index 8e4957d97..f13003175 100644 --- a/src/test/com/jogamp/opengl/test/junit/math/TestQuaternion01NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/math/TestQuaternion01NOUI.java @@ -309,7 +309,7 @@ public class TestQuaternion01NOUI extends JunitTracer { Assert.assertEquals( 0f, Math.abs( UNIT_Z.dist(vecHas) ), Quaternion.ALLOWED_DEVIANCE ); } mat1.getRotation(quat); - quat.setFromMatrix(mat1); + quat.setFromMat(mat1); quat.rotateVector(UNIT_Y, vecHas); // System.err.println("exp0 "+Arrays.toString(UNIT_Z)); // System.err.println("has0 "+Arrays.toString(vecHas)); @@ -388,7 +388,7 @@ public class TestQuaternion01NOUI extends JunitTracer { // System.err.println("has0 "+Arrays.toString(vecHas)); Assert.assertEquals( 0f, Math.abs( NEG_UNIT_Y.dist(vecHas) ), Quaternion.ALLOWED_DEVIANCE ); } - quat.setFromMatrix(mat1); + quat.setFromMat(mat1); quat.rotateVector(UNIT_Y, vecHas); // System.err.println("exp0 "+Arrays.toString(NEG_UNIT_Y)); // System.err.println("has0 "+Arrays.toString(vecHas)); @@ -423,7 +423,7 @@ public class TestQuaternion01NOUI extends JunitTracer { // System.err.println("has0 "+Arrays.toString(vecHas)); Assert.assertEquals( 0f, Math.abs( NEG_UNIT_X.dist(vecHas) ), Quaternion.ALLOWED_DEVIANCE ); } - quat.setFromMatrix(mat1); + quat.setFromMat(mat1); quat.rotateVector(UNIT_X, vecHas); // System.err.println("exp0 "+Arrays.toString(NEG_UNIT_X)); // System.err.println("has0 "+Arrays.toString(vecHas)); @@ -458,7 +458,7 @@ public class TestQuaternion01NOUI extends JunitTracer { // System.err.println("has0 "+Arrays.toString(vecHas)); Assert.assertEquals( 0f, Math.abs( NEG_UNIT_X.dist(vecHas) ), Quaternion.ALLOWED_DEVIANCE ); } - quat.setFromMatrix(mat1); + quat.setFromMat(mat1); quat.rotateVector(UNIT_X, vecHas); // System.err.println("exp0 "+Arrays.toString(NEG_UNIT_X)); // System.err.println("has0 "+Arrays.toString(vecHas)); @@ -517,7 +517,7 @@ public class TestQuaternion01NOUI extends JunitTracer { final Vec3f eulerHas = new Vec3f(); final Quaternion quat2 = new Quaternion(); - quat2.setFromMatrix(matExp1); + quat2.setFromMat(matExp1); quat2.toEuler(eulerHas); // System.err.println("exp-euler "+Arrays.toString(eulerExp)); // System.err.println("has-euler "+Arrays.toString(eulerHas)); @@ -546,7 +546,7 @@ public class TestQuaternion01NOUI extends JunitTracer { final Vec3f eulerHas = new Vec3f(); final Quaternion quat2 = new Quaternion(); - quat2.setFromMatrix(matExp); + quat2.setFromMat(matExp); quat2.toEuler(eulerHas); // System.err.println("exp-euler "+Arrays.toString(eulerExp)); // System.err.println("has-euler "+Arrays.toString(eulerHas)); @@ -578,7 +578,7 @@ public class TestQuaternion01NOUI extends JunitTracer { final Vec3f eulerHas1 = new Vec3f(); final Quaternion quat2 = new Quaternion(); - quat2.setFromMatrix(matExp); + quat2.setFromMat(matExp); quat2.toEuler(eulerHas1); // Vec3f if( DEBUG ) { System.err.println("PI"); @@ -789,7 +789,7 @@ public class TestQuaternion01NOUI extends JunitTracer { final Quaternion quat1 = new Quaternion().setFromAxes(xAxis, yAxis, zAxis); Assert.assertEquals(quat0, quat1); - final Quaternion quat2 = new Quaternion().setFromMatrix(rotMat); + final Quaternion quat2 = new Quaternion().setFromMat(rotMat); Assert.assertEquals(quat2, quat1); quat1.toAxes(xAxis, yAxis, zAxis, rotMat); @@ -889,12 +889,22 @@ public class TestQuaternion01NOUI extends JunitTracer { Assert.assertEquals(0f, direction.dist( quat.rotateVector(UNIT_Z, vecHas) ), Quaternion.ALLOWED_DEVIANCE); Assert.assertEquals(direction, vecHas); - if( DEBUG ) System.err.println("LookAt #02"); + if( DEBUG ) { + System.err.println("quat0.0 "+quat); + System.err.println("exp0 "+direction+", len "+direction.length()); + System.err.println("has0 "+vecHas+", len "+vecHas.length()); + System.err.println(); + System.err.println("LookAt #02"); + } direction.set(ONE).normalize(); quat.setLookAt(direction, UNIT_Y, xAxis, yAxis, zAxis); - if( DEBUG )System.err.println("quat0 "+quat); + if( DEBUG ) { + System.err.println("direction "+direction); + System.err.println("quat0.0 "+quat); + } quat.rotateVector(UNIT_Z, vecHas); if( DEBUG ) { + System.err.println("quat0.1 "+quat); System.err.println("xAxis "+xAxis+", len "+xAxis.length()); System.err.println("yAxis "+yAxis+", len "+yAxis.length()); System.err.println("zAxis "+zAxis+", len "+zAxis.length()); -- cgit v1.2.3