http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java index a2ebce8..a02ac26 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java @@ -23,7 +23,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.CardanEulerSingularity import org.apache.commons.math4.geometry.euclidean.threed.NotARotationMatrixException; import org.apache.commons.math4.geometry.euclidean.threed.Rotation; import org.apache.commons.math4.geometry.euclidean.threed.RotationOrder; -import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; +import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.MathUtils; import org.junit.Assert; @@ -36,21 +36,21 @@ public class RotationTest { public void testIdentity() { Rotation r = Rotation.IDENTITY; - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_I); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.PLUS_J); - checkVector(r.applyTo(Coordinates3D.PLUS_K), Coordinates3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_I); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.PLUS_J); + checkVector(r.applyTo(Cartesian3D.PLUS_K), Cartesian3D.PLUS_K); checkAngle(r.getAngle(), 0); r = new Rotation(-1, 0, 0, 0, false); - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_I); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.PLUS_J); - checkVector(r.applyTo(Coordinates3D.PLUS_K), Coordinates3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_I); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.PLUS_J); + checkVector(r.applyTo(Cartesian3D.PLUS_K), Cartesian3D.PLUS_K); checkAngle(r.getAngle(), 0); r = new Rotation(42, 0, 0, 0, true); - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_I); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.PLUS_J); - checkVector(r.applyTo(Coordinates3D.PLUS_K), Coordinates3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_I); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.PLUS_J); + checkVector(r.applyTo(Cartesian3D.PLUS_K), Cartesian3D.PLUS_K); checkAngle(r.getAngle(), 0); } @@ -59,95 +59,95 @@ public class RotationTest { @Deprecated public void testAxisAngleDeprecated() throws MathIllegalArgumentException { - Rotation r = new Rotation(new Coordinates3D(10, 10, 10), 2 * FastMath.PI / 3); - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_J); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.PLUS_K); - checkVector(r.applyTo(Coordinates3D.PLUS_K), Coordinates3D.PLUS_I); + Rotation r = new Rotation(new Cartesian3D(10, 10, 10), 2 * FastMath.PI / 3); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_J); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_K), Cartesian3D.PLUS_I); double s = 1 / FastMath.sqrt(3); - checkVector(r.getAxis(), new Coordinates3D(s, s, s)); + checkVector(r.getAxis(), new Cartesian3D(s, s, s)); checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new Rotation(new Coordinates3D(0, 0, 0), 2 * FastMath.PI / 3); + new Rotation(new Cartesian3D(0, 0, 0), 2 * FastMath.PI / 3); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new Rotation(Coordinates3D.PLUS_K, 1.5 * FastMath.PI); - checkVector(r.getAxis(), new Coordinates3D(0, 0, -1)); + r = new Rotation(Cartesian3D.PLUS_K, 1.5 * FastMath.PI); + checkVector(r.getAxis(), new Cartesian3D(0, 0, -1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new Rotation(Coordinates3D.PLUS_J, FastMath.PI); - checkVector(r.getAxis(), Coordinates3D.PLUS_J); + r = new Rotation(Cartesian3D.PLUS_J, FastMath.PI); + checkVector(r.getAxis(), Cartesian3D.PLUS_J); checkAngle(r.getAngle(), FastMath.PI); - checkVector(Rotation.IDENTITY.getAxis(), Coordinates3D.PLUS_I); + checkVector(Rotation.IDENTITY.getAxis(), Cartesian3D.PLUS_I); } @Test public void testAxisAngleVectorOperator() throws MathIllegalArgumentException { - Rotation r = new Rotation(new Coordinates3D(10, 10, 10), 2 * FastMath.PI / 3, RotationConvention.VECTOR_OPERATOR); - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_J); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.PLUS_K); - checkVector(r.applyTo(Coordinates3D.PLUS_K), Coordinates3D.PLUS_I); + Rotation r = new Rotation(new Cartesian3D(10, 10, 10), 2 * FastMath.PI / 3, RotationConvention.VECTOR_OPERATOR); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_J); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_K), Cartesian3D.PLUS_I); double s = 1 / FastMath.sqrt(3); - checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Coordinates3D( s, s, s)); - checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Coordinates3D(-s, -s, -s)); + checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Cartesian3D( s, s, s)); + checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Cartesian3D(-s, -s, -s)); checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new Rotation(new Coordinates3D(0, 0, 0), 2 * FastMath.PI / 3, RotationConvention.VECTOR_OPERATOR); + new Rotation(new Cartesian3D(0, 0, 0), 2 * FastMath.PI / 3, RotationConvention.VECTOR_OPERATOR); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new Rotation(Coordinates3D.PLUS_K, 1.5 * FastMath.PI, RotationConvention.VECTOR_OPERATOR); - checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Coordinates3D(0, 0, -1)); - checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Coordinates3D(0, 0, +1)); + r = new Rotation(Cartesian3D.PLUS_K, 1.5 * FastMath.PI, RotationConvention.VECTOR_OPERATOR); + checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Cartesian3D(0, 0, -1)); + checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Cartesian3D(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new Rotation(Coordinates3D.PLUS_J, FastMath.PI, RotationConvention.VECTOR_OPERATOR); - checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Coordinates3D.PLUS_J); - checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Coordinates3D.MINUS_J); + r = new Rotation(Cartesian3D.PLUS_J, FastMath.PI, RotationConvention.VECTOR_OPERATOR); + checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Cartesian3D.PLUS_J); + checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Cartesian3D.MINUS_J); checkAngle(r.getAngle(), FastMath.PI); - checkVector(Rotation.IDENTITY.getAxis(RotationConvention.VECTOR_OPERATOR), Coordinates3D.PLUS_I); - checkVector(Rotation.IDENTITY.getAxis(RotationConvention.FRAME_TRANSFORM), Coordinates3D.MINUS_I); + checkVector(Rotation.IDENTITY.getAxis(RotationConvention.VECTOR_OPERATOR), Cartesian3D.PLUS_I); + checkVector(Rotation.IDENTITY.getAxis(RotationConvention.FRAME_TRANSFORM), Cartesian3D.MINUS_I); } @Test public void testAxisAngleFrameTransform() throws MathIllegalArgumentException { - Rotation r = new Rotation(new Coordinates3D(10, 10, 10), 2 * FastMath.PI / 3, RotationConvention.FRAME_TRANSFORM); - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_K); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.PLUS_I); - checkVector(r.applyTo(Coordinates3D.PLUS_K), Coordinates3D.PLUS_J); + Rotation r = new Rotation(new Cartesian3D(10, 10, 10), 2 * FastMath.PI / 3, RotationConvention.FRAME_TRANSFORM); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.PLUS_I); + checkVector(r.applyTo(Cartesian3D.PLUS_K), Cartesian3D.PLUS_J); double s = 1 / FastMath.sqrt(3); - checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Coordinates3D( s, s, s)); - checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Coordinates3D(-s, -s, -s)); + checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Cartesian3D( s, s, s)); + checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Cartesian3D(-s, -s, -s)); checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new Rotation(new Coordinates3D(0, 0, 0), 2 * FastMath.PI / 3, RotationConvention.FRAME_TRANSFORM); + new Rotation(new Cartesian3D(0, 0, 0), 2 * FastMath.PI / 3, RotationConvention.FRAME_TRANSFORM); Assert.fail("an exception should have been thrown"); } catch (MathIllegalArgumentException e) { } - r = new Rotation(Coordinates3D.PLUS_K, 1.5 * FastMath.PI, RotationConvention.FRAME_TRANSFORM); - checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Coordinates3D(0, 0, -1)); - checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Coordinates3D(0, 0, +1)); + r = new Rotation(Cartesian3D.PLUS_K, 1.5 * FastMath.PI, RotationConvention.FRAME_TRANSFORM); + checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Cartesian3D(0, 0, -1)); + checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Cartesian3D(0, 0, +1)); checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new Rotation(Coordinates3D.PLUS_J, FastMath.PI, RotationConvention.FRAME_TRANSFORM); - checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Coordinates3D.PLUS_J); - checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Coordinates3D.MINUS_J); + r = new Rotation(Cartesian3D.PLUS_J, FastMath.PI, RotationConvention.FRAME_TRANSFORM); + checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Cartesian3D.PLUS_J); + checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Cartesian3D.MINUS_J); checkAngle(r.getAngle(), FastMath.PI); - checkVector(Rotation.IDENTITY.getAxis(RotationConvention.FRAME_TRANSFORM), Coordinates3D.MINUS_I); - checkVector(Rotation.IDENTITY.getAxis(RotationConvention.VECTOR_OPERATOR), Coordinates3D.PLUS_I); + checkVector(Rotation.IDENTITY.getAxis(RotationConvention.FRAME_TRANSFORM), Cartesian3D.MINUS_I); + checkVector(Rotation.IDENTITY.getAxis(RotationConvention.VECTOR_OPERATOR), Cartesian3D.PLUS_I); } @@ -159,7 +159,7 @@ public class RotationTest { checkRotation(reverted.applyTo(r), 1, 0, 0, 0); Assert.assertEquals(r.getAngle(), reverted.getAngle(), 1.0e-12); Assert.assertEquals(-1, - Coordinates3D.dotProduct(r.getAxis(RotationConvention.VECTOR_OPERATOR), + Cartesian3D.dotProduct(r.getAxis(RotationConvention.VECTOR_OPERATOR), reverted.getAxis(RotationConvention.VECTOR_OPERATOR)), 1.0e-12); } @@ -172,7 +172,7 @@ public class RotationTest { checkRotation(reverted.compose(r, RotationConvention.VECTOR_OPERATOR), 1, 0, 0, 0); Assert.assertEquals(r.getAngle(), reverted.getAngle(), 1.0e-12); Assert.assertEquals(-1, - Coordinates3D.dotProduct(r.getAxis(RotationConvention.VECTOR_OPERATOR), + Cartesian3D.dotProduct(r.getAxis(RotationConvention.VECTOR_OPERATOR), reverted.getAxis(RotationConvention.VECTOR_OPERATOR)), 1.0e-12); } @@ -185,7 +185,7 @@ public class RotationTest { checkRotation(reverted.compose(r, RotationConvention.FRAME_TRANSFORM), 1, 0, 0, 0); Assert.assertEquals(r.getAngle(), reverted.getAngle(), 1.0e-12); Assert.assertEquals(-1, - Coordinates3D.dotProduct(r.getAxis(RotationConvention.FRAME_TRANSFORM), + Cartesian3D.dotProduct(r.getAxis(RotationConvention.FRAME_TRANSFORM), reverted.getAxis(RotationConvention.FRAME_TRANSFORM)), 1.0e-12); } @@ -193,15 +193,15 @@ public class RotationTest { @Test public void testVectorOnePair() throws MathArithmeticException { - Coordinates3D u = new Coordinates3D(3, 2, 1); - Coordinates3D v = new Coordinates3D(-4, 2, 2); + Cartesian3D u = new Cartesian3D(3, 2, 1); + Cartesian3D v = new Cartesian3D(-4, 2, 2); Rotation r = new Rotation(u, v); checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm())); checkAngle(new Rotation(u, u.negate()).getAngle(), FastMath.PI); try { - new Rotation(u, Coordinates3D.ZERO); + new Rotation(u, Cartesian3D.ZERO); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -212,36 +212,36 @@ public class RotationTest { @Test public void testVectorTwoPairs() throws MathArithmeticException { - Coordinates3D u1 = new Coordinates3D(3, 0, 0); - Coordinates3D u2 = new Coordinates3D(0, 5, 0); - Coordinates3D v1 = new Coordinates3D(0, 0, 2); - Coordinates3D v2 = new Coordinates3D(-2, 0, 2); + Cartesian3D u1 = new Cartesian3D(3, 0, 0); + Cartesian3D u2 = new Cartesian3D(0, 5, 0); + Cartesian3D v1 = new Cartesian3D(0, 0, 2); + Cartesian3D v2 = new Cartesian3D(-2, 0, 2); Rotation r = new Rotation(u1, u2, v1, v2); - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_K); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.MINUS_I); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.MINUS_I); r = new Rotation(u1, u2, u1.negate(), u2.negate()); - Coordinates3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR); - if (Coordinates3D.dotProduct(axis, Coordinates3D.PLUS_K) > 0) { - checkVector(axis, Coordinates3D.PLUS_K); + Cartesian3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR); + if (Cartesian3D.dotProduct(axis, Cartesian3D.PLUS_K) > 0) { + checkVector(axis, Cartesian3D.PLUS_K); } else { - checkVector(axis, Coordinates3D.MINUS_K); + checkVector(axis, Cartesian3D.MINUS_K); } checkAngle(r.getAngle(), FastMath.PI); double sqrt = FastMath.sqrt(2) / 2; - r = new Rotation(Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, - new Coordinates3D(0.5, 0.5, sqrt), - new Coordinates3D(0.5, 0.5, -sqrt)); + r = new Rotation(Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, + new Cartesian3D(0.5, 0.5, sqrt), + new Cartesian3D(0.5, 0.5, -sqrt)); checkRotation(r, sqrt, 0.5, 0.5, 0); - r = new Rotation(u1, u2, u1, Coordinates3D.crossProduct(u1, u2)); + r = new Rotation(u1, u2, u1, Cartesian3D.crossProduct(u1, u2)); checkRotation(r, sqrt, -sqrt, 0, 0); checkRotation(new Rotation(u1, u2, u1, u2), 1, 0, 0, 0); try { - new Rotation(u1, u2, Coordinates3D.ZERO, v2); + new Rotation(u1, u2, Cartesian3D.ZERO, v2); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException e) { // expected behavior @@ -317,9 +317,9 @@ public class RotationTest { { 0.0, 0.0, 1.0 }, { 1.0, 0.0, 0.0 } }; Rotation r = new Rotation(m1, 1.0e-7); - checkVector(r.applyTo(Coordinates3D.PLUS_I), Coordinates3D.PLUS_K); - checkVector(r.applyTo(Coordinates3D.PLUS_J), Coordinates3D.PLUS_I); - checkVector(r.applyTo(Coordinates3D.PLUS_K), Coordinates3D.PLUS_J); + checkVector(r.applyTo(Cartesian3D.PLUS_I), Cartesian3D.PLUS_K); + checkVector(r.applyTo(Cartesian3D.PLUS_J), Cartesian3D.PLUS_I); + checkVector(r.applyTo(Cartesian3D.PLUS_K), Cartesian3D.PLUS_J); double[][] m2 = { { 0.83203, -0.55012, -0.07139 }, { 0.48293, 0.78164, -0.39474 }, @@ -370,12 +370,12 @@ public class RotationTest { } } - checkVector(r.applyTo(Coordinates3D.PLUS_I), - new Coordinates3D(m3[0][0], m3[1][0], m3[2][0])); - checkVector(r.applyTo(Coordinates3D.PLUS_J), - new Coordinates3D(m3[0][1], m3[1][1], m3[2][1])); - checkVector(r.applyTo(Coordinates3D.PLUS_K), - new Coordinates3D(m3[0][2], m3[1][2], m3[2][2])); + checkVector(r.applyTo(Cartesian3D.PLUS_I), + new Cartesian3D(m3[0][0], m3[1][0], m3[2][0])); + checkVector(r.applyTo(Cartesian3D.PLUS_J), + new Cartesian3D(m3[0][1], m3[1][1], m3[2][1])); + checkVector(r.applyTo(Cartesian3D.PLUS_K), + new Cartesian3D(m3[0][2], m3[1][2], m3[2][2])); double[][] m4 = { { 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, @@ -535,7 +535,7 @@ public class RotationTest { @Test public void testQuaternion() throws MathIllegalArgumentException { - Rotation r1 = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); + Rotation r1 = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); double n = 23.5; Rotation r2 = new Rotation(n * r1.getQ0(), n * r1.getQ1(), n * r1.getQ2(), n * r1.getQ3(), @@ -543,7 +543,7 @@ public class RotationTest { for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); + Cartesian3D u = new Cartesian3D(x, y, z); checkVector(r2.applyTo(u), r1.applyTo(u)); } } @@ -557,14 +557,14 @@ public class RotationTest { @Test public void testApplyTo() throws MathIllegalArgumentException { - Rotation r1 = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); - Rotation r2 = new Rotation(new Coordinates3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); + Rotation r1 = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); + Rotation r2 = new Rotation(new Cartesian3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); Rotation r3 = r2.applyTo(r1); for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); + Cartesian3D u = new Cartesian3D(x, y, z); checkVector(r2.applyTo(r1.applyTo(u)), r3.applyTo(u)); } } @@ -575,14 +575,14 @@ public class RotationTest { @Test public void testComposeVectorOperator() throws MathIllegalArgumentException { - Rotation r1 = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); - Rotation r2 = new Rotation(new Coordinates3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); + Rotation r1 = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); + Rotation r2 = new Rotation(new Cartesian3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); Rotation r3 = r2.compose(r1, RotationConvention.VECTOR_OPERATOR); for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); + Cartesian3D u = new Cartesian3D(x, y, z); checkVector(r2.applyTo(r1.applyTo(u)), r3.applyTo(u)); } } @@ -593,8 +593,8 @@ public class RotationTest { @Test public void testComposeFrameTransform() throws MathIllegalArgumentException { - Rotation r1 = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM); - Rotation r2 = new Rotation(new Coordinates3D(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM); + Rotation r1 = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM); + Rotation r2 = new Rotation(new Cartesian3D(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM); Rotation r3 = r2.compose(r1, RotationConvention.FRAME_TRANSFORM); Rotation r4 = r1.compose(r2, RotationConvention.VECTOR_OPERATOR); Assert.assertEquals(0.0, Rotation.distance(r3, r4), 1.0e-15); @@ -602,7 +602,7 @@ public class RotationTest { for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); + Cartesian3D u = new Cartesian3D(x, y, z); checkVector(r1.applyTo(r2.applyTo(u)), r3.applyTo(u)); } } @@ -613,14 +613,14 @@ public class RotationTest { @Test public void testApplyInverseToRotation() throws MathIllegalArgumentException { - Rotation r1 = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); - Rotation r2 = new Rotation(new Coordinates3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); + Rotation r1 = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); + Rotation r2 = new Rotation(new Cartesian3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); Rotation r3 = r2.applyInverseTo(r1); for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); + Cartesian3D u = new Cartesian3D(x, y, z); checkVector(r2.applyInverseTo(r1.applyTo(u)), r3.applyTo(u)); } } @@ -631,14 +631,14 @@ public class RotationTest { @Test public void testComposeInverseVectorOperator() throws MathIllegalArgumentException { - Rotation r1 = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); - Rotation r2 = new Rotation(new Coordinates3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); + Rotation r1 = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); + Rotation r2 = new Rotation(new Cartesian3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR); Rotation r3 = r2.composeInverse(r1, RotationConvention.VECTOR_OPERATOR); for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); + Cartesian3D u = new Cartesian3D(x, y, z); checkVector(r2.applyInverseTo(r1.applyTo(u)), r3.applyTo(u)); } } @@ -649,8 +649,8 @@ public class RotationTest { @Test public void testComposeInverseFrameTransform() throws MathIllegalArgumentException { - Rotation r1 = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM); - Rotation r2 = new Rotation(new Coordinates3D(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM); + Rotation r1 = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM); + Rotation r2 = new Rotation(new Cartesian3D(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM); Rotation r3 = r2.composeInverse(r1, RotationConvention.FRAME_TRANSFORM); Rotation r4 = r1.revert().composeInverse(r2.revert(), RotationConvention.VECTOR_OPERATOR); Assert.assertEquals(0.0, Rotation.distance(r3, r4), 1.0e-15); @@ -658,7 +658,7 @@ public class RotationTest { for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); + Cartesian3D u = new Cartesian3D(x, y, z); checkVector(r1.applyTo(r2.applyInverseTo(u)), r3.applyTo(u)); } } @@ -669,13 +669,13 @@ public class RotationTest { @Test public void testArray() throws MathIllegalArgumentException { - Rotation r = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); + Rotation r = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { for (double z = -0.9; z < 0.9; z += 0.2) { - Coordinates3D u = new Coordinates3D(x, y, z); - Coordinates3D v = r.applyTo(u); + Cartesian3D u = new Cartesian3D(x, y, z); + Cartesian3D v = r.applyTo(u); double[] inOut = new double[] { x, y, z }; r.applyTo(inOut, inOut); Assert.assertEquals(v.getX(), inOut[0], 1.0e-10); @@ -694,10 +694,10 @@ public class RotationTest { @Test public void testApplyInverseTo() throws MathIllegalArgumentException { - Rotation r = new Rotation(new Coordinates3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); + Rotation r = new Rotation(new Cartesian3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { - Coordinates3D u = new Coordinates3D(FastMath.cos(lambda) * FastMath.cos(phi), + Cartesian3D u = new Cartesian3D(FastMath.cos(lambda) * FastMath.cos(phi), FastMath.sin(lambda) * FastMath.cos(phi), FastMath.sin(phi)); r.applyInverseTo(r.applyTo(u)); @@ -709,7 +709,7 @@ public class RotationTest { r = Rotation.IDENTITY; for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { - Coordinates3D u = new Coordinates3D(FastMath.cos(lambda) * FastMath.cos(phi), + Cartesian3D u = new Cartesian3D(FastMath.cos(lambda) * FastMath.cos(phi), FastMath.sin(lambda) * FastMath.cos(phi), FastMath.sin(phi)); checkVector(u, r.applyInverseTo(r.applyTo(u))); @@ -717,10 +717,10 @@ public class RotationTest { } } - r = new Rotation(Coordinates3D.PLUS_K, FastMath.PI, RotationConvention.VECTOR_OPERATOR); + r = new Rotation(Cartesian3D.PLUS_K, FastMath.PI, RotationConvention.VECTOR_OPERATOR); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { - Coordinates3D u = new Coordinates3D(FastMath.cos(lambda) * FastMath.cos(phi), + Cartesian3D u = new Cartesian3D(FastMath.cos(lambda) * FastMath.cos(phi), FastMath.sin(lambda) * FastMath.cos(phi), FastMath.sin(phi)); checkVector(u, r.applyInverseTo(r.applyTo(u))); @@ -732,13 +732,13 @@ public class RotationTest { @Test public void testIssue639() throws MathArithmeticException{ - Coordinates3D u1 = new Coordinates3D(-1321008684645961.0 / 268435456.0, + Cartesian3D u1 = new Cartesian3D(-1321008684645961.0 / 268435456.0, -5774608829631843.0 / 268435456.0, -3822921525525679.0 / 4294967296.0); - Coordinates3D u2 =new Coordinates3D( -5712344449280879.0 / 2097152.0, + Cartesian3D u2 =new Cartesian3D( -5712344449280879.0 / 2097152.0, -2275058564560979.0 / 1048576.0, 4423475992255071.0 / 65536.0); - Rotation rot = new Rotation(u1, u2, Coordinates3D.PLUS_I,Coordinates3D.PLUS_K); + Rotation rot = new Rotation(u1, u2, Cartesian3D.PLUS_I,Cartesian3D.PLUS_K); Assert.assertEquals( 0.6228370359608200639829222, rot.getQ0(), 1.0e-15); Assert.assertEquals( 0.0257707621456498790029987, rot.getQ1(), 1.0e-15); Assert.assertEquals(-0.0000000002503012255839931, rot.getQ2(), 1.0e-15); @@ -747,11 +747,11 @@ public class RotationTest { @Test public void testIssue801() throws MathArithmeticException { - Coordinates3D u1 = new Coordinates3D(0.9999988431610581, -0.0015210774290851095, 0.0); - Coordinates3D u2 = new Coordinates3D(0.0, 0.0, 1.0); + Cartesian3D u1 = new Cartesian3D(0.9999988431610581, -0.0015210774290851095, 0.0); + Cartesian3D u2 = new Cartesian3D(0.0, 0.0, 1.0); - Coordinates3D v1 = new Coordinates3D(0.9999999999999999, 0.0, 0.0); - Coordinates3D v2 = new Coordinates3D(0.0, 0.0, -1.0); + Cartesian3D v1 = new Cartesian3D(0.9999999999999999, 0.0, 0.0); + Cartesian3D v2 = new Cartesian3D(0.0, 0.0, -1.0); Rotation quat = new Rotation(u1, u2, v1, v2); double q2 = quat.getQ0() * quat.getQ0() + @@ -759,8 +759,8 @@ public class RotationTest { quat.getQ2() * quat.getQ2() + quat.getQ3() * quat.getQ3(); Assert.assertEquals(1.0, q2, 1.0e-14); - Assert.assertEquals(0.0, Coordinates3D.angle(v1, quat.applyTo(u1)), 1.0e-14); - Assert.assertEquals(0.0, Coordinates3D.angle(v2, quat.applyTo(u2)), 1.0e-14); + Assert.assertEquals(0.0, Cartesian3D.angle(v1, quat.applyTo(u1)), 1.0e-14); + Assert.assertEquals(0.0, Cartesian3D.angle(v2, quat.applyTo(u2)), 1.0e-14); } @@ -770,13 +770,13 @@ public class RotationTest { final double xRotation = FastMath.toDegrees(30); final double yRotation = FastMath.toDegrees(20); final double zRotation = FastMath.toDegrees(10); - final Coordinates3D startingVector = Coordinates3D.PLUS_I; - Coordinates3D appliedIndividually = startingVector; + final Cartesian3D startingVector = Cartesian3D.PLUS_I; + Cartesian3D appliedIndividually = startingVector; appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, zRotation, 0, 0).applyTo(appliedIndividually); appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, yRotation, 0).applyTo(appliedIndividually); appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, 0, xRotation).applyTo(appliedIndividually); - final Coordinates3D bad = new Rotation(order, RotationConvention.FRAME_TRANSFORM, zRotation, yRotation, xRotation).applyTo(startingVector); + final Cartesian3D bad = new Rotation(order, RotationConvention.FRAME_TRANSFORM, zRotation, yRotation, xRotation).applyTo(startingVector); Assert.assertEquals(bad.getX(), appliedIndividually.getX(), 1e-12); Assert.assertEquals(bad.getY(), appliedIndividually.getY(), 1e-12); @@ -789,8 +789,8 @@ public class RotationTest { final double xRotation = FastMath.toDegrees(30); final double yRotation = FastMath.toDegrees(20); final double zRotation = FastMath.toDegrees(10); - final Coordinates3D startingVector = Coordinates3D.PLUS_I; - Coordinates3D appliedIndividually = startingVector; + final Cartesian3D startingVector = Cartesian3D.PLUS_I; + Cartesian3D appliedIndividually = startingVector; appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, zRotation, 0, 0).applyTo(appliedIndividually); appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, yRotation, 0).applyTo(appliedIndividually); appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, 0, xRotation).applyTo(appliedIndividually); @@ -801,14 +801,14 @@ public class RotationTest { final Rotation composite = r1.compose(r2.compose(r3, RotationConvention.FRAME_TRANSFORM), RotationConvention.FRAME_TRANSFORM); - final Coordinates3D good = composite.applyTo(startingVector); + final Cartesian3D good = composite.applyTo(startingVector); Assert.assertEquals(good.getX(), appliedIndividually.getX(), 1e-12); Assert.assertEquals(good.getY(), appliedIndividually.getY(), 1e-12); Assert.assertEquals(good.getZ(), appliedIndividually.getZ(), 1e-12); } - private void checkVector(Coordinates3D v1, Coordinates3D v2) { + private void checkVector(Cartesian3D v1, Cartesian3D v2) { Assert.assertTrue(v1.subtract(v2).getNorm() < 1.0e-10); }
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java index cae331b..ec920b3 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGeneratorTest.java @@ -23,7 +23,7 @@ import java.util.List; import org.apache.commons.math4.geometry.enclosing.EnclosingBall; import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D; import org.apache.commons.math4.geometry.euclidean.threed.SphereGenerator; -import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; +import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D; import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; @@ -36,8 +36,8 @@ public class SphereGeneratorTest { @Test public void testSupport0Point() { - List<Coordinates3D> support = Arrays.asList(new Coordinates3D[0]); - EnclosingBall<Euclidean3D, Coordinates3D> sphere = new SphereGenerator().ballOnSupport(support); + List<Cartesian3D> support = Arrays.asList(new Cartesian3D[0]); + EnclosingBall<Euclidean3D, Cartesian3D> sphere = new SphereGenerator().ballOnSupport(support); Assert.assertTrue(sphere.getRadius() < 0); Assert.assertEquals(0, sphere.getSupportSize()); Assert.assertEquals(0, sphere.getSupport().length); @@ -45,16 +45,16 @@ public class SphereGeneratorTest { @Test public void testSupport1Point() { - List<Coordinates3D> support = Arrays.asList(new Coordinates3D(1, 2, 3)); - EnclosingBall<Euclidean3D, Coordinates3D> sphere = new SphereGenerator().ballOnSupport(support); + List<Cartesian3D> support = Arrays.asList(new Cartesian3D(1, 2, 3)); + EnclosingBall<Euclidean3D, Cartesian3D> sphere = new SphereGenerator().ballOnSupport(support); Assert.assertEquals(0.0, sphere.getRadius(), 1.0e-10); Assert.assertTrue(sphere.contains(support.get(0))); Assert.assertTrue(sphere.contains(support.get(0), 0.5)); - Assert.assertFalse(sphere.contains(new Coordinates3D(support.get(0).getX() + 0.1, + Assert.assertFalse(sphere.contains(new Cartesian3D(support.get(0).getX() + 0.1, support.get(0).getY() + 0.1, support.get(0).getZ() + 0.1), 0.001)); - Assert.assertTrue(sphere.contains(new Coordinates3D(support.get(0).getX() + 0.1, + Assert.assertTrue(sphere.contains(new Cartesian3D(support.get(0).getX() + 0.1, support.get(0).getY() + 0.1, support.get(0).getZ() + 0.1), 0.5)); @@ -65,73 +65,73 @@ public class SphereGeneratorTest { @Test public void testSupport2Points() { - List<Coordinates3D> support = Arrays.asList(new Coordinates3D(1, 0, 0), - new Coordinates3D(3, 0, 0)); - EnclosingBall<Euclidean3D, Coordinates3D> sphere = new SphereGenerator().ballOnSupport(support); + List<Cartesian3D> support = Arrays.asList(new Cartesian3D(1, 0, 0), + new Cartesian3D(3, 0, 0)); + EnclosingBall<Euclidean3D, Cartesian3D> sphere = new SphereGenerator().ballOnSupport(support); Assert.assertEquals(1.0, sphere.getRadius(), 1.0e-10); int i = 0; - for (Coordinates3D v : support) { + for (Cartesian3D v : support) { Assert.assertTrue(sphere.contains(v)); Assert.assertEquals(1.0, v.distance(sphere.getCenter()), 1.0e-10); Assert.assertTrue(v == sphere.getSupport()[i++]); } - Assert.assertTrue(sphere.contains(new Coordinates3D(2, 0.9, 0))); - Assert.assertFalse(sphere.contains(Coordinates3D.ZERO)); - Assert.assertEquals(0.0, new Coordinates3D(2, 0, 0).distance(sphere.getCenter()), 1.0e-10); + Assert.assertTrue(sphere.contains(new Cartesian3D(2, 0.9, 0))); + Assert.assertFalse(sphere.contains(Cartesian3D.ZERO)); + Assert.assertEquals(0.0, new Cartesian3D(2, 0, 0).distance(sphere.getCenter()), 1.0e-10); Assert.assertEquals(2, sphere.getSupportSize()); } @Test public void testSupport3Points() { - List<Coordinates3D> support = Arrays.asList(new Coordinates3D(1, 0, 0), - new Coordinates3D(3, 0, 0), - new Coordinates3D(2, 2, 0)); - EnclosingBall<Euclidean3D, Coordinates3D> sphere = new SphereGenerator().ballOnSupport(support); + List<Cartesian3D> support = Arrays.asList(new Cartesian3D(1, 0, 0), + new Cartesian3D(3, 0, 0), + new Cartesian3D(2, 2, 0)); + EnclosingBall<Euclidean3D, Cartesian3D> sphere = new SphereGenerator().ballOnSupport(support); Assert.assertEquals(5.0 / 4.0, sphere.getRadius(), 1.0e-10); int i = 0; - for (Coordinates3D v : support) { + for (Cartesian3D v : support) { Assert.assertTrue(sphere.contains(v)); Assert.assertEquals(5.0 / 4.0, v.distance(sphere.getCenter()), 1.0e-10); Assert.assertTrue(v == sphere.getSupport()[i++]); } - Assert.assertTrue(sphere.contains(new Coordinates3D(2, 0.9, 0))); - Assert.assertFalse(sphere.contains(new Coordinates3D(0.9, 0, 0))); - Assert.assertFalse(sphere.contains(new Coordinates3D(3.1, 0, 0))); - Assert.assertTrue(sphere.contains(new Coordinates3D(2.0, -0.499, 0))); - Assert.assertFalse(sphere.contains(new Coordinates3D(2.0, -0.501, 0))); - Assert.assertTrue(sphere.contains(new Coordinates3D(2.0, 3.0 / 4.0, -1.249))); - Assert.assertFalse(sphere.contains(new Coordinates3D(2.0, 3.0 / 4.0, -1.251))); - Assert.assertEquals(0.0, new Coordinates3D(2.0, 3.0 / 4.0, 0).distance(sphere.getCenter()), 1.0e-10); + Assert.assertTrue(sphere.contains(new Cartesian3D(2, 0.9, 0))); + Assert.assertFalse(sphere.contains(new Cartesian3D(0.9, 0, 0))); + Assert.assertFalse(sphere.contains(new Cartesian3D(3.1, 0, 0))); + Assert.assertTrue(sphere.contains(new Cartesian3D(2.0, -0.499, 0))); + Assert.assertFalse(sphere.contains(new Cartesian3D(2.0, -0.501, 0))); + Assert.assertTrue(sphere.contains(new Cartesian3D(2.0, 3.0 / 4.0, -1.249))); + Assert.assertFalse(sphere.contains(new Cartesian3D(2.0, 3.0 / 4.0, -1.251))); + Assert.assertEquals(0.0, new Cartesian3D(2.0, 3.0 / 4.0, 0).distance(sphere.getCenter()), 1.0e-10); Assert.assertEquals(3, sphere.getSupportSize()); } @Test public void testSupport4Points() { - List<Coordinates3D> support = Arrays.asList(new Coordinates3D(17, 14, 18), - new Coordinates3D(11, 14, 22), - new Coordinates3D( 2, 22, 17), - new Coordinates3D(22, 11, -10)); - EnclosingBall<Euclidean3D, Coordinates3D> sphere = new SphereGenerator().ballOnSupport(support); + List<Cartesian3D> support = Arrays.asList(new Cartesian3D(17, 14, 18), + new Cartesian3D(11, 14, 22), + new Cartesian3D( 2, 22, 17), + new Cartesian3D(22, 11, -10)); + EnclosingBall<Euclidean3D, Cartesian3D> sphere = new SphereGenerator().ballOnSupport(support); Assert.assertEquals(25.0, sphere.getRadius(), 1.0e-10); int i = 0; - for (Coordinates3D v : support) { + for (Cartesian3D v : support) { Assert.assertTrue(sphere.contains(v)); Assert.assertEquals(25.0, v.distance(sphere.getCenter()), 1.0e-10); Assert.assertTrue(v == sphere.getSupport()[i++]); } - Assert.assertTrue(sphere.contains (new Coordinates3D(-22.999, 2, 2))); - Assert.assertFalse(sphere.contains(new Coordinates3D(-23.001, 2, 2))); - Assert.assertTrue(sphere.contains (new Coordinates3D( 26.999, 2, 2))); - Assert.assertFalse(sphere.contains(new Coordinates3D( 27.001, 2, 2))); - Assert.assertTrue(sphere.contains (new Coordinates3D(2, -22.999, 2))); - Assert.assertFalse(sphere.contains(new Coordinates3D(2, -23.001, 2))); - Assert.assertTrue(sphere.contains (new Coordinates3D(2, 26.999, 2))); - Assert.assertFalse(sphere.contains(new Coordinates3D(2, 27.001, 2))); - Assert.assertTrue(sphere.contains (new Coordinates3D(2, 2, -22.999))); - Assert.assertFalse(sphere.contains(new Coordinates3D(2, 2, -23.001))); - Assert.assertTrue(sphere.contains (new Coordinates3D(2, 2, 26.999))); - Assert.assertFalse(sphere.contains(new Coordinates3D(2, 2, 27.001))); - Assert.assertEquals(0.0, new Coordinates3D(2.0, 2.0, 2.0).distance(sphere.getCenter()), 1.0e-10); + Assert.assertTrue(sphere.contains (new Cartesian3D(-22.999, 2, 2))); + Assert.assertFalse(sphere.contains(new Cartesian3D(-23.001, 2, 2))); + Assert.assertTrue(sphere.contains (new Cartesian3D( 26.999, 2, 2))); + Assert.assertFalse(sphere.contains(new Cartesian3D( 27.001, 2, 2))); + Assert.assertTrue(sphere.contains (new Cartesian3D(2, -22.999, 2))); + Assert.assertFalse(sphere.contains(new Cartesian3D(2, -23.001, 2))); + Assert.assertTrue(sphere.contains (new Cartesian3D(2, 26.999, 2))); + Assert.assertFalse(sphere.contains(new Cartesian3D(2, 27.001, 2))); + Assert.assertTrue(sphere.contains (new Cartesian3D(2, 2, -22.999))); + Assert.assertFalse(sphere.contains(new Cartesian3D(2, 2, -23.001))); + Assert.assertTrue(sphere.contains (new Cartesian3D(2, 2, 26.999))); + Assert.assertFalse(sphere.contains(new Cartesian3D(2, 2, 27.001))); + Assert.assertEquals(0.0, new Cartesian3D(2.0, 2.0, 2.0).distance(sphere.getCenter()), 1.0e-10); Assert.assertEquals(4, sphere.getSupportSize()); } @@ -143,12 +143,12 @@ public class SphereGeneratorTest { for (int i = 0; i < 100; ++i) { double d = 25 * random.nextDouble(); double refRadius = 10 * random.nextDouble(); - Coordinates3D refCenter = new Coordinates3D(d, new Coordinates3D(sr.nextVector())); - List<Coordinates3D> support = new ArrayList<>(); + Cartesian3D refCenter = new Cartesian3D(d, new Cartesian3D(sr.nextVector())); + List<Cartesian3D> support = new ArrayList<>(); for (int j = 0; j < 5; ++j) { - support.add(new Coordinates3D(1.0, refCenter, refRadius, new Coordinates3D(sr.nextVector()))); + support.add(new Cartesian3D(1.0, refCenter, refRadius, new Cartesian3D(sr.nextVector()))); } - EnclosingBall<Euclidean3D, Coordinates3D> sphere = new SphereGenerator().ballOnSupport(support); + EnclosingBall<Euclidean3D, Cartesian3D> sphere = new SphereGenerator().ballOnSupport(support); Assert.assertEquals(0.0, refCenter.distance(sphere.getCenter()), 4e-7 * refRadius); Assert.assertEquals(refRadius, sphere.getRadius(), 1e-7 * refRadius); } @@ -156,20 +156,20 @@ public class SphereGeneratorTest { @Test public void testDegeneratedCase() { - final List<Coordinates3D> support = - Arrays.asList(new Coordinates3D(FastMath.scalb(-8039905610797991.0, -50), // -7.140870659936730 + final List<Cartesian3D> support = + Arrays.asList(new Cartesian3D(FastMath.scalb(-8039905610797991.0, -50), // -7.140870659936730 FastMath.scalb(-4663475464714142.0, -48), // -16.567993074240455 FastMath.scalb( 6592658872616184.0, -49)), // 11.710914678204503 - new Coordinates3D(FastMath.scalb(-8036658568968473.0, -50), // -7.137986707455888 + new Cartesian3D(FastMath.scalb(-8036658568968473.0, -50), // -7.137986707455888 FastMath.scalb(-4664256346424880.0, -48), // -16.570767323375720 FastMath.scalb( 6591357011730307.0, -49)), // 11.708602108715928) - new Coordinates3D(FastMath.scalb(-8037820142977230.0, -50), // -7.139018392423351 + new Cartesian3D(FastMath.scalb(-8037820142977230.0, -50), // -7.139018392423351 FastMath.scalb(-4665280434237813.0, -48), // -16.574405614157020 FastMath.scalb( 6592435966112099.0, -49)), // 11.710518716711425 - new Coordinates3D(FastMath.scalb(-8038007803611611.0, -50), // -7.139185068549035 + new Cartesian3D(FastMath.scalb(-8038007803611611.0, -50), // -7.139185068549035 FastMath.scalb(-4664291215918380.0, -48), // -16.570891204702250 FastMath.scalb( 6595270610894208.0, -49))); // 11.715554057357394 - EnclosingBall<Euclidean3D, Coordinates3D> sphere = new SphereGenerator().ballOnSupport(support); + EnclosingBall<Euclidean3D, Cartesian3D> sphere = new SphereGenerator().ballOnSupport(support); // the following values have been computed using Emacs calc with exact arithmetic from the // rational representation corresponding to the scalb calls (i.e. -8039905610797991/2^50, ...) @@ -180,7 +180,7 @@ public class SphereGeneratorTest { Assert.assertEquals(-16.571096474251747245361467833760, sphere.getCenter().getY(), 1.0e-20); Assert.assertEquals( 11.711945804096960876521111630800, sphere.getCenter().getZ(), 1.0e-20); - for (Coordinates3D v : support) { + for (Cartesian3D v : support) { Assert.assertTrue(sphere.contains(v, 1.0e-14)); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinatesTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinatesTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinatesTest.java index 36c9ed4..6b72072 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinatesTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinatesTest.java @@ -21,7 +21,7 @@ import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.analysis.differentiation.DerivativeStructure; import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.geometry.euclidean.threed.SphericalCoordinates; -import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; +import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D; import org.apache.commons.math4.util.FastMath; import org.junit.Assert; import org.junit.Test; @@ -32,43 +32,43 @@ public class SphericalCoordinatesTest { public void testCoordinatesStoC() throws DimensionMismatchException { double piO2 = 0.5 * FastMath.PI; SphericalCoordinates sc1 = new SphericalCoordinates(2.0, 0, piO2); - Assert.assertEquals(0, sc1.getCartesian().distance(new Coordinates3D(2, 0, 0)), 1.0e-10); + Assert.assertEquals(0, sc1.getCartesian().distance(new Cartesian3D(2, 0, 0)), 1.0e-10); SphericalCoordinates sc2 = new SphericalCoordinates(2.0, piO2, piO2); - Assert.assertEquals(0, sc2.getCartesian().distance(new Coordinates3D(0, 2, 0)), 1.0e-10); + Assert.assertEquals(0, sc2.getCartesian().distance(new Cartesian3D(0, 2, 0)), 1.0e-10); SphericalCoordinates sc3 = new SphericalCoordinates(2.0, FastMath.PI, piO2); - Assert.assertEquals(0, sc3.getCartesian().distance(new Coordinates3D(-2, 0, 0)), 1.0e-10); + Assert.assertEquals(0, sc3.getCartesian().distance(new Cartesian3D(-2, 0, 0)), 1.0e-10); SphericalCoordinates sc4 = new SphericalCoordinates(2.0, -piO2, piO2); - Assert.assertEquals(0, sc4.getCartesian().distance(new Coordinates3D(0, -2, 0)), 1.0e-10); + Assert.assertEquals(0, sc4.getCartesian().distance(new Cartesian3D(0, -2, 0)), 1.0e-10); SphericalCoordinates sc5 = new SphericalCoordinates(2.0, 1.23456, 0); - Assert.assertEquals(0, sc5.getCartesian().distance(new Coordinates3D(0, 0, 2)), 1.0e-10); + Assert.assertEquals(0, sc5.getCartesian().distance(new Cartesian3D(0, 0, 2)), 1.0e-10); SphericalCoordinates sc6 = new SphericalCoordinates(2.0, 6.54321, FastMath.PI); - Assert.assertEquals(0, sc6.getCartesian().distance(new Coordinates3D(0, 0, -2)), 1.0e-10); + Assert.assertEquals(0, sc6.getCartesian().distance(new Cartesian3D(0, 0, -2)), 1.0e-10); } @Test public void testCoordinatesCtoS() throws DimensionMismatchException { double piO2 = 0.5 * FastMath.PI; - SphericalCoordinates sc1 = new SphericalCoordinates(new Coordinates3D(2, 0, 0)); + SphericalCoordinates sc1 = new SphericalCoordinates(new Cartesian3D(2, 0, 0)); Assert.assertEquals(2, sc1.getR(), 1.0e-10); Assert.assertEquals(0, sc1.getTheta(), 1.0e-10); Assert.assertEquals(piO2, sc1.getPhi(), 1.0e-10); - SphericalCoordinates sc2 = new SphericalCoordinates(new Coordinates3D(0, 2, 0)); + SphericalCoordinates sc2 = new SphericalCoordinates(new Cartesian3D(0, 2, 0)); Assert.assertEquals(2, sc2.getR(), 1.0e-10); Assert.assertEquals(piO2, sc2.getTheta(), 1.0e-10); Assert.assertEquals(piO2, sc2.getPhi(), 1.0e-10); - SphericalCoordinates sc3 = new SphericalCoordinates(new Coordinates3D(-2, 0, 0)); + SphericalCoordinates sc3 = new SphericalCoordinates(new Cartesian3D(-2, 0, 0)); Assert.assertEquals(2, sc3.getR(), 1.0e-10); Assert.assertEquals(FastMath.PI, sc3.getTheta(), 1.0e-10); Assert.assertEquals(piO2, sc3.getPhi(), 1.0e-10); - SphericalCoordinates sc4 = new SphericalCoordinates(new Coordinates3D(0, -2, 0)); + SphericalCoordinates sc4 = new SphericalCoordinates(new Cartesian3D(0, -2, 0)); Assert.assertEquals(2, sc4.getR(), 1.0e-10); Assert.assertEquals(-piO2, sc4.getTheta(), 1.0e-10); Assert.assertEquals(piO2, sc4.getPhi(), 1.0e-10); - SphericalCoordinates sc5 = new SphericalCoordinates(new Coordinates3D(0, 0, 2)); + SphericalCoordinates sc5 = new SphericalCoordinates(new Cartesian3D(0, 0, 2)); Assert.assertEquals(2, sc5.getR(), 1.0e-10); // don't check theta on poles, as it is singular Assert.assertEquals(0, sc5.getPhi(), 1.0e-10); - SphericalCoordinates sc6 = new SphericalCoordinates(new Coordinates3D(0, 0, -2)); + SphericalCoordinates sc6 = new SphericalCoordinates(new Cartesian3D(0, 0, -2)); Assert.assertEquals(2, sc6.getR(), 1.0e-10); // don't check theta on poles, as it is singular Assert.assertEquals(FastMath.PI, sc6.getPhi(), 1.0e-10); @@ -93,11 +93,11 @@ public class SphericalCoordinatesTest { DerivativeStructure cvalue = valueCartesian(new DerivativeStructure(3, 1, 0, sc.getCartesian().getX()), new DerivativeStructure(3, 1, 1, sc.getCartesian().getY()), new DerivativeStructure(3, 1, 2, sc.getCartesian().getZ())); - Coordinates3D refCGradient = new Coordinates3D(cvalue.getPartialDerivative(1, 0, 0), + Cartesian3D refCGradient = new Cartesian3D(cvalue.getPartialDerivative(1, 0, 0), cvalue.getPartialDerivative(0, 1, 0), cvalue.getPartialDerivative(0, 0, 1)); - Coordinates3D testCGradient = new Coordinates3D(sc.toCartesianGradient(sGradient)); + Cartesian3D testCGradient = new Cartesian3D(sc.toCartesianGradient(sGradient)); Assert.assertEquals(0, testCGradient.distance(refCGradient) / refCGradient.getNorm(), 5.0e-14); http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SubLineTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SubLineTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SubLineTest.java index cb967fb..aab6398 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SubLineTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/SubLineTest.java @@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet; import org.apache.commons.math4.geometry.euclidean.threed.Line; import org.apache.commons.math4.geometry.euclidean.threed.Segment; import org.apache.commons.math4.geometry.euclidean.threed.SubLine; -import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; +import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D; import org.apache.commons.math4.geometry.partitioning.RegionFactory; import org.junit.Assert; import org.junit.Test; @@ -33,19 +33,19 @@ public class SubLineTest { @Test public void testEndPoints() throws MathIllegalArgumentException { - Coordinates3D p1 = new Coordinates3D(-1, -7, 2); - Coordinates3D p2 = new Coordinates3D(7, -1, 0); + Cartesian3D p1 = new Cartesian3D(-1, -7, 2); + Cartesian3D p2 = new Cartesian3D(7, -1, 0); Segment segment = new Segment(p1, p2, new Line(p1, p2, 1.0e-10)); SubLine sub = new SubLine(segment); List<Segment> segments = sub.getSegments(); Assert.assertEquals(1, segments.size()); - Assert.assertEquals(0.0, new Coordinates3D(-1, -7, 2).distance(segments.get(0).getStart()), 1.0e-10); - Assert.assertEquals(0.0, new Coordinates3D( 7, -1, 0).distance(segments.get(0).getEnd()), 1.0e-10); + Assert.assertEquals(0.0, new Cartesian3D(-1, -7, 2).distance(segments.get(0).getStart()), 1.0e-10); + Assert.assertEquals(0.0, new Cartesian3D( 7, -1, 0).distance(segments.get(0).getEnd()), 1.0e-10); } @Test public void testNoEndPoints() throws MathIllegalArgumentException { - SubLine wholeLine = new Line(new Coordinates3D(-1, 7, 2), new Coordinates3D(7, 1, 0), 1.0e-10).wholeLine(); + SubLine wholeLine = new Line(new Cartesian3D(-1, 7, 2), new Cartesian3D(7, 1, 0), 1.0e-10).wholeLine(); List<Segment> segments = wholeLine.getSegments(); Assert.assertEquals(1, segments.size()); Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getX()) && @@ -64,7 +64,7 @@ public class SubLineTest { @Test public void testNoSegments() throws MathIllegalArgumentException { - SubLine empty = new SubLine(new Line(new Coordinates3D(-1, -7, 2), new Coordinates3D(7, -1, 0), 1.0e-10), + SubLine empty = new SubLine(new Line(new Cartesian3D(-1, -7, 2), new Cartesian3D(7, -1, 0), 1.0e-10), (IntervalsSet) new RegionFactory<Euclidean1D>().getComplement(new IntervalsSet(1.0e-10))); List<Segment> segments = empty.getSegments(); Assert.assertEquals(0, segments.size()); @@ -72,7 +72,7 @@ public class SubLineTest { @Test public void testSeveralSegments() throws MathIllegalArgumentException { - SubLine twoSubs = new SubLine(new Line(new Coordinates3D(-1, -7, 2), new Coordinates3D(7, -1, 0), 1.0e-10), + SubLine twoSubs = new SubLine(new Line(new Cartesian3D(-1, -7, 2), new Cartesian3D(7, -1, 0), 1.0e-10), (IntervalsSet) new RegionFactory<Euclidean1D>().union(new IntervalsSet(1, 2, 1.0e-10), new IntervalsSet(3, 4, 1.0e-10))); List<Segment> segments = twoSubs.getSegments(); @@ -81,7 +81,7 @@ public class SubLineTest { @Test public void testHalfInfiniteNeg() throws MathIllegalArgumentException { - SubLine empty = new SubLine(new Line(new Coordinates3D(-1, -7, 2), new Coordinates3D(7, -1, -2), 1.0e-10), + SubLine empty = new SubLine(new Line(new Cartesian3D(-1, -7, 2), new Cartesian3D(7, -1, -2), 1.0e-10), new IntervalsSet(Double.NEGATIVE_INFINITY, 0.0, 1.0e-10)); List<Segment> segments = empty.getSegments(); Assert.assertEquals(1, segments.size()); @@ -91,16 +91,16 @@ public class SubLineTest { segments.get(0).getStart().getY() < 0); Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getZ()) && segments.get(0).getStart().getZ() > 0); - Assert.assertEquals(0.0, new Coordinates3D(3, -4, 0).distance(segments.get(0).getEnd()), 1.0e-10); + Assert.assertEquals(0.0, new Cartesian3D(3, -4, 0).distance(segments.get(0).getEnd()), 1.0e-10); } @Test public void testHalfInfinitePos() throws MathIllegalArgumentException { - SubLine empty = new SubLine(new Line(new Coordinates3D(-1, -7, 2), new Coordinates3D(7, -1, -2), 1.0e-10), + SubLine empty = new SubLine(new Line(new Cartesian3D(-1, -7, 2), new Cartesian3D(7, -1, -2), 1.0e-10), new IntervalsSet(0.0, Double.POSITIVE_INFINITY, 1.0e-10)); List<Segment> segments = empty.getSegments(); Assert.assertEquals(1, segments.size()); - Assert.assertEquals(0.0, new Coordinates3D(3, -4, 0).distance(segments.get(0).getStart()), 1.0e-10); + Assert.assertEquals(0.0, new Cartesian3D(3, -4, 0).distance(segments.get(0).getStart()), 1.0e-10); Assert.assertTrue(Double.isInfinite(segments.get(0).getEnd().getX()) && segments.get(0).getEnd().getX() > 0); Assert.assertTrue(Double.isInfinite(segments.get(0).getEnd().getY()) && @@ -111,56 +111,56 @@ public class SubLineTest { @Test public void testIntersectionInsideInside() throws MathIllegalArgumentException { - SubLine sub1 = new SubLine(new Coordinates3D(1, 1, 1), new Coordinates3D(3, 1, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Coordinates3D(2, 0, 0), new Coordinates3D(2, 2, 2), 1.0e-10); - Assert.assertEquals(0.0, new Coordinates3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); - Assert.assertEquals(0.0, new Coordinates3D(2, 1, 1).distance(sub1.intersection(sub2, false)), 1.0e-12); + SubLine sub1 = new SubLine(new Cartesian3D(1, 1, 1), new Cartesian3D(3, 1, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Cartesian3D(2, 0, 0), new Cartesian3D(2, 2, 2), 1.0e-10); + Assert.assertEquals(0.0, new Cartesian3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); + Assert.assertEquals(0.0, new Cartesian3D(2, 1, 1).distance(sub1.intersection(sub2, false)), 1.0e-12); } @Test public void testIntersectionInsideBoundary() throws MathIllegalArgumentException { - SubLine sub1 = new SubLine(new Coordinates3D(1, 1, 1), new Coordinates3D(3, 1, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Coordinates3D(2, 0, 0), new Coordinates3D(2, 1, 1), 1.0e-10); - Assert.assertEquals(0.0, new Coordinates3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); + SubLine sub1 = new SubLine(new Cartesian3D(1, 1, 1), new Cartesian3D(3, 1, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Cartesian3D(2, 0, 0), new Cartesian3D(2, 1, 1), 1.0e-10); + Assert.assertEquals(0.0, new Cartesian3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); Assert.assertNull(sub1.intersection(sub2, false)); } @Test public void testIntersectionInsideOutside() throws MathIllegalArgumentException { - SubLine sub1 = new SubLine(new Coordinates3D(1, 1, 1), new Coordinates3D(3, 1, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Coordinates3D(2, 0, 0), new Coordinates3D(2, 0.5, 0.5), 1.0e-10); + SubLine sub1 = new SubLine(new Cartesian3D(1, 1, 1), new Cartesian3D(3, 1, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Cartesian3D(2, 0, 0), new Cartesian3D(2, 0.5, 0.5), 1.0e-10); Assert.assertNull(sub1.intersection(sub2, true)); Assert.assertNull(sub1.intersection(sub2, false)); } @Test public void testIntersectionBoundaryBoundary() throws MathIllegalArgumentException { - SubLine sub1 = new SubLine(new Coordinates3D(1, 1, 1), new Coordinates3D(2, 1, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Coordinates3D(2, 0, 0), new Coordinates3D(2, 1, 1), 1.0e-10); - Assert.assertEquals(0.0, new Coordinates3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); + SubLine sub1 = new SubLine(new Cartesian3D(1, 1, 1), new Cartesian3D(2, 1, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Cartesian3D(2, 0, 0), new Cartesian3D(2, 1, 1), 1.0e-10); + Assert.assertEquals(0.0, new Cartesian3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); Assert.assertNull(sub1.intersection(sub2, false)); } @Test public void testIntersectionBoundaryOutside() throws MathIllegalArgumentException { - SubLine sub1 = new SubLine(new Coordinates3D(1, 1, 1), new Coordinates3D(2, 1, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Coordinates3D(2, 0, 0), new Coordinates3D(2, 0.5, 0.5), 1.0e-10); + SubLine sub1 = new SubLine(new Cartesian3D(1, 1, 1), new Cartesian3D(2, 1, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Cartesian3D(2, 0, 0), new Cartesian3D(2, 0.5, 0.5), 1.0e-10); Assert.assertNull(sub1.intersection(sub2, true)); Assert.assertNull(sub1.intersection(sub2, false)); } @Test public void testIntersectionOutsideOutside() throws MathIllegalArgumentException { - SubLine sub1 = new SubLine(new Coordinates3D(1, 1, 1), new Coordinates3D(1.5, 1, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Coordinates3D(2, 0, 0), new Coordinates3D(2, 0.5, 0.5), 1.0e-10); + SubLine sub1 = new SubLine(new Cartesian3D(1, 1, 1), new Cartesian3D(1.5, 1, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Cartesian3D(2, 0, 0), new Cartesian3D(2, 0.5, 0.5), 1.0e-10); Assert.assertNull(sub1.intersection(sub2, true)); Assert.assertNull(sub1.intersection(sub2, false)); } @Test public void testIntersectionNotIntersecting() throws MathIllegalArgumentException { - SubLine sub1 = new SubLine(new Coordinates3D(1, 1, 1), new Coordinates3D(1.5, 1, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Coordinates3D(2, 3, 0), new Coordinates3D(2, 3, 0.5), 1.0e-10); + SubLine sub1 = new SubLine(new Cartesian3D(1, 1, 1), new Cartesian3D(1.5, 1, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Cartesian3D(2, 3, 0), new Cartesian3D(2, 3, 0.5), 1.0e-10); Assert.assertNull(sub1.intersection(sub2, true)); Assert.assertNull(sub1.intersection(sub2, false)); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormatAbstractTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormatAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormatAbstractTest.java index 048a769..9092797 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormatAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormatAbstractTest.java @@ -22,7 +22,7 @@ import java.text.ParsePosition; import java.util.Locale; import org.apache.commons.math4.exception.MathParseException; -import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; +import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D; import org.apache.commons.math4.geometry.euclidean.threed.Vector3DFormat; import org.junit.Test; import org.junit.Assert; @@ -45,7 +45,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testSimpleNoDecimals() { - Coordinates3D c = new Coordinates3D(1, 1, 1); + Cartesian3D c = new Cartesian3D(1, 1, 1); String expected = "{1; 1; 1}"; String actual = vector3DFormat.format(c); Assert.assertEquals(expected, actual); @@ -53,7 +53,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testSimpleWithDecimals() { - Coordinates3D c = new Coordinates3D(1.23, 1.43, 1.63); + Cartesian3D c = new Cartesian3D(1.23, 1.43, 1.63); String expected = "{1" + getDecimalCharacter() + "23; 1" + getDecimalCharacter() + @@ -65,7 +65,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testSimpleWithDecimalsTrunc() { - Coordinates3D c = new Coordinates3D(1.232323232323, 1.434343434343, 1.633333333333); + Cartesian3D c = new Cartesian3D(1.232323232323, 1.434343434343, 1.633333333333); String expected = "{1" + getDecimalCharacter() + "2323232323; 1" + getDecimalCharacter() + @@ -77,7 +77,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testNegativeX() { - Coordinates3D c = new Coordinates3D(-1.232323232323, 1.43, 1.63); + Cartesian3D c = new Cartesian3D(-1.232323232323, 1.43, 1.63); String expected = "{-1" + getDecimalCharacter() + "2323232323; 1" + getDecimalCharacter() + @@ -89,7 +89,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testNegativeY() { - Coordinates3D c = new Coordinates3D(1.23, -1.434343434343, 1.63); + Cartesian3D c = new Cartesian3D(1.23, -1.434343434343, 1.63); String expected = "{1" + getDecimalCharacter() + "23; -1" + getDecimalCharacter() + @@ -101,7 +101,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testNegativeZ() { - Coordinates3D c = new Coordinates3D(1.23, 1.43, -1.633333333333); + Cartesian3D c = new Cartesian3D(1.23, 1.43, -1.633333333333); String expected = "{1" + getDecimalCharacter() + "23; 1" + getDecimalCharacter() + @@ -113,7 +113,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testNonDefaultSetting() { - Coordinates3D c = new Coordinates3D(1, 1, 1); + Cartesian3D c = new Cartesian3D(1, 1, 1); String expected = "[1 : 1 : 1]"; String actual = vector3DFormatSquare.format(c); Assert.assertEquals(expected, actual); @@ -124,7 +124,7 @@ public abstract class Vector3DFormatAbstractTest { Locale defaultLocal = Locale.getDefault(); Locale.setDefault(getLocale()); - Coordinates3D c = new Coordinates3D(232.22222222222, -342.3333333333, 432.44444444444); + Cartesian3D c = new Cartesian3D(232.22222222222, -342.3333333333, 432.44444444444); String expected = "{232" + getDecimalCharacter() + "2222222222; -342" + getDecimalCharacter() + @@ -138,7 +138,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testNan() { - Coordinates3D c = Coordinates3D.NaN; + Cartesian3D c = Cartesian3D.NaN; String expected = "{(NaN); (NaN); (NaN)}"; String actual = vector3DFormat.format(c); Assert.assertEquals(expected, actual); @@ -146,7 +146,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testPositiveInfinity() { - Coordinates3D c = Coordinates3D.POSITIVE_INFINITY; + Cartesian3D c = Cartesian3D.POSITIVE_INFINITY; String expected = "{(Infinity); (Infinity); (Infinity)}"; String actual = vector3DFormat.format(c); Assert.assertEquals(expected, actual); @@ -154,7 +154,7 @@ public abstract class Vector3DFormatAbstractTest { @Test public void tesNegativeInfinity() { - Coordinates3D c = Coordinates3D.NEGATIVE_INFINITY; + Cartesian3D c = Cartesian3D.NEGATIVE_INFINITY; String expected = "{(-Infinity); (-Infinity); (-Infinity)}"; String actual = vector3DFormat.format(c); Assert.assertEquals(expected, actual); @@ -163,14 +163,14 @@ public abstract class Vector3DFormatAbstractTest { @Test public void testParseSimpleNoDecimals() throws MathParseException { String source = "{1; 1; 1}"; - Coordinates3D expected = new Coordinates3D(1, 1, 1); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(1, 1, 1); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @Test public void testParseIgnoredWhitespace() { - Coordinates3D expected = new Coordinates3D(1, 1, 1); + Cartesian3D expected = new Cartesian3D(1, 1, 1); ParsePosition pos1 = new ParsePosition(0); String source1 = "{1;1;1}"; Assert.assertEquals(expected, vector3DFormat.parse(source1, pos1)); @@ -188,8 +188,8 @@ public abstract class Vector3DFormatAbstractTest { "23; 1" + getDecimalCharacter() + "43; 1" + getDecimalCharacter() + "63}"; - Coordinates3D expected = new Coordinates3D(1.23, 1.43, 1.63); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(1.23, 1.43, 1.63); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -200,8 +200,8 @@ public abstract class Vector3DFormatAbstractTest { "2323; 1" + getDecimalCharacter() + "4343; 1" + getDecimalCharacter() + "6333}"; - Coordinates3D expected = new Coordinates3D(1.2323, 1.4343, 1.6333); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(1.2323, 1.4343, 1.6333); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -212,8 +212,8 @@ public abstract class Vector3DFormatAbstractTest { "2323; 1" + getDecimalCharacter() + "4343; 1" + getDecimalCharacter() + "6333}"; - Coordinates3D expected = new Coordinates3D(-1.2323, 1.4343, 1.6333); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(-1.2323, 1.4343, 1.6333); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -224,8 +224,8 @@ public abstract class Vector3DFormatAbstractTest { "2323; -1" + getDecimalCharacter() + "4343; 1" + getDecimalCharacter() + "6333}"; - Coordinates3D expected = new Coordinates3D(1.2323, -1.4343, 1.6333); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(1.2323, -1.4343, 1.6333); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -236,8 +236,8 @@ public abstract class Vector3DFormatAbstractTest { "2323; 1" + getDecimalCharacter() + "4343; -1" + getDecimalCharacter() + "6333}"; - Coordinates3D expected = new Coordinates3D(1.2323, 1.4343, -1.6333); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(1.2323, 1.4343, -1.6333); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -248,8 +248,8 @@ public abstract class Vector3DFormatAbstractTest { "2323; -1" + getDecimalCharacter() + "4343; -1" + getDecimalCharacter() + "6333}"; - Coordinates3D expected = new Coordinates3D(-1.2323, -1.4343, -1.6333); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(-1.2323, -1.4343, -1.6333); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -260,8 +260,8 @@ public abstract class Vector3DFormatAbstractTest { "0; -1" + getDecimalCharacter() + "4343; 1" + getDecimalCharacter() + "6333}"; - Coordinates3D expected = new Coordinates3D(0.0, -1.4343, 1.6333); - Coordinates3D actual = vector3DFormat.parse(source); + Cartesian3D expected = new Cartesian3D(0.0, -1.4343, 1.6333); + Cartesian3D actual = vector3DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -272,30 +272,30 @@ public abstract class Vector3DFormatAbstractTest { "2323 : 1" + getDecimalCharacter() + "4343 : 1" + getDecimalCharacter() + "6333]"; - Coordinates3D expected = new Coordinates3D(1.2323, 1.4343, 1.6333); - Coordinates3D actual = vector3DFormatSquare.parse(source); + Cartesian3D expected = new Cartesian3D(1.2323, 1.4343, 1.6333); + Cartesian3D actual = vector3DFormatSquare.parse(source); Assert.assertEquals(expected, actual); } @Test public void testParseNan() throws MathParseException { String source = "{(NaN); (NaN); (NaN)}"; - Coordinates3D actual = vector3DFormat.parse(source); - Assert.assertEquals(Coordinates3D.NaN, actual); + Cartesian3D actual = vector3DFormat.parse(source); + Assert.assertEquals(Cartesian3D.NaN, actual); } @Test public void testParsePositiveInfinity() throws MathParseException { String source = "{(Infinity); (Infinity); (Infinity)}"; - Coordinates3D actual = vector3DFormat.parse(source); - Assert.assertEquals(Coordinates3D.POSITIVE_INFINITY, actual); + Cartesian3D actual = vector3DFormat.parse(source); + Assert.assertEquals(Cartesian3D.POSITIVE_INFINITY, actual); } @Test public void testParseNegativeInfinity() throws MathParseException { String source = "{(-Infinity); (-Infinity); (-Infinity)}"; - Coordinates3D actual = vector3DFormat.parse(source); - Assert.assertEquals(Coordinates3D.NEGATIVE_INFINITY, actual); + Cartesian3D actual = vector3DFormat.parse(source); + Assert.assertEquals(Cartesian3D.NEGATIVE_INFINITY, actual); } @Test