You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ra...@apache.org on 2017/05/06 15:04:19 UTC
[06/19] [math] MATH-1284: Replace/rename Coordinate?D classes (nee
Vector?D) as Cartesian?D classes as per discussion. When there are existing
overridden methods accepting Vector and Point,
add a disambiguating method accepting
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java
index 7728b96..02c059e 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.geometry.euclidean.threed.FieldVector3D;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.util.FastMath;
@@ -59,7 +59,7 @@ public class FieldVector3DTest {
createVector(1, 0, 0, 4)),
2, 0, 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, 0, 2, 0);
checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0),
- new Coordinates3D(1, 0, 0)),
+ new Cartesian3D(1, 0, 0)),
2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3),
@@ -71,9 +71,9 @@ public class FieldVector3DTest {
createVector(0, 0, -1, 4)),
2, 0, 3, -1, 0, 0, 1, 0, -1, 0, 0, 0, 0, -1, -1);
checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0),
- new Coordinates3D(1, 0, 0),
+ new Cartesian3D(1, 0, 0),
new DerivativeStructure(4, 1, 3, -3.0),
- new Coordinates3D(0, 0, -1)),
+ new Cartesian3D(0, 0, -1)),
2, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1);
checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3),
@@ -88,11 +88,11 @@ public class FieldVector3DTest {
createVector(0, 0, -1, 4)),
2, 5, 3, 4, 0, 0, 1, 0, 4, 0, 1, 0, 0, 4, -1);
checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0),
- new Coordinates3D(1, 0, 0),
+ new Cartesian3D(1, 0, 0),
new DerivativeStructure(4, 1, 3, 5.0),
- new Coordinates3D(0, 1, 0),
+ new Cartesian3D(0, 1, 0),
new DerivativeStructure(4, 1, 3, -3.0),
- new Coordinates3D(0, 0, -1)),
+ new Cartesian3D(0, 0, -1)),
2, 5, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, -1);
checkVector(new FieldVector3D<>(2, createVector(1, 0, 0, 3),
@@ -110,13 +110,13 @@ public class FieldVector3DTest {
createVector(0, 0, -1, 4)),
2, 0, 3, 9, 0, 0, 1, 0, 9, 0, 0, 0, 0, 9, -1);
checkVector(new FieldVector3D<>(new DerivativeStructure(4, 1, 3, 2.0),
- new Coordinates3D(1, 0, 0),
+ new Cartesian3D(1, 0, 0),
new DerivativeStructure(4, 1, 3, 5.0),
- new Coordinates3D(0, 1, 0),
+ new Cartesian3D(0, 1, 0),
new DerivativeStructure(4, 1, 3, 5.0),
- new Coordinates3D(0, -1, 0),
+ new Cartesian3D(0, -1, 0),
new DerivativeStructure(4, 1, 3, -3.0),
- new Coordinates3D(0, 0, -1)),
+ new Cartesian3D(0, 0, -1)),
2, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1);
checkVector(new FieldVector3D<>(new DerivativeStructure[] {
@@ -270,12 +270,12 @@ public class FieldVector3DTest {
Assert.assertEquals(0, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
- distance = FieldVector3D.distance1(v1, new Coordinates3D(-4, 2, 0));
+ distance = FieldVector3D.distance1(v1, new Cartesian3D(-4, 2, 0));
Assert.assertEquals(12.0, distance.getReal(), 1.0e-12);
Assert.assertEquals( 1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(-1, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals( 1, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
- distance = FieldVector3D.distance1(new Coordinates3D(-4, 2, 0), v1);
+ distance = FieldVector3D.distance1(new Cartesian3D(-4, 2, 0), v1);
Assert.assertEquals(12.0, distance.getReal(), 1.0e-12);
Assert.assertEquals( 1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(-1, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
@@ -292,12 +292,12 @@ public class FieldVector3DTest {
Assert.assertEquals(0, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
- distance = FieldVector3D.distance(v1, new Coordinates3D(-4, 2, 0));
+ distance = FieldVector3D.distance(v1, new Cartesian3D(-4, 2, 0));
Assert.assertEquals(FastMath.sqrt(50), distance.getReal(), 1.0e-12);
Assert.assertEquals( 5 / FastMath.sqrt(50), distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(-4 / FastMath.sqrt(50), distance.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals( 3 / FastMath.sqrt(50), distance.getPartialDerivative(0, 0, 1), 1.0e-12);
- distance = FieldVector3D.distance(new Coordinates3D(-4, 2, 0), v1);
+ distance = FieldVector3D.distance(new Cartesian3D(-4, 2, 0), v1);
Assert.assertEquals(FastMath.sqrt(50), distance.getReal(), 1.0e-12);
Assert.assertEquals( 5 / FastMath.sqrt(50), distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(-4 / FastMath.sqrt(50), distance.getPartialDerivative(0, 1, 0), 1.0e-12);
@@ -314,12 +314,12 @@ public class FieldVector3DTest {
Assert.assertEquals(0, distanceSq.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(0, distanceSq.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals(0, distanceSq.getPartialDerivative(0, 0, 1), 1.0e-12);
- distanceSq = FieldVector3D.distanceSq(v1, new Coordinates3D(-4, 2, 0));
+ distanceSq = FieldVector3D.distanceSq(v1, new Cartesian3D(-4, 2, 0));
Assert.assertEquals(50.0, distanceSq.getReal(), 1.0e-12);
Assert.assertEquals(10, distanceSq.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(-8, distanceSq.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals( 6, distanceSq.getPartialDerivative(0, 0, 1), 1.0e-12);
- distanceSq = FieldVector3D.distanceSq(new Coordinates3D(-4, 2, 0), v1);
+ distanceSq = FieldVector3D.distanceSq(new Cartesian3D(-4, 2, 0), v1);
Assert.assertEquals(50.0, distanceSq.getReal(), 1.0e-12);
Assert.assertEquals(10, distanceSq.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(-8, distanceSq.getPartialDerivative(0, 1, 0), 1.0e-12);
@@ -336,12 +336,12 @@ public class FieldVector3DTest {
Assert.assertEquals(0, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
- distance = FieldVector3D.distanceInf(v1, new Coordinates3D(-4, 2, 0));
+ distance = FieldVector3D.distanceInf(v1, new Cartesian3D(-4, 2, 0));
Assert.assertEquals(5.0, distance.getReal(), 1.0e-12);
Assert.assertEquals(1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
- distance = FieldVector3D.distanceInf(new Coordinates3D(-4, 2, 0), v1);
+ distance = FieldVector3D.distanceInf(new Cartesian3D(-4, 2, 0), v1);
Assert.assertEquals(5.0, distance.getReal(), 1.0e-12);
Assert.assertEquals(1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
@@ -368,22 +368,22 @@ public class FieldVector3DTest {
1.0e-12);
Assert.assertEquals(5.0,
- FieldVector3D.distanceInf(createVector( 1, -2, 3, 3), new Coordinates3D(-4, 2, 0)).getReal(),
+ FieldVector3D.distanceInf(createVector( 1, -2, 3, 3), new Cartesian3D(-4, 2, 0)).getReal(),
1.0e-12);
Assert.assertEquals(5.0,
- FieldVector3D.distanceInf(createVector( 1, 3, -2, 3), new Coordinates3D(-4, 0, 2)).getReal(),
+ FieldVector3D.distanceInf(createVector( 1, 3, -2, 3), new Cartesian3D(-4, 0, 2)).getReal(),
1.0e-12);
Assert.assertEquals(5.0,
- FieldVector3D.distanceInf(createVector(-2, 1, 3, 3), new Coordinates3D( 2, -4, 0)).getReal(),
+ FieldVector3D.distanceInf(createVector(-2, 1, 3, 3), new Cartesian3D( 2, -4, 0)).getReal(),
1.0e-12);
Assert.assertEquals(5.0,
- FieldVector3D.distanceInf(createVector(-2, 3, 1, 3), new Coordinates3D( 2, 0, -4)).getReal(),
+ FieldVector3D.distanceInf(createVector(-2, 3, 1, 3), new Cartesian3D( 2, 0, -4)).getReal(),
1.0e-12);
Assert.assertEquals(5.0,
- FieldVector3D.distanceInf(createVector(3, -2, 1, 3), new Coordinates3D(0, 2, -4)).getReal(),
+ FieldVector3D.distanceInf(createVector(3, -2, 1, 3), new Cartesian3D(0, 2, -4)).getReal(),
1.0e-12);
Assert.assertEquals(5.0,
- FieldVector3D.distanceInf(createVector(3, 1, -2, 3), new Coordinates3D(0, -4, 2)).getReal(),
+ FieldVector3D.distanceInf(createVector(3, 1, -2, 3), new Cartesian3D(0, -4, 2)).getReal(),
1.0e-12);
}
@@ -396,10 +396,10 @@ public class FieldVector3DTest {
checkVector(v1, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0);
checkVector(v2.subtract(v1), -7, -6, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1);
- checkVector(v2.subtract(new Coordinates3D(4, 4, 4)), -7, -6, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1);
+ checkVector(v2.subtract(new Cartesian3D(4, 4, 4)), -7, -6, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1);
checkVector(v2.subtract(3, v1), -15, -14, -13, 1, 0, 0, 0, 1, 0, 0, 0, 1);
- checkVector(v2.subtract(3, new Coordinates3D(4, 4, 4)), -15, -14, -13, 1, 0, 0, 0, 1, 0, 0, 0, 1);
- checkVector(v2.subtract(new DerivativeStructure(3, 1, 2, 3), new Coordinates3D(4, 4, 4)),
+ checkVector(v2.subtract(3, new Cartesian3D(4, 4, 4)), -15, -14, -13, 1, 0, 0, 0, 1, 0, 0, 0, 1);
+ checkVector(v2.subtract(new DerivativeStructure(3, 1, 2, 3), new Cartesian3D(4, 4, 4)),
-15, -14, -13, 1, 0, -4, 0, 1, -4, 0, 0, -3);
checkVector(createVector(1, 2, 3, 4).subtract(new DerivativeStructure(4, 1, 3, 5.0),
@@ -419,10 +419,10 @@ public class FieldVector3DTest {
checkVector(v1, -2, 0, 2, 2, 0, 0, 0, 2, 0, 0, 0, 2);
checkVector(v2.add(v1), -5, -2, 1, 3, 0, 0, 0, 3, 0, 0, 0, 3);
- checkVector(v2.add(new Coordinates3D(-2, 0, 2)), -5, -2, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1);
+ checkVector(v2.add(new Cartesian3D(-2, 0, 2)), -5, -2, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1);
checkVector(v2.add(3, v1), -9, -2, 5, 7, 0, 0, 0, 7, 0, 0, 0, 7);
- checkVector(v2.add(3, new Coordinates3D(-2, 0, 2)), -9, -2, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1);
- checkVector(v2.add(new DerivativeStructure(3, 1, 2, 3), new Coordinates3D(-2, 0, 2)),
+ checkVector(v2.add(3, new Cartesian3D(-2, 0, 2)), -9, -2, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1);
+ checkVector(v2.add(new DerivativeStructure(3, 1, 2, 3), new Cartesian3D(-2, 0, 2)),
-9, -2, 5, 1, 0, -2, 0, 1, 0, 0, 0, 3);
checkVector(createVector(1, 2, 3, 4).add(new DerivativeStructure(4, 1, 3, 5.0),
@@ -508,7 +508,7 @@ public class FieldVector3DTest {
Assert.assertTrue(FastMath.abs(FieldVector3D.angle(v1.toVector3D(), v2).getReal() - 1.2) < 1.0e-12);
try {
- FieldVector3D.angle(v1, Coordinates3D.ZERO);
+ FieldVector3D.angle(v1, Cartesian3D.ZERO);
Assert.fail("an exception should have been thrown");
} catch (MathArithmeticException mae) {
// expected
@@ -605,7 +605,7 @@ public class FieldVector3DTest {
FieldVector3D<DerivativeStructure> uds = createVector(ux, uy, uz, 3);
FieldVector3D<DerivativeStructure> vds = createVector(vx, vy, vz, 3);
- Coordinates3D v = new Coordinates3D(vx, vy, vz);
+ Cartesian3D v = new Cartesian3D(vx, vy, vz);
DerivativeStructure sAccurate = FieldVector3D.dotProduct(uds, vds);
Assert.assertEquals(sNaive, sAccurate.getReal(), 2.5e-16 * sNaive);
@@ -658,11 +658,11 @@ public class FieldVector3DTest {
double vx = random.nextDouble();
double vy = random.nextDouble();
double vz = random.nextDouble();
- Coordinates3D cNaive = new Coordinates3D(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx);
+ Cartesian3D cNaive = new Cartesian3D(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx);
FieldVector3D<DerivativeStructure> uds = createVector(ux, uy, uz, 3);
FieldVector3D<DerivativeStructure> vds = createVector(vx, vy, vz, 3);
- Coordinates3D v = new Coordinates3D(vx, vy, vz);
+ Cartesian3D v = new Cartesian3D(vx, vy, vz);
checkVector(FieldVector3D.crossProduct(uds, vds),
cNaive.getX(), cNaive.getY(), cNaive.getZ(),
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/LineTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/LineTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/LineTest.java
index 16688c9..6cd4962 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/LineTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/LineTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.geometry.euclidean.threed;
import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.geometry.euclidean.threed.Line;
-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;
@@ -28,22 +28,22 @@ public class LineTest {
@Test
public void testContains() throws MathIllegalArgumentException, MathArithmeticException {
- Coordinates3D p1 = new Coordinates3D(0, 0, 1);
- Line l = new Line(p1, new Coordinates3D(0, 0, 2), 1.0e-10);
+ Cartesian3D p1 = new Cartesian3D(0, 0, 1);
+ Line l = new Line(p1, new Cartesian3D(0, 0, 2), 1.0e-10);
Assert.assertTrue(l.contains(p1));
- Assert.assertTrue(l.contains(new Coordinates3D(1.0, p1, 0.3, l.getDirection())));
- Coordinates3D u = l.getDirection().orthogonal();
- Coordinates3D v = Coordinates3D.crossProduct(l.getDirection(), u);
+ Assert.assertTrue(l.contains(new Cartesian3D(1.0, p1, 0.3, l.getDirection())));
+ Cartesian3D u = l.getDirection().orthogonal();
+ Cartesian3D v = Cartesian3D.crossProduct(l.getDirection(), u);
for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) {
- Assert.assertTrue(! l.contains(p1.add(new Coordinates3D(FastMath.cos(alpha), u,
+ Assert.assertTrue(! l.contains(p1.add(new Cartesian3D(FastMath.cos(alpha), u,
FastMath.sin(alpha), v))));
}
}
@Test
public void testSimilar() throws MathIllegalArgumentException, MathArithmeticException {
- Coordinates3D p1 = new Coordinates3D (1.2, 3.4, -5.8);
- Coordinates3D p2 = new Coordinates3D (3.4, -5.8, 1.2);
+ Cartesian3D p1 = new Cartesian3D (1.2, 3.4, -5.8);
+ Cartesian3D p2 = new Cartesian3D (3.4, -5.8, 1.2);
Line lA = new Line(p1, p2, 1.0e-10);
Line lB = new Line(p2, p1, 1.0e-10);
Assert.assertTrue(lA.isSimilarTo(lB));
@@ -52,91 +52,91 @@ public class LineTest {
@Test
public void testPointDistance() throws MathIllegalArgumentException {
- Line l = new Line(new Coordinates3D(0, 1, 1), new Coordinates3D(0, 2, 2), 1.0e-10);
- Assert.assertEquals(FastMath.sqrt(3.0 / 2.0), l.distance(new Coordinates3D(1, 0, 1)), 1.0e-10);
- Assert.assertEquals(0, l.distance(new Coordinates3D(0, -4, -4)), 1.0e-10);
+ Line l = new Line(new Cartesian3D(0, 1, 1), new Cartesian3D(0, 2, 2), 1.0e-10);
+ Assert.assertEquals(FastMath.sqrt(3.0 / 2.0), l.distance(new Cartesian3D(1, 0, 1)), 1.0e-10);
+ Assert.assertEquals(0, l.distance(new Cartesian3D(0, -4, -4)), 1.0e-10);
}
@Test
public void testLineDistance() throws MathIllegalArgumentException {
- Line l = new Line(new Coordinates3D(0, 1, 1), new Coordinates3D(0, 2, 2), 1.0e-10);
+ Line l = new Line(new Cartesian3D(0, 1, 1), new Cartesian3D(0, 2, 2), 1.0e-10);
Assert.assertEquals(1.0,
- l.distance(new Line(new Coordinates3D(1, 0, 1), new Coordinates3D(1, 0, 2), 1.0e-10)),
+ l.distance(new Line(new Cartesian3D(1, 0, 1), new Cartesian3D(1, 0, 2), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.5,
- l.distance(new Line(new Coordinates3D(-0.5, 0, 0), new Coordinates3D(-0.5, -1, -1), 1.0e-10)),
+ l.distance(new Line(new Cartesian3D(-0.5, 0, 0), new Cartesian3D(-0.5, -1, -1), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.0,
l.distance(l),
1.0e-10);
Assert.assertEquals(0.0,
- l.distance(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(0, -5, -5), 1.0e-10)),
+ l.distance(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(0, -5, -5), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.0,
- l.distance(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(0, -3, -4), 1.0e-10)),
+ l.distance(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(0, -3, -4), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.0,
- l.distance(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(1, -4, -4), 1.0e-10)),
+ l.distance(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(1, -4, -4), 1.0e-10)),
1.0e-10);
Assert.assertEquals(FastMath.sqrt(8),
- l.distance(new Line(new Coordinates3D(0, -4, 0), new Coordinates3D(1, -4, 0), 1.0e-10)),
+ l.distance(new Line(new Cartesian3D(0, -4, 0), new Cartesian3D(1, -4, 0), 1.0e-10)),
1.0e-10);
}
@Test
public void testClosest() throws MathIllegalArgumentException {
- Line l = new Line(new Coordinates3D(0, 1, 1), new Coordinates3D(0, 2, 2), 1.0e-10);
+ Line l = new Line(new Cartesian3D(0, 1, 1), new Cartesian3D(0, 2, 2), 1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Coordinates3D(1, 0, 1), new Coordinates3D(1, 0, 2), 1.0e-10)).distance(new Coordinates3D(0, 0, 0)),
+ l.closestPoint(new Line(new Cartesian3D(1, 0, 1), new Cartesian3D(1, 0, 2), 1.0e-10)).distance(new Cartesian3D(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.5,
- l.closestPoint(new Line(new Coordinates3D(-0.5, 0, 0), new Coordinates3D(-0.5, -1, -1), 1.0e-10)).distance(new Coordinates3D(-0.5, 0, 0)),
+ l.closestPoint(new Line(new Cartesian3D(-0.5, 0, 0), new Cartesian3D(-0.5, -1, -1), 1.0e-10)).distance(new Cartesian3D(-0.5, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(l).distance(new Coordinates3D(0, 0, 0)),
+ l.closestPoint(l).distance(new Cartesian3D(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(0, -5, -5), 1.0e-10)).distance(new Coordinates3D(0, 0, 0)),
+ l.closestPoint(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(0, -5, -5), 1.0e-10)).distance(new Cartesian3D(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(0, -3, -4), 1.0e-10)).distance(new Coordinates3D(0, -4, -4)),
+ l.closestPoint(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(0, -3, -4), 1.0e-10)).distance(new Cartesian3D(0, -4, -4)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(1, -4, -4), 1.0e-10)).distance(new Coordinates3D(0, -4, -4)),
+ l.closestPoint(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(1, -4, -4), 1.0e-10)).distance(new Cartesian3D(0, -4, -4)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Coordinates3D(0, -4, 0), new Coordinates3D(1, -4, 0), 1.0e-10)).distance(new Coordinates3D(0, -2, -2)),
+ l.closestPoint(new Line(new Cartesian3D(0, -4, 0), new Cartesian3D(1, -4, 0), 1.0e-10)).distance(new Cartesian3D(0, -2, -2)),
1.0e-10);
}
@Test
public void testIntersection() throws MathIllegalArgumentException {
- Line l = new Line(new Coordinates3D(0, 1, 1), new Coordinates3D(0, 2, 2), 1.0e-10);
- Assert.assertNull(l.intersection(new Line(new Coordinates3D(1, 0, 1), new Coordinates3D(1, 0, 2), 1.0e-10)));
- Assert.assertNull(l.intersection(new Line(new Coordinates3D(-0.5, 0, 0), new Coordinates3D(-0.5, -1, -1), 1.0e-10)));
+ Line l = new Line(new Cartesian3D(0, 1, 1), new Cartesian3D(0, 2, 2), 1.0e-10);
+ Assert.assertNull(l.intersection(new Line(new Cartesian3D(1, 0, 1), new Cartesian3D(1, 0, 2), 1.0e-10)));
+ Assert.assertNull(l.intersection(new Line(new Cartesian3D(-0.5, 0, 0), new Cartesian3D(-0.5, -1, -1), 1.0e-10)));
Assert.assertEquals(0.0,
- l.intersection(l).distance(new Coordinates3D(0, 0, 0)),
+ l.intersection(l).distance(new Cartesian3D(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.intersection(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(0, -5, -5), 1.0e-10)).distance(new Coordinates3D(0, 0, 0)),
+ l.intersection(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(0, -5, -5), 1.0e-10)).distance(new Cartesian3D(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.intersection(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(0, -3, -4), 1.0e-10)).distance(new Coordinates3D(0, -4, -4)),
+ l.intersection(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(0, -3, -4), 1.0e-10)).distance(new Cartesian3D(0, -4, -4)),
1.0e-10);
Assert.assertEquals(0.0,
- l.intersection(new Line(new Coordinates3D(0, -4, -4), new Coordinates3D(1, -4, -4), 1.0e-10)).distance(new Coordinates3D(0, -4, -4)),
+ l.intersection(new Line(new Cartesian3D(0, -4, -4), new Cartesian3D(1, -4, -4), 1.0e-10)).distance(new Cartesian3D(0, -4, -4)),
1.0e-10);
- Assert.assertNull(l.intersection(new Line(new Coordinates3D(0, -4, 0), new Coordinates3D(1, -4, 0), 1.0e-10)));
+ Assert.assertNull(l.intersection(new Line(new Cartesian3D(0, -4, 0), new Cartesian3D(1, -4, 0), 1.0e-10)));
}
@Test
public void testRevert() {
// setup
- Line line = new Line(new Coordinates3D(1653345.6696423641, 6170370.041579291, 90000),
- new Coordinates3D(1650757.5050732433, 6160710.879908984, 0.9),
+ Line line = new Line(new Cartesian3D(1653345.6696423641, 6170370.041579291, 90000),
+ new Cartesian3D(1650757.5050732433, 6160710.879908984, 0.9),
1.0e-10);
- Coordinates3D expected = line.getDirection().negate();
+ Cartesian3D expected = line.getDirection().negate();
// action
Line reverted = line.revert();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java
index 5439d8d..4413223 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PLYParser.java
@@ -40,7 +40,7 @@ import org.apache.commons.math4.util.Precision;
public class PLYParser {
/** Parsed vertices. */
- private Coordinates3D[] vertices;
+ private Cartesian3D[] vertices;
/** Parsed faces. */
private int[][] faces;
@@ -167,7 +167,7 @@ public class PLYParser {
++vPropertiesNumber;
// parse vertices
- vertices = new Coordinates3D[nbVertices];
+ vertices = new Cartesian3D[nbVertices];
for (int i = 0; i < nbVertices; ++i) {
fields = parseNextLine();
if (fields.size() != vPropertiesNumber ||
@@ -176,7 +176,7 @@ public class PLYParser {
fields.get(zIndex).getToken() != Token.UNKNOWN) {
complain();
}
- vertices[i] = new Coordinates3D(Double.parseDouble(fields.get(xIndex).getValue()),
+ vertices[i] = new Cartesian3D(Double.parseDouble(fields.get(xIndex).getValue()),
Double.parseDouble(fields.get(yIndex).getValue()),
Double.parseDouble(fields.get(zIndex).getValue()));
}
@@ -229,7 +229,7 @@ public class PLYParser {
/** Get the parsed vertices.
* @return parsed vertices
*/
- public List<Coordinates3D> getVertices() {
+ public List<Cartesian3D> getVertices() {
return Arrays.asList(vertices);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
index 53de398..54c975e 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.geometry.euclidean.threed.Line;
import org.apache.commons.math4.geometry.euclidean.threed.Plane;
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.junit.Assert;
import org.junit.Test;
@@ -29,37 +29,37 @@ public class PlaneTest {
@Test
public void testContains() throws MathArithmeticException {
- Plane p = new Plane(new Coordinates3D(0, 0, 1), new Coordinates3D(0, 0, 1), 1.0e-10);
- Assert.assertTrue(p.contains(new Coordinates3D(0, 0, 1)));
- Assert.assertTrue(p.contains(new Coordinates3D(17, -32, 1)));
- Assert.assertTrue(! p.contains(new Coordinates3D(17, -32, 1.001)));
+ Plane p = new Plane(new Cartesian3D(0, 0, 1), new Cartesian3D(0, 0, 1), 1.0e-10);
+ Assert.assertTrue(p.contains(new Cartesian3D(0, 0, 1)));
+ Assert.assertTrue(p.contains(new Cartesian3D(17, -32, 1)));
+ Assert.assertTrue(! p.contains(new Cartesian3D(17, -32, 1.001)));
}
@Test
public void testOffset() throws MathArithmeticException {
- Coordinates3D p1 = new Coordinates3D(1, 1, 1);
- Plane p = new Plane(p1, new Coordinates3D(0.2, 0, 0), 1.0e-10);
- Assert.assertEquals(-5.0, p.getOffset(new Coordinates3D(-4, 0, 0)), 1.0e-10);
- Assert.assertEquals(+5.0, p.getOffset(new Coordinates3D(6, 10, -12)), 1.0e-10);
+ Cartesian3D p1 = new Cartesian3D(1, 1, 1);
+ Plane p = new Plane(p1, new Cartesian3D(0.2, 0, 0), 1.0e-10);
+ Assert.assertEquals(-5.0, p.getOffset(new Cartesian3D(-4, 0, 0)), 1.0e-10);
+ Assert.assertEquals(+5.0, p.getOffset(new Cartesian3D(6, 10, -12)), 1.0e-10);
Assert.assertEquals(0.3,
- p.getOffset(new Coordinates3D(1.0, p1, 0.3, p.getNormal())),
+ p.getOffset(new Cartesian3D(1.0, p1, 0.3, p.getNormal())),
1.0e-10);
Assert.assertEquals(-0.3,
- p.getOffset(new Coordinates3D(1.0, p1, -0.3, p.getNormal())),
+ p.getOffset(new Cartesian3D(1.0, p1, -0.3, p.getNormal())),
1.0e-10);
}
@Test
public void testPoint() throws MathArithmeticException {
- Plane p = new Plane(new Coordinates3D(2, -3, 1), new Coordinates3D(1, 4, 9), 1.0e-10);
+ Plane p = new Plane(new Cartesian3D(2, -3, 1), new Cartesian3D(1, 4, 9), 1.0e-10);
Assert.assertTrue(p.contains(p.getOrigin()));
}
@Test
public void testThreePoints() throws MathArithmeticException {
- Coordinates3D p1 = new Coordinates3D(1.2, 3.4, -5.8);
- Coordinates3D p2 = new Coordinates3D(3.4, -5.8, 1.2);
- Coordinates3D p3 = new Coordinates3D(-2.0, 4.3, 0.7);
+ Cartesian3D p1 = new Cartesian3D(1.2, 3.4, -5.8);
+ Cartesian3D p2 = new Cartesian3D(3.4, -5.8, 1.2);
+ Cartesian3D p3 = new Cartesian3D(-2.0, 4.3, 0.7);
Plane p = new Plane(p1, p2, p3, 1.0e-10);
Assert.assertTrue(p.contains(p1));
Assert.assertTrue(p.contains(p2));
@@ -68,11 +68,11 @@ public class PlaneTest {
@Test
public void testRotate() throws MathArithmeticException, MathIllegalArgumentException {
- Coordinates3D p1 = new Coordinates3D(1.2, 3.4, -5.8);
- Coordinates3D p2 = new Coordinates3D(3.4, -5.8, 1.2);
- Coordinates3D p3 = new Coordinates3D(-2.0, 4.3, 0.7);
+ Cartesian3D p1 = new Cartesian3D(1.2, 3.4, -5.8);
+ Cartesian3D p2 = new Cartesian3D(3.4, -5.8, 1.2);
+ Cartesian3D p3 = new Cartesian3D(-2.0, 4.3, 0.7);
Plane p = new Plane(p1, p2, p3, 1.0e-10);
- Coordinates3D oldNormal = p.getNormal();
+ Cartesian3D oldNormal = p.getNormal();
p = p.rotate(p2, new Rotation(p2.subtract(p1), 1.7, RotationConvention.VECTOR_OPERATOR));
Assert.assertTrue(p.contains(p1));
@@ -93,22 +93,22 @@ public class PlaneTest {
@Test
public void testTranslate() throws MathArithmeticException {
- Coordinates3D p1 = new Coordinates3D(1.2, 3.4, -5.8);
- Coordinates3D p2 = new Coordinates3D(3.4, -5.8, 1.2);
- Coordinates3D p3 = new Coordinates3D(-2.0, 4.3, 0.7);
+ Cartesian3D p1 = new Cartesian3D(1.2, 3.4, -5.8);
+ Cartesian3D p2 = new Cartesian3D(3.4, -5.8, 1.2);
+ Cartesian3D p3 = new Cartesian3D(-2.0, 4.3, 0.7);
Plane p = new Plane(p1, p2, p3, 1.0e-10);
- p = p.translate(new Coordinates3D(2.0, p.getU(), -1.5, p.getV()));
+ p = p.translate(new Cartesian3D(2.0, p.getU(), -1.5, p.getV()));
Assert.assertTrue(p.contains(p1));
Assert.assertTrue(p.contains(p2));
Assert.assertTrue(p.contains(p3));
- p = p.translate(new Coordinates3D(-1.2, p.getNormal()));
+ p = p.translate(new Cartesian3D(-1.2, p.getNormal()));
Assert.assertTrue(! p.contains(p1));
Assert.assertTrue(! p.contains(p2));
Assert.assertTrue(! p.contains(p3));
- p = p.translate(new Coordinates3D(+1.2, p.getNormal()));
+ p = p.translate(new Cartesian3D(+1.2, p.getNormal()));
Assert.assertTrue(p.contains(p1));
Assert.assertTrue(p.contains(p2));
Assert.assertTrue(p.contains(p3));
@@ -117,22 +117,22 @@ public class PlaneTest {
@Test
public void testIntersection() throws MathArithmeticException, MathIllegalArgumentException {
- Plane p = new Plane(new Coordinates3D(1, 2, 3), new Coordinates3D(-4, 1, -5), 1.0e-10);
- Line l = new Line(new Coordinates3D(0.2, -3.5, 0.7), new Coordinates3D(1.2, -2.5, -0.3), 1.0e-10);
- Coordinates3D point = p.intersection(l);
+ Plane p = new Plane(new Cartesian3D(1, 2, 3), new Cartesian3D(-4, 1, -5), 1.0e-10);
+ Line l = new Line(new Cartesian3D(0.2, -3.5, 0.7), new Cartesian3D(1.2, -2.5, -0.3), 1.0e-10);
+ Cartesian3D point = p.intersection(l);
Assert.assertTrue(p.contains(point));
Assert.assertTrue(l.contains(point));
- Assert.assertNull(p.intersection(new Line(new Coordinates3D(10, 10, 10),
- new Coordinates3D(10, 10, 10).add(p.getNormal().orthogonal()),
+ Assert.assertNull(p.intersection(new Line(new Cartesian3D(10, 10, 10),
+ new Cartesian3D(10, 10, 10).add(p.getNormal().orthogonal()),
1.0e-10)));
}
@Test
public void testIntersection2() throws MathArithmeticException {
- Coordinates3D p1 = new Coordinates3D (1.2, 3.4, -5.8);
- Coordinates3D p2 = new Coordinates3D (3.4, -5.8, 1.2);
- Plane pA = new Plane(p1, p2, new Coordinates3D (-2.0, 4.3, 0.7), 1.0e-10);
- Plane pB = new Plane(p1, new Coordinates3D (11.4, -3.8, 5.1), p2, 1.0e-10);
+ Cartesian3D p1 = new Cartesian3D (1.2, 3.4, -5.8);
+ Cartesian3D p2 = new Cartesian3D (3.4, -5.8, 1.2);
+ Plane pA = new Plane(p1, p2, new Cartesian3D (-2.0, 4.3, 0.7), 1.0e-10);
+ Plane pB = new Plane(p1, new Cartesian3D (11.4, -3.8, 5.1), p2, 1.0e-10);
Line l = pA.intersection(pB);
Assert.assertTrue(l.contains(p1));
Assert.assertTrue(l.contains(p2));
@@ -141,11 +141,11 @@ public class PlaneTest {
@Test
public void testIntersection3() throws MathArithmeticException {
- Coordinates3D reference = new Coordinates3D (1.2, 3.4, -5.8);
- Plane p1 = new Plane(reference, new Coordinates3D(1, 3, 3), 1.0e-10);
- Plane p2 = new Plane(reference, new Coordinates3D(-2, 4, 0), 1.0e-10);
- Plane p3 = new Plane(reference, new Coordinates3D(7, 0, -4), 1.0e-10);
- Coordinates3D p = Plane.intersection(p1, p2, p3);
+ Cartesian3D reference = new Cartesian3D (1.2, 3.4, -5.8);
+ Plane p1 = new Plane(reference, new Cartesian3D(1, 3, 3), 1.0e-10);
+ Plane p2 = new Plane(reference, new Cartesian3D(-2, 4, 0), 1.0e-10);
+ Plane p3 = new Plane(reference, new Cartesian3D(7, 0, -4), 1.0e-10);
+ Cartesian3D p = Plane.intersection(p1, p2, p3);
Assert.assertEquals(reference.getX(), p.getX(), 1.0e-10);
Assert.assertEquals(reference.getY(), p.getY(), 1.0e-10);
Assert.assertEquals(reference.getZ(), p.getZ(), 1.0e-10);
@@ -153,15 +153,15 @@ public class PlaneTest {
@Test
public void testSimilar() throws MathArithmeticException {
- Coordinates3D p1 = new Coordinates3D (1.2, 3.4, -5.8);
- Coordinates3D p2 = new Coordinates3D (3.4, -5.8, 1.2);
- Coordinates3D p3 = new Coordinates3D (-2.0, 4.3, 0.7);
+ Cartesian3D p1 = new Cartesian3D (1.2, 3.4, -5.8);
+ Cartesian3D p2 = new Cartesian3D (3.4, -5.8, 1.2);
+ Cartesian3D p3 = new Cartesian3D (-2.0, 4.3, 0.7);
Plane pA = new Plane(p1, p2, p3, 1.0e-10);
- Plane pB = new Plane(p1, new Coordinates3D (11.4, -3.8, 5.1), p2, 1.0e-10);
+ Plane pB = new Plane(p1, new Cartesian3D (11.4, -3.8, 5.1), p2, 1.0e-10);
Assert.assertTrue(! pA.isSimilarTo(pB));
Assert.assertTrue(pA.isSimilarTo(pA));
Assert.assertTrue(pA.isSimilarTo(new Plane(p1, p3, p2, 1.0e-10)));
- Coordinates3D shift = new Coordinates3D(0.3, pA.getNormal());
+ Cartesian3D shift = new Cartesian3D(0.3, pA.getNormal());
Assert.assertTrue(! pA.isSimilarTo(new Plane(p1.add(shift),
p3.add(shift),
p2.add(shift),
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
index 73b1168..43553ea 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
@@ -37,11 +37,11 @@ import org.apache.commons.math4.geometry.euclidean.threed.Plane;
import org.apache.commons.math4.geometry.euclidean.threed.PolyhedronsSet;
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
import org.apache.commons.math4.geometry.euclidean.threed.SubPlane;
-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.twod.Euclidean2D;
import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet;
import org.apache.commons.math4.geometry.euclidean.twod.SubLine;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor;
import org.apache.commons.math4.geometry.partitioning.BoundaryAttribute;
@@ -63,7 +63,7 @@ public class PolyhedronsSetTest {
PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1, 1.0e-10);
Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
- Coordinates3D barycenter = (Coordinates3D) tree.getBarycenter();
+ Cartesian3D barycenter = (Cartesian3D) tree.getBarycenter();
Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
@@ -75,34 +75,34 @@ public class PolyhedronsSetTest {
boolean zOK = (z >= 0.0) && (z <= 1.0);
Region.Location expected =
(xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
- Assert.assertEquals(expected, tree.checkPoint(new Coordinates3D(x, y, z)));
+ Assert.assertEquals(expected, tree.checkPoint(new Cartesian3D(x, y, z)));
}
}
}
- checkPoints(Region.Location.BOUNDARY, tree, new Coordinates3D[] {
- new Coordinates3D(0.0, 0.5, 0.5),
- new Coordinates3D(1.0, 0.5, 0.5),
- new Coordinates3D(0.5, 0.0, 0.5),
- new Coordinates3D(0.5, 1.0, 0.5),
- new Coordinates3D(0.5, 0.5, 0.0),
- new Coordinates3D(0.5, 0.5, 1.0)
+ checkPoints(Region.Location.BOUNDARY, tree, new Cartesian3D[] {
+ new Cartesian3D(0.0, 0.5, 0.5),
+ new Cartesian3D(1.0, 0.5, 0.5),
+ new Cartesian3D(0.5, 0.0, 0.5),
+ new Cartesian3D(0.5, 1.0, 0.5),
+ new Cartesian3D(0.5, 0.5, 0.0),
+ new Cartesian3D(0.5, 0.5, 1.0)
});
- checkPoints(Region.Location.OUTSIDE, tree, new Coordinates3D[] {
- new Coordinates3D(0.0, 1.2, 1.2),
- new Coordinates3D(1.0, 1.2, 1.2),
- new Coordinates3D(1.2, 0.0, 1.2),
- new Coordinates3D(1.2, 1.0, 1.2),
- new Coordinates3D(1.2, 1.2, 0.0),
- new Coordinates3D(1.2, 1.2, 1.0)
+ checkPoints(Region.Location.OUTSIDE, tree, new Cartesian3D[] {
+ new Cartesian3D(0.0, 1.2, 1.2),
+ new Cartesian3D(1.0, 1.2, 1.2),
+ new Cartesian3D(1.2, 0.0, 1.2),
+ new Cartesian3D(1.2, 1.0, 1.2),
+ new Cartesian3D(1.2, 1.2, 0.0),
+ new Cartesian3D(1.2, 1.2, 1.0)
});
}
@Test
public void testTetrahedron() throws MathArithmeticException {
- Coordinates3D vertex1 = new Coordinates3D(1, 2, 3);
- Coordinates3D vertex2 = new Coordinates3D(2, 2, 4);
- Coordinates3D vertex3 = new Coordinates3D(2, 3, 3);
- Coordinates3D vertex4 = new Coordinates3D(1, 3, 4);
+ Cartesian3D vertex1 = new Cartesian3D(1, 2, 3);
+ Cartesian3D vertex2 = new Cartesian3D(2, 2, 4);
+ Cartesian3D vertex3 = new Cartesian3D(2, 3, 3);
+ Cartesian3D vertex4 = new Cartesian3D(1, 3, 4);
PolyhedronsSet tree =
(PolyhedronsSet) new RegionFactory<Euclidean3D>().buildConvex(
new Plane(vertex3, vertex2, vertex1, 1.0e-10),
@@ -111,64 +111,64 @@ public class PolyhedronsSetTest {
new Plane(vertex1, vertex2, vertex4, 1.0e-10));
Assert.assertEquals(1.0 / 3.0, tree.getSize(), 1.0e-10);
Assert.assertEquals(2.0 * FastMath.sqrt(3.0), tree.getBoundarySize(), 1.0e-10);
- Coordinates3D barycenter = (Coordinates3D) tree.getBarycenter();
+ Cartesian3D barycenter = (Cartesian3D) tree.getBarycenter();
Assert.assertEquals(1.5, barycenter.getX(), 1.0e-10);
Assert.assertEquals(2.5, barycenter.getY(), 1.0e-10);
Assert.assertEquals(3.5, barycenter.getZ(), 1.0e-10);
double third = 1.0 / 3.0;
- checkPoints(Region.Location.BOUNDARY, tree, new Coordinates3D[] {
+ checkPoints(Region.Location.BOUNDARY, tree, new Cartesian3D[] {
vertex1, vertex2, vertex3, vertex4,
- new Coordinates3D(third, vertex1, third, vertex2, third, vertex3),
- new Coordinates3D(third, vertex2, third, vertex3, third, vertex4),
- new Coordinates3D(third, vertex3, third, vertex4, third, vertex1),
- new Coordinates3D(third, vertex4, third, vertex1, third, vertex2)
+ new Cartesian3D(third, vertex1, third, vertex2, third, vertex3),
+ new Cartesian3D(third, vertex2, third, vertex3, third, vertex4),
+ new Cartesian3D(third, vertex3, third, vertex4, third, vertex1),
+ new Cartesian3D(third, vertex4, third, vertex1, third, vertex2)
});
- checkPoints(Region.Location.OUTSIDE, tree, new Coordinates3D[] {
- new Coordinates3D(1, 2, 4),
- new Coordinates3D(2, 2, 3),
- new Coordinates3D(2, 3, 4),
- new Coordinates3D(1, 3, 3)
+ checkPoints(Region.Location.OUTSIDE, tree, new Cartesian3D[] {
+ new Cartesian3D(1, 2, 4),
+ new Cartesian3D(2, 2, 3),
+ new Cartesian3D(2, 3, 4),
+ new Cartesian3D(1, 3, 3)
});
}
@Test
public void testIsometry() throws MathArithmeticException, MathIllegalArgumentException {
- Coordinates3D vertex1 = new Coordinates3D(1.1, 2.2, 3.3);
- Coordinates3D vertex2 = new Coordinates3D(2.0, 2.4, 4.2);
- Coordinates3D vertex3 = new Coordinates3D(2.8, 3.3, 3.7);
- Coordinates3D vertex4 = new Coordinates3D(1.0, 3.6, 4.5);
+ Cartesian3D vertex1 = new Cartesian3D(1.1, 2.2, 3.3);
+ Cartesian3D vertex2 = new Cartesian3D(2.0, 2.4, 4.2);
+ Cartesian3D vertex3 = new Cartesian3D(2.8, 3.3, 3.7);
+ Cartesian3D vertex4 = new Cartesian3D(1.0, 3.6, 4.5);
PolyhedronsSet tree =
(PolyhedronsSet) new RegionFactory<Euclidean3D>().buildConvex(
new Plane(vertex3, vertex2, vertex1, 1.0e-10),
new Plane(vertex2, vertex3, vertex4, 1.0e-10),
new Plane(vertex4, vertex3, vertex1, 1.0e-10),
new Plane(vertex1, vertex2, vertex4, 1.0e-10));
- Coordinates3D barycenter = (Coordinates3D) tree.getBarycenter();
- Coordinates3D s = new Coordinates3D(10.2, 4.3, -6.7);
- Coordinates3D c = new Coordinates3D(-0.2, 2.1, -3.2);
- Rotation r = new Rotation(new Coordinates3D(6.2, -4.4, 2.1), 0.12, RotationConvention.VECTOR_OPERATOR);
+ Cartesian3D barycenter = (Cartesian3D) tree.getBarycenter();
+ Cartesian3D s = new Cartesian3D(10.2, 4.3, -6.7);
+ Cartesian3D c = new Cartesian3D(-0.2, 2.1, -3.2);
+ Rotation r = new Rotation(new Cartesian3D(6.2, -4.4, 2.1), 0.12, RotationConvention.VECTOR_OPERATOR);
tree = tree.rotate(c, r).translate(s);
- Coordinates3D newB =
- new Coordinates3D(1.0, s,
+ Cartesian3D newB =
+ new Cartesian3D(1.0, s,
1.0, c,
1.0, r.applyTo(barycenter.subtract(c)));
Assert.assertEquals(0.0,
newB.subtract((Vector<Euclidean3D>) tree.getBarycenter()).getNorm(),
1.0e-10);
- final Coordinates3D[] expectedV = new Coordinates3D[] {
- new Coordinates3D(1.0, s,
+ final Cartesian3D[] expectedV = new Cartesian3D[] {
+ new Cartesian3D(1.0, s,
1.0, c,
1.0, r.applyTo(vertex1.subtract(c))),
- new Coordinates3D(1.0, s,
+ new Cartesian3D(1.0, s,
1.0, c,
1.0, r.applyTo(vertex2.subtract(c))),
- new Coordinates3D(1.0, s,
+ new Cartesian3D(1.0, s,
1.0, c,
1.0, r.applyTo(vertex3.subtract(c))),
- new Coordinates3D(1.0, s,
+ new Cartesian3D(1.0, s,
1.0, c,
1.0, r.applyTo(vertex4.subtract(c)))
};
@@ -198,11 +198,11 @@ public class PolyhedronsSetTest {
private void checkFacet(SubPlane facet) {
Plane plane = (Plane) facet.getHyperplane();
- Coordinates2D[][] vertices =
+ Cartesian2D[][] vertices =
((PolygonsSet) facet.getRemainingRegion()).getVertices();
Assert.assertEquals(1, vertices.length);
for (int i = 0; i < vertices[0].length; ++i) {
- Coordinates3D v = plane.toSpace(vertices[0][i]);
+ Cartesian3D v = plane.toSpace(vertices[0][i]);
double d = Double.POSITIVE_INFINITY;
for (int k = 0; k < expectedV.length; ++k) {
d = FastMath.min(d, v.subtract(expectedV[k]).getNorm());
@@ -224,7 +224,7 @@ public class PolyhedronsSetTest {
double l = 1.0;
PolyhedronsSet tree =
new PolyhedronsSet(x - l, x + l, y - w, y + w, z - w, z + w, 1.0e-10);
- Coordinates3D barycenter = (Coordinates3D) tree.getBarycenter();
+ Cartesian3D barycenter = (Cartesian3D) tree.getBarycenter();
Assert.assertEquals(x, barycenter.getX(), 1.0e-10);
Assert.assertEquals(y, barycenter.getY(), 1.0e-10);
Assert.assertEquals(z, barycenter.getZ(), 1.0e-10);
@@ -248,7 +248,7 @@ public class PolyhedronsSetTest {
new PolyhedronsSet(x - w, x + w, y - w, y + w, z - l, z + l, 1.0e-10);
RegionFactory<Euclidean3D> factory = new RegionFactory<>();
PolyhedronsSet tree = (PolyhedronsSet) factory.union(xBeam, factory.union(yBeam, zBeam));
- Coordinates3D barycenter = (Coordinates3D) tree.getBarycenter();
+ Cartesian3D barycenter = (Cartesian3D) tree.getBarycenter();
Assert.assertEquals(x, barycenter.getX(), 1.0e-10);
Assert.assertEquals(y, barycenter.getY(), 1.0e-10);
@@ -281,14 +281,14 @@ public class PolyhedronsSetTest {
int idxA = indices[idx] * 3;
int idxB = indices[idx + 1] * 3;
int idxC = indices[idx + 2] * 3;
- Coordinates3D v_1 = new Coordinates3D(coords[idxA], coords[idxA + 1], coords[idxA + 2]);
- Coordinates3D v_2 = new Coordinates3D(coords[idxB], coords[idxB + 1], coords[idxB + 2]);
- Coordinates3D v_3 = new Coordinates3D(coords[idxC], coords[idxC + 1], coords[idxC + 2]);
- Coordinates3D[] vertices = {v_1, v_2, v_3};
+ Cartesian3D v_1 = new Cartesian3D(coords[idxA], coords[idxA + 1], coords[idxA + 2]);
+ Cartesian3D v_2 = new Cartesian3D(coords[idxB], coords[idxB + 1], coords[idxB + 2]);
+ Cartesian3D v_3 = new Cartesian3D(coords[idxC], coords[idxC + 1], coords[idxC + 2]);
+ Cartesian3D[] vertices = {v_1, v_2, v_3};
Plane polyPlane = new Plane(v_1, v_2, v_3, 1.0e-10);
ArrayList<SubHyperplane<Euclidean2D>> lines = new ArrayList<>();
- Coordinates2D[] projPts = new Coordinates2D[vertices.length];
+ Cartesian2D[] projPts = new Cartesian2D[vertices.length];
for (int ptIdx = 0; ptIdx < projPts.length; ptIdx++) {
projPts[ptIdx] = polyPlane.toSubSpace(vertices[ptIdx]);
}
@@ -322,7 +322,7 @@ public class PolyhedronsSetTest {
PolyhedronsSet ps = new PolyhedronsSet(new BSPTree<Euclidean3D>(), 1.0e-10);
Assert.assertNotNull(ps);
try {
- ps.checkPoint(Coordinates3D.ZERO);
+ ps.checkPoint(Cartesian3D.ZERO);
Assert.fail("an exception should have been thrown");
} catch (NullPointerException npe) {
// this is expected
@@ -333,18 +333,18 @@ public class PolyhedronsSetTest {
public void testDumpParse() throws IOException, ParseException {
double tol=1e-8;
- Coordinates3D[] verts=new Coordinates3D[8];
+ Cartesian3D[] verts=new Cartesian3D[8];
double xmin=-1,xmax=1;
double ymin=-1,ymax=1;
double zmin=-1,zmax=1;
- verts[0]=new Coordinates3D(xmin,ymin,zmin);
- verts[1]=new Coordinates3D(xmax,ymin,zmin);
- verts[2]=new Coordinates3D(xmax,ymax,zmin);
- verts[3]=new Coordinates3D(xmin,ymax,zmin);
- verts[4]=new Coordinates3D(xmin,ymin,zmax);
- verts[5]=new Coordinates3D(xmax,ymin,zmax);
- verts[6]=new Coordinates3D(xmax,ymax,zmax);
- verts[7]=new Coordinates3D(xmin,ymax,zmax);
+ verts[0]=new Cartesian3D(xmin,ymin,zmin);
+ verts[1]=new Cartesian3D(xmax,ymin,zmin);
+ verts[2]=new Cartesian3D(xmax,ymax,zmin);
+ verts[3]=new Cartesian3D(xmin,ymax,zmin);
+ verts[4]=new Cartesian3D(xmin,ymin,zmax);
+ verts[5]=new Cartesian3D(xmax,ymin,zmax);
+ verts[6]=new Cartesian3D(xmax,ymax,zmax);
+ verts[7]=new Cartesian3D(xmin,ymax,zmax);
//
int[][] faces=new int[12][];
faces[0]=new int[]{3,1,0}; // bottom (-z)
@@ -401,7 +401,7 @@ public class PolyhedronsSetTest {
@Test
public void testFacet2Vertices() throws IOException, ParseException {
- checkError(Arrays.asList(Coordinates3D.ZERO, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, Coordinates3D.PLUS_K),
+ checkError(Arrays.asList(Cartesian3D.ZERO, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, Cartesian3D.PLUS_K),
Arrays.asList(new int[] { 0, 1, 2 }, new int[] {2, 3}),
LocalizedFormats.WRONG_NUMBER_OF_POINTS);
}
@@ -419,7 +419,7 @@ public class PolyhedronsSetTest {
}
}
- private void checkError(final List<Coordinates3D> vertices, final List<int[]> facets,
+ private void checkError(final List<Cartesian3D> vertices, final List<int[]> facets,
final LocalizedFormats expected) {
try {
new PolyhedronsSet(vertices, facets, 1.0e-10);
@@ -446,14 +446,14 @@ public class PolyhedronsSetTest {
UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xb97c9d1ade21e40al);
int nrays = 1000;
for (int i = 0; i < nrays; i++) {
- Coordinates3D origin = Coordinates3D.ZERO;
- Coordinates3D direction = new Coordinates3D(2 * random.nextDouble() - 1,
+ Cartesian3D origin = Cartesian3D.ZERO;
+ Cartesian3D direction = new Cartesian3D(2 * random.nextDouble() - 1,
2 * random.nextDouble() - 1,
2 * random.nextDouble() - 1).normalize();
Line line = new Line(origin, origin.add(direction), polyset.getTolerance());
SubHyperplane<Euclidean3D> plane = polyset.firstIntersection(origin, line);
if (plane != null) {
- Coordinates3D intersectionPoint = ((Plane)plane.getHyperplane()).intersection(line);
+ Cartesian3D intersectionPoint = ((Plane)plane.getHyperplane()).intersection(line);
double dotProduct = direction.dotProduct(intersectionPoint.subtract(origin));
Assert.assertTrue(dotProduct > 0);
}
@@ -471,7 +471,7 @@ public class PolyhedronsSetTest {
return builder.toString();
}
- private void checkPoints(Region.Location expected, PolyhedronsSet tree, Coordinates3D[] points) {
+ private void checkPoints(Region.Location expected, PolyhedronsSet tree, Cartesian3D[] points) {
for (int i = 0; i < points.length; ++i) {
Assert.assertEquals(expected, tree.checkPoint(points[i]));
}