aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-19 06:11:35 +0100
committerSven Gothel <[email protected]>2023-03-19 06:11:35 +0100
commit603068a4e6af5293db10db73ead3a83b7a74af34 (patch)
treede6097189acfe6efe0e5ff51a9b9803bb7d91c56 /src/test/com
parentf8584748e33aab56780eca5cf7009a5a0d11991d (diff)
API doc cleanup, add + refine math tests
API doc
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary32NOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary64NOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01NOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java306
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject02NOUI.java125
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java96
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java3
13 files changed, 547 insertions, 11 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary32NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary32NOUI.java
index d2a9a92ce..ba59eddec 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary32NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary32NOUI.java
@@ -31,9 +31,10 @@ package com.jogamp.opengl.test.junit.jogl.math;
import org.junit.Assert;
import org.junit.Test;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.math.Binary32;
-public class TestBinary32NOUI
+public class TestBinary32NOUI extends JunitTracer
{
@SuppressWarnings("static-method") @Test public void testInfinityExponent()
{
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary64NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary64NOUI.java
index f16ea2bee..8e635f128 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary64NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary64NOUI.java
@@ -31,9 +31,10 @@ package com.jogamp.opengl.test.junit.jogl.math;
import org.junit.Assert;
import org.junit.Test;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.math.Binary64;
-public class TestBinary64NOUI
+public class TestBinary64NOUI extends JunitTracer
{
@SuppressWarnings("static-method") @Test public void testInfinityExponent()
{
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01NOUI.java
index 0d156c42c..909b94a90 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01NOUI.java
@@ -36,10 +36,11 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.math.FloatUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFloatUtil01NOUI {
+public class TestFloatUtil01NOUI extends JunitTracer {
static final float MACH_EPSILON = FloatUtil.getMachineEpsilon();
static boolean deltaMachEpsLEQEpsilon;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java
index 13285ac0b..72b4453c6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil02MatrixMatrixMultNOUI.java
@@ -33,10 +33,11 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.math.FloatUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFloatUtil02MatrixMatrixMultNOUI {
+public class TestFloatUtil02MatrixMatrixMultNOUI extends JunitTracer {
final float[] m1 = new float[]{ 1, 3, 4, 0,
6, 7, 8, 5,
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java
index a2aa69863..eaca73579 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil03InversionNOUI.java
@@ -34,10 +34,11 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.math.FloatUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFloatUtil03InversionNOUI {
+public class TestFloatUtil03InversionNOUI extends JunitTracer {
@Test
public void test01Ident(){
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java
new file mode 100644
index 000000000..05126676d
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject01NOUI.java
@@ -0,0 +1,306 @@
+/**
+ * Copyright 2014-2023 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.math;
+
+import java.util.Arrays;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.junit.util.JunitTracer;
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.glu.GLU;
+
+import jogamp.opengl.gl2.ProjectDouble;
+
+import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.util.PMVMatrix;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestFloatUtilProject01NOUI extends JunitTracer {
+
+ static final float epsilon = 0.00001f;
+
+ // Simple 10 x 10 view port
+ static final int[] viewport = new int[] { 0,0,10,10};
+
+ /**
+ * PMVMatrix FloatUtil.mapObjToWinCoords() w/ separate P + Mv, against FloatUtil.mapObjToWinCoords() w/ PMV
+ */
+ @Test
+ public void test01PMVMatrixToFloatUtil1() {
+ final float[] vec4Tmp1 = new float[4];
+ final float[] vec4Tmp2 = new float[4];
+
+ final float[] winA00 = new float[4];
+ final float[] winA01 = new float[4];
+ final float[] winA10 = new float[4];
+ final float[] winA11 = new float[4];
+ final float[] winB00 = new float[4];
+ final float[] winB01 = new float[4];
+ final float[] winB10 = new float[4];
+ final float[] winB11 = new float[4];
+
+ final PMVMatrix m = new PMVMatrix();
+ final float[] mat4PMv = new float[16];
+ m.multPMvMatrixf(mat4PMv, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */));
+
+ m.gluProject(1f, 0f, 0f, viewport, 0, winA00, 0);
+ System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4PMv, viewport, 0, winB00, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
+
+ m.gluProject(0f, 0f, 0f, viewport, 0, winA01, 0);
+ System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4PMv, viewport, 0, winB01, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.multPMvMatrixf(mat4PMv, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */));
+
+ m.gluProject(1f, 0f, 0f, viewport, 0, winA10, 0);
+ System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4PMv, viewport, 0, winB10, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
+
+ m.gluProject(0f, 0f, 0f, viewport, 0, winA11, 0);
+ System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4PMv, viewport, 0, winB11, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
+
+ Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon);
+ Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon);
+ Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon);
+ Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon);
+ }
+
+ /**
+ * Actually both using same FloatUtil.mapObjToWinCoords() w/ separate P + Mv
+ */
+ @Test
+ public void test01PMVMatrixToFloatUtil2() {
+ final float[] vec4Tmp1 = new float[4];
+ final float[] vec4Tmp2 = new float[4];
+
+ final float[] winA00 = new float[4];
+ final float[] winA01 = new float[4];
+ final float[] winA10 = new float[4];
+ final float[] winA11 = new float[4];
+ final float[] winB00 = new float[4];
+ final float[] winB01 = new float[4];
+ final float[] winB10 = new float[4];
+ final float[] winB11 = new float[4];
+
+ final PMVMatrix m = new PMVMatrix();
+ final float[] mat4Mv = new float[16];
+ final float[] mat4P = new float[16];
+
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
+
+ m.gluProject(1f, 0f, 0f, viewport, 0, winA00, 0);
+ System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB00, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
+
+ m.gluProject(0f, 0f, 0f, viewport, 0, winA01, 0);
+ System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB01, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
+
+ m.gluProject(1f, 0f, 0f, viewport, 0, winA10, 0);
+ System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB10, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
+
+ m.gluProject(0f, 0f, 0f, viewport, 0, winA11, 0);
+ System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB11, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
+
+ Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon);
+ Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon);
+ Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon);
+ Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon);
+ }
+
+ /**
+ * GLU ProjectFloat w/ same FloatUtil.mapObjToWinCoords() w/ separate P + Mv
+ */
+ @Test
+ public void test03GLUToFloatUtil2() {
+ final float[] vec4Tmp1 = new float[4];
+ final float[] vec4Tmp2 = new float[4];
+
+ final float[] winA00 = new float[4];
+ final float[] winA01 = new float[4];
+ final float[] winA10 = new float[4];
+ final float[] winA11 = new float[4];
+ final float[] winB00 = new float[4];
+ final float[] winB01 = new float[4];
+ final float[] winB10 = new float[4];
+ final float[] winB11 = new float[4];
+
+ final PMVMatrix m = new PMVMatrix();
+ final float[] mat4Mv = new float[16];
+ final float[] mat4P = new float[16];
+ final GLU glu = new GLU();
+
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
+
+ glu.gluProject(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA00, 0);
+ System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB00, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
+
+ glu.gluProject(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA01, 0);
+ System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB01, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
+
+ glu.gluProject(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA10, 0);
+ System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB10, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
+
+ glu.gluProject(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winA11, 0);
+ System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB11, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
+
+ Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon);
+ Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon);
+ Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon);
+ Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon);
+ }
+
+ /**
+ * GLU ProjectDouble against FloatUtil.mapObjToWinCoords() w/ separate P + Mv
+ */
+ @Test
+ public void test04GLUDoubleToFloatUtil2() {
+ final float[] vec4Tmp1 = new float[4];
+ final float[] vec4Tmp2 = new float[4];
+
+ final double[] winA00 = new double[4];
+ final double[] winA01 = new double[4];
+ final double[] winA10 = new double[4];
+ final double[] winA11 = new double[4];
+ final float[] winB00 = new float[4];
+ final float[] winB01 = new float[4];
+ final float[] winB10 = new float[4];
+ final float[] winB11 = new float[4];
+
+ final PMVMatrix m = new PMVMatrix();
+ final float[] mat4Mv = new float[16];
+ final float[] mat4P = new float[16];
+ final ProjectDouble glu = new ProjectDouble();
+
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
+ double[] d_mat4Mv = Buffers.getDoubleArray(mat4Mv, 0, null, 0, -1);
+ double[] d_mat4P = Buffers.getDoubleArray(mat4P, 0, null, 0, -1);
+
+ glu.gluProject(1f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA00, 0);
+ System.err.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB00, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winB00));
+
+ glu.gluProject(0f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA01, 0);
+ System.err.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB01, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.1 - Project 0,0 -->" + Arrays.toString(winB01));
+
+ m.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ m.glOrthof(0, 10, 0, 10, 1, -1);
+ System.err.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale");
+ System.err.println(m);
+ m.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, mat4Mv, 0);
+ m.glGetFloatv(GLMatrixFunc.GL_PROJECTION_MATRIX, mat4P, 0);
+ System.err.println(FloatUtil.matrixToString(null, "mat4Mv", "%10.5f", mat4Mv, 0, 4, 4, false /* rowMajorOrder */));
+ System.err.println(FloatUtil.matrixToString(null, "mat4P ", "%10.5f", mat4P, 0, 4, 4, false /* rowMajorOrder */));
+ d_mat4Mv = Buffers.getDoubleArray(mat4Mv, 0, null, 0, -1);
+ d_mat4P = Buffers.getDoubleArray(mat4P, 0, null, 0, -1);
+
+ glu.gluProject(1f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA10, 0);
+ System.err.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10));
+ FloatUtil.mapObjToWinCoords(1f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB10, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10));
+
+ glu.gluProject(0f, 0f, 0f, d_mat4Mv, 0, d_mat4P, 0, viewport, 0, winA11, 0);
+ System.err.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11));
+ FloatUtil.mapObjToWinCoords(0f, 0f, 0f, mat4Mv, 0, mat4P, 0, viewport, 0, winB11, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11));
+
+ double[] d_winBxx = Buffers.getDoubleArray(winB00, 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", d_winBxx, winA00, epsilon);
+ d_winBxx = Buffers.getDoubleArray(winB01, 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", d_winBxx, winA01, epsilon);
+ d_winBxx = Buffers.getDoubleArray(winB10, 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", d_winBxx, winA10, epsilon);
+ d_winBxx = Buffers.getDoubleArray(winB11, 0, null, 0, -1);
+ Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", d_winBxx, winA11, epsilon);
+ }
+
+ public static void main(final String args[]) {
+ org.junit.runner.JUnitCore.main(TestFloatUtilProject01NOUI.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject02NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject02NOUI.java
new file mode 100644
index 000000000..ed3f68f5d
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtilProject02NOUI.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2014-2023 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.math;
+
+import java.util.Arrays;
+
+import com.jogamp.junit.util.JunitTracer;
+
+import com.jogamp.opengl.math.FloatUtil;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestFloatUtilProject02NOUI extends JunitTracer {
+
+ static final float epsilon = 0.00001f;
+
+ @Test
+ public void test01FloatUtilProject() {
+ final float[] vec4Tmp1 = new float[4];
+ final float[] vec4Tmp2 = new float[4];
+
+ final float[] winHas = new float[3];
+ final int[] winExp = { 297, 360 };
+
+ final int[] viewport = new int[] { 0, 0, 1280, 720 };
+
+
+ final float[] mat4Mv = new float[] {
+ 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
+ -0.09278385341167450000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f
+ };
+ final float[] mat4P = new float[] {
+ 1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
+ 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f,
+ };
+
+ final float[] objPos = { 0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f };
+
+ System.err.println("pMv");
+ System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4Mv, 0, 4, 4, true /* rowMajorOrder */));
+ System.err.println("pP");
+ System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4P, 0, 4, 4, true/* rowMajorOrder */));
+
+ FloatUtil.mapObjToWinCoords(objPos[0], objPos[1], objPos[2], mat4Mv, 0, mat4P, 0, viewport, 0, winHas, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winHas));
+
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.x", winExp[0], Math.round(winHas[0]));
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.y", winExp[1], Math.round(winHas[1]));
+ }
+
+ @Test
+ public void test02GLUFloatUtil() {
+ final float[] vec4Tmp1 = new float[4];
+ final float[] vec4Tmp2 = new float[4];
+
+ final float[] winHas = new float[3];
+ final int[] winExp = { 136, 360 };
+
+ final int[] viewport = new int[] { 0, 0, 1280, 720 };
+
+
+ final float[] mat4Mv = new float[] {
+ 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
+ -0.13065303862094880000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f,
+ };
+ final float[] mat4P = new float[] {
+ 1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
+ 0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
+ 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f,
+ };
+
+ final float[] objPos = { 0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f };
+
+ System.err.println("pMv");
+ System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4Mv, 0, 4, 4, true /* rowMajorOrder */));
+ System.err.println("pP");
+ System.err.println(FloatUtil.matrixToString(null, "", "%25.20ff", mat4P, 0, 4, 4, true/* rowMajorOrder */));
+
+ FloatUtil.mapObjToWinCoords(objPos[0], objPos[1], objPos[2], mat4Mv, 0, mat4P, 0, viewport, 0, winHas, 0, vec4Tmp1, vec4Tmp2);
+ System.err.println("B.0.0 - Project 1,0 -->" + Arrays.toString(winHas));
+
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.x", winExp[0], Math.round(winHas[0]));
+ Assert.assertEquals("A/B 0.0 Project 1,0 failure.y", winExp[1], Math.round(winHas[1]));
+ }
+
+ public static void main(final String args[]) {
+ org.junit.runner.JUnitCore.main(TestFloatUtilProject02NOUI.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java
index 00a474b05..7d7ec47d6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java
@@ -28,6 +28,7 @@
package com.jogamp.opengl.test.junit.jogl.math;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.glu.GLU;
import org.junit.Assert;
@@ -39,7 +40,7 @@ import org.junit.runners.MethodSorters;
* @author Julien Gouesse
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGluUnprojectDoubleNOUI {
+public class TestGluUnprojectDoubleNOUI extends JunitTracer {
@Test
public void test(){
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java
index d0557ccc4..55df4bcd4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java
@@ -28,6 +28,7 @@
package com.jogamp.opengl.test.junit.jogl.math;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.glu.GLU;
import org.junit.Assert;
@@ -36,7 +37,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGluUnprojectFloatNOUI {
+public class TestGluUnprojectFloatNOUI extends JunitTracer {
@Test
public void testNaN(){
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java
index 78c66d927..d6a0beac6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java
@@ -34,7 +34,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import com.jogamp.opengl.util.PMVMatrix;
-
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import java.nio.FloatBuffer;
@@ -44,7 +44,7 @@ import static org.junit.Assert.assertArrayEquals;
* @author Thomas De Bodt
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestPMVMatrix02NOUI {
+public class TestPMVMatrix02NOUI extends JunitTracer {
private PMVMatrix fMat;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java
index f356a3678..63cb5b539 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java
@@ -2,6 +2,7 @@ package com.jogamp.opengl.test.junit.jogl.math;
import java.util.Arrays;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import jogamp.opengl.ProjectFloat;
@@ -15,7 +16,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestPMVMatrix03NOUI {
+public class TestPMVMatrix03NOUI extends JunitTracer {
static final float epsilon = 0.00001f;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java
new file mode 100644
index 000000000..a9bac4f48
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVTransform01NOUI.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright 2014-2023 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.math;
+
+import com.jogamp.junit.util.JunitTracer;
+
+import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.util.PMVMatrix;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestPMVTransform01NOUI extends JunitTracer {
+
+ static final float epsilon = 0.00001f;
+
+ @Test
+ public void test01() {
+ final PMVMatrix pmv = new PMVMatrix();
+ System.err.println(FloatUtil.matrixToString(null, "Ident ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
+
+ final float[] t = { 1f, 2f, 3f };
+ final float[] s = { 2f, 2f, 2f };
+
+ pmv.glTranslatef(t[0], t[1], t[2]);
+ System.err.println(FloatUtil.matrixToString(null, "Translate ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true/* rowMajorOrder */));
+ pmv.glScalef(s[0], s[1], s[2]);
+ System.err.println(FloatUtil.matrixToString(null, "Scale ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
+
+ final float[] exp = new float[] {
+ 2.00000f, 0.00000f, 0.00000f, 0.00000f,
+ 0.00000f, 2.00000f, 0.00000f, 0.00000f,
+ 0.00000f, 0.00000f, 2.00000f, 0.00000f,
+ 1.00000f, 2.00000f, 3.00000f, 1.00000f,
+ };
+ final float[] has = new float[16];
+ pmv.multPMvMatrixf(has, 0);
+ Assert.assertArrayEquals(exp, has, epsilon);
+ }
+
+ @Test
+ public void test02() {
+ final PMVMatrix pmv = new PMVMatrix();
+ System.err.println(FloatUtil.matrixToString(null, "Ident ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
+
+ final float[] t = { 1f, 2f, 3f };
+ final float[] s = { 2f, 2f, 2f };
+
+ pmv.glScalef(s[0], s[1], s[2]);
+ System.err.println(FloatUtil.matrixToString(null, "Scale ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true /* rowMajorOrder */));
+ pmv.glTranslatef(t[0], t[1], t[2]);
+ System.err.println(FloatUtil.matrixToString(null, "Translate ", "%7.5f", pmv.glGetMatrixf(), 0, 4, 4, true/* rowMajorOrder */));
+
+ final float[] exp = new float[] {
+ 2.00000f, 0.00000f, 0.00000f, 0.00000f,
+ 0.00000f, 2.00000f, 0.00000f, 0.00000f,
+ 0.00000f, 0.00000f, 2.00000f, 0.00000f,
+ 2.00000f, 4.00000f, 6.00000f, 1.00000f,
+ };
+ final float[] has = new float[16];
+ pmv.multPMvMatrixf(has, 0);
+ Assert.assertArrayEquals(exp, has, epsilon);
+ }
+
+ public static void main(final String args[]) {
+ org.junit.runner.JUnitCore.main(TestPMVTransform01NOUI.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java
index d6d7131fa..80d2e088f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestQuaternion01NOUI.java
@@ -35,12 +35,13 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Quaternion;
import com.jogamp.opengl.math.VectorUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestQuaternion01NOUI {
+public class TestQuaternion01NOUI extends JunitTracer {
static final boolean DEBUG = false;
static final Quaternion QUAT_IDENT = new Quaternion(0f, 0f, 0f, 1f);