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/12 21:32:21 UTC
[12/31] [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/spherical/twod/SphericalPolygonsSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java
index 22fb232..4096a59 100644
--- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSetTest.java
@@ -21,7 +21,7 @@ import java.util.List;
import org.apache.commons.math4.geometry.enclosing.EnclosingBall;
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.apache.commons.math4.geometry.partitioning.RegionFactory;
import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
import org.apache.commons.math4.geometry.partitioning.Region.Location;
@@ -50,7 +50,7 @@ public class SphericalPolygonsSetTest {
new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0x852fd2a0ed8d2f6dl));
for (int i = 0; i < 1000; ++i) {
- Coordinates3D v = new Coordinates3D(random.nextVector());
+ Cartesian3D v = new Cartesian3D(random.nextVector());
Assert.assertEquals(Location.INSIDE, full.checkPoint(new S2Point(v)));
}
Assert.assertEquals(4 * FastMath.PI, new SphericalPolygonsSet(0.01, new S2Point[0]).getSize(), 1.0e-10);
@@ -68,7 +68,7 @@ public class SphericalPolygonsSetTest {
new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0x76d9205d6167b6ddl));
for (int i = 0; i < 1000; ++i) {
- Coordinates3D v = new Coordinates3D(random.nextVector());
+ Cartesian3D v = new Cartesian3D(random.nextVector());
Assert.assertEquals(Location.OUTSIDE, empty.checkPoint(new S2Point(v)));
}
Assert.assertEquals(0, empty.getSize(), 1.0e-10);
@@ -82,12 +82,12 @@ public class SphericalPolygonsSetTest {
public void testSouthHemisphere() {
double tol = 0.01;
double sinTol = FastMath.sin(tol);
- SphericalPolygonsSet south = new SphericalPolygonsSet(Coordinates3D.MINUS_K, tol);
+ SphericalPolygonsSet south = new SphericalPolygonsSet(Cartesian3D.MINUS_K, tol);
UnitSphereRandomVectorGenerator random =
new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0x6b9d4a6ad90d7b0bl));
for (int i = 0; i < 1000; ++i) {
- Coordinates3D v = new Coordinates3D(random.nextVector());
+ Cartesian3D v = new Cartesian3D(random.nextVector());
if (v.getZ() < -sinTol) {
Assert.assertEquals(Location.INSIDE, south.checkPoint(new S2Point(v)));
} else if (v.getZ() > sinTol) {
@@ -114,16 +114,16 @@ public class SphericalPolygonsSetTest {
double tol = 0.01;
double sinTol = FastMath.sin(tol);
RegionFactory<Sphere2D> factory = new RegionFactory<>();
- SphericalPolygonsSet plusX = new SphericalPolygonsSet(Coordinates3D.PLUS_I, tol);
- SphericalPolygonsSet plusY = new SphericalPolygonsSet(Coordinates3D.PLUS_J, tol);
- SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Coordinates3D.PLUS_K, tol);
+ SphericalPolygonsSet plusX = new SphericalPolygonsSet(Cartesian3D.PLUS_I, tol);
+ SphericalPolygonsSet plusY = new SphericalPolygonsSet(Cartesian3D.PLUS_J, tol);
+ SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Cartesian3D.PLUS_K, tol);
SphericalPolygonsSet octant =
(SphericalPolygonsSet) factory.intersection(factory.intersection(plusX, plusY), plusZ);
UnitSphereRandomVectorGenerator random =
new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0x9c9802fde3cbcf25l));
for (int i = 0; i < 1000; ++i) {
- Coordinates3D v = new Coordinates3D(random.nextVector());
+ Cartesian3D v = new Cartesian3D(random.nextVector());
if ((v.getX() > sinTol) && (v.getY() > sinTol) && (v.getZ() > sinTol)) {
Assert.assertEquals(Location.INSIDE, octant.checkPoint(new S2Point(v)));
} else if ((v.getX() < -sinTol) || (v.getY() < -sinTol) || (v.getZ() < -sinTol)) {
@@ -147,13 +147,13 @@ public class SphericalPolygonsSetTest {
++count;
Edge e = v.getIncoming();
Assert.assertTrue(v == e.getStart().getOutgoing().getEnd());
- xPFound = xPFound || e.getCircle().getPole().distance(Coordinates3D.PLUS_I) < 1.0e-10;
- yPFound = yPFound || e.getCircle().getPole().distance(Coordinates3D.PLUS_J) < 1.0e-10;
- zPFound = zPFound || e.getCircle().getPole().distance(Coordinates3D.PLUS_K) < 1.0e-10;
+ xPFound = xPFound || e.getCircle().getPole().distance(Cartesian3D.PLUS_I) < 1.0e-10;
+ yPFound = yPFound || e.getCircle().getPole().distance(Cartesian3D.PLUS_J) < 1.0e-10;
+ zPFound = zPFound || e.getCircle().getPole().distance(Cartesian3D.PLUS_K) < 1.0e-10;
Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10);
- xVFound = xVFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_I) < 1.0e-10;
- yVFound = yVFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_J) < 1.0e-10;
- zVFound = zVFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_K) < 1.0e-10;
+ xVFound = xVFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_I) < 1.0e-10;
+ yVFound = yVFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_J) < 1.0e-10;
+ zVFound = zVFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_K) < 1.0e-10;
}
Assert.assertTrue(xPFound);
Assert.assertTrue(yPFound);
@@ -164,7 +164,7 @@ public class SphericalPolygonsSetTest {
Assert.assertEquals(3, count);
Assert.assertEquals(0.0,
- ((S2Point) octant.getBarycenter()).distance(new S2Point(new Coordinates3D(1, 1, 1))),
+ ((S2Point) octant.getBarycenter()).distance(new S2Point(new Cartesian3D(1, 1, 1))),
1.0e-10);
Assert.assertEquals(0.5 * FastMath.PI, octant.getSize(), 1.0e-10);
@@ -174,7 +174,7 @@ public class SphericalPolygonsSetTest {
EnclosingBall<Sphere2D, S2Point> reversedCap =
((SphericalPolygonsSet) factory.getComplement(octant)).getEnclosingCap();
- Assert.assertEquals(0, reversedCap.getCenter().distance(new S2Point(new Coordinates3D(-1, -1, -1))), 1.0e-10);
+ Assert.assertEquals(0, reversedCap.getCenter().distance(new S2Point(new Cartesian3D(-1, -1, -1))), 1.0e-10);
Assert.assertEquals(FastMath.PI - FastMath.asin(1.0 / FastMath.sqrt(3)), reversedCap.getRadius(), 1.0e-10);
}
@@ -188,7 +188,7 @@ public class SphericalPolygonsSetTest {
new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0xb8fc5acc91044308l));
for (int i = 0; i < 1000; ++i) {
- Coordinates3D v = new Coordinates3D(random.nextVector());
+ Cartesian3D v = new Cartesian3D(random.nextVector());
if ((v.getX() > sinTol) && (v.getY() > sinTol) && (v.getZ() > sinTol)) {
Assert.assertEquals(Location.INSIDE, octant.checkPoint(new S2Point(v)));
} else if ((v.getX() < -sinTol) || (v.getY() < -sinTol) || (v.getZ() < -sinTol)) {
@@ -204,9 +204,9 @@ public class SphericalPolygonsSetTest {
double tol = 0.01;
double sinTol = FastMath.sin(tol);
RegionFactory<Sphere2D> factory = new RegionFactory<>();
- SphericalPolygonsSet plusX = new SphericalPolygonsSet(Coordinates3D.PLUS_I, tol);
- SphericalPolygonsSet plusY = new SphericalPolygonsSet(Coordinates3D.PLUS_J, tol);
- SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Coordinates3D.PLUS_K, tol);
+ SphericalPolygonsSet plusX = new SphericalPolygonsSet(Cartesian3D.PLUS_I, tol);
+ SphericalPolygonsSet plusY = new SphericalPolygonsSet(Cartesian3D.PLUS_J, tol);
+ SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Cartesian3D.PLUS_K, tol);
SphericalPolygonsSet threeOctants =
(SphericalPolygonsSet) factory.difference(plusZ, factory.intersection(plusX, plusY));
@@ -214,7 +214,7 @@ public class SphericalPolygonsSetTest {
new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0x9c9802fde3cbcf25l));
for (int i = 0; i < 1000; ++i) {
- Coordinates3D v = new Coordinates3D(random.nextVector());
+ Cartesian3D v = new Cartesian3D(random.nextVector());
if (((v.getX() < -sinTol) || (v.getY() < -sinTol)) && (v.getZ() > sinTol)) {
Assert.assertEquals(Location.INSIDE, threeOctants.checkPoint(new S2Point(v)));
} else if (((v.getX() > sinTol) && (v.getY() > sinTol)) || (v.getZ() < -sinTol)) {
@@ -241,20 +241,20 @@ public class SphericalPolygonsSetTest {
++count;
Edge e = v.getIncoming();
Assert.assertTrue(v == e.getStart().getOutgoing().getEnd());
- if (e.getCircle().getPole().distance(Coordinates3D.MINUS_I) < 1.0e-10) {
+ if (e.getCircle().getPole().distance(Cartesian3D.MINUS_I) < 1.0e-10) {
xPFound = true;
sumPoleX += e.getLength();
- } else if (e.getCircle().getPole().distance(Coordinates3D.MINUS_J) < 1.0e-10) {
+ } else if (e.getCircle().getPole().distance(Cartesian3D.MINUS_J) < 1.0e-10) {
yPFound = true;
sumPoleY += e.getLength();
} else {
- Assert.assertEquals(0.0, e.getCircle().getPole().distance(Coordinates3D.PLUS_K), 1.0e-10);
+ Assert.assertEquals(0.0, e.getCircle().getPole().distance(Cartesian3D.PLUS_K), 1.0e-10);
zPFound = true;
sumPoleZ += e.getLength();
}
- xVFound = xVFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_I) < 1.0e-10;
- yVFound = yVFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_J) < 1.0e-10;
- zVFound = zVFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_K) < 1.0e-10;
+ xVFound = xVFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_I) < 1.0e-10;
+ yVFound = yVFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_J) < 1.0e-10;
+ zVFound = zVFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_K) < 1.0e-10;
}
Assert.assertTrue(xPFound);
Assert.assertTrue(yPFound);
@@ -274,22 +274,22 @@ public class SphericalPolygonsSetTest {
public void testModeratlyComplexShape() {
double tol = 0.01;
List<SubHyperplane<Sphere2D>> boundary = new ArrayList<>();
- boundary.add(create(Coordinates3D.MINUS_J, Coordinates3D.PLUS_I, Coordinates3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.MINUS_I, Coordinates3D.PLUS_K, Coordinates3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_J, Coordinates3D.MINUS_I, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.MINUS_J, Coordinates3D.MINUS_I, Coordinates3D.MINUS_K, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.MINUS_I, Coordinates3D.MINUS_K, Coordinates3D.MINUS_J, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.PLUS_K, Coordinates3D.MINUS_J, Coordinates3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.MINUS_J, Cartesian3D.PLUS_I, Cartesian3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.MINUS_I, Cartesian3D.PLUS_K, Cartesian3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_J, Cartesian3D.MINUS_I, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.MINUS_J, Cartesian3D.MINUS_I, Cartesian3D.MINUS_K, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.MINUS_I, Cartesian3D.MINUS_K, Cartesian3D.MINUS_J, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.PLUS_K, Cartesian3D.MINUS_J, Cartesian3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI));
SphericalPolygonsSet polygon = new SphericalPolygonsSet(boundary, tol);
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Coordinates3D( 1, 1, 1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Coordinates3D(-1, 1, 1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Coordinates3D(-1, -1, 1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Coordinates3D( 1, -1, 1).normalize())));
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Coordinates3D( 1, 1, -1).normalize())));
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Coordinates3D(-1, 1, -1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Coordinates3D(-1, -1, -1).normalize())));
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Coordinates3D( 1, -1, -1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Cartesian3D( 1, 1, 1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Cartesian3D(-1, 1, 1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Cartesian3D(-1, -1, 1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Cartesian3D( 1, -1, 1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Cartesian3D( 1, 1, -1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Cartesian3D(-1, 1, -1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Cartesian3D(-1, -1, -1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Cartesian3D( 1, -1, -1).normalize())));
Assert.assertEquals(MathUtils.TWO_PI, polygon.getSize(), 1.0e-10);
Assert.assertEquals(3 * FastMath.PI, polygon.getBoundarySize(), 1.0e-10);
@@ -308,12 +308,12 @@ public class SphericalPolygonsSetTest {
++count;
Edge e = v.getIncoming();
Assert.assertTrue(v == e.getStart().getOutgoing().getEnd());
- pXFound = pXFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_I) < 1.0e-10;
- mXFound = mXFound || v.getLocation().getVector().distance(Coordinates3D.MINUS_I) < 1.0e-10;
- pYFound = pYFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_J) < 1.0e-10;
- mYFound = mYFound || v.getLocation().getVector().distance(Coordinates3D.MINUS_J) < 1.0e-10;
- pZFound = pZFound || v.getLocation().getVector().distance(Coordinates3D.PLUS_K) < 1.0e-10;
- mZFound = mZFound || v.getLocation().getVector().distance(Coordinates3D.MINUS_K) < 1.0e-10;
+ pXFound = pXFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_I) < 1.0e-10;
+ mXFound = mXFound || v.getLocation().getVector().distance(Cartesian3D.MINUS_I) < 1.0e-10;
+ pYFound = pYFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_J) < 1.0e-10;
+ mYFound = mYFound || v.getLocation().getVector().distance(Cartesian3D.MINUS_J) < 1.0e-10;
+ pZFound = pZFound || v.getLocation().getVector().distance(Cartesian3D.PLUS_K) < 1.0e-10;
+ mZFound = mZFound || v.getLocation().getVector().distance(Cartesian3D.MINUS_K) < 1.0e-10;
Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10);
}
Assert.assertTrue(pXFound);
@@ -333,14 +333,14 @@ public class SphericalPolygonsSetTest {
List<SubHyperplane<Sphere2D>> boundary = new ArrayList<>();
// first part: +X, +Y, +Z octant
- boundary.add(create(Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.PLUS_J, Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, Cartesian3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI));
// first part: -X, -Y, -Z octant
- boundary.add(create(Coordinates3D.MINUS_J, Coordinates3D.MINUS_I, Coordinates3D.MINUS_K, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.MINUS_I, Coordinates3D.MINUS_K, Coordinates3D.MINUS_J, tol, 0.0, 0.5 * FastMath.PI));
- boundary.add(create(Coordinates3D.MINUS_K, Coordinates3D.MINUS_J, Coordinates3D.MINUS_I, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.MINUS_J, Cartesian3D.MINUS_I, Cartesian3D.MINUS_K, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.MINUS_I, Cartesian3D.MINUS_K, Cartesian3D.MINUS_J, tol, 0.0, 0.5 * FastMath.PI));
+ boundary.add(create(Cartesian3D.MINUS_K, Cartesian3D.MINUS_J, Cartesian3D.MINUS_I, tol, 0.0, 0.5 * FastMath.PI));
SphericalPolygonsSet polygon = new SphericalPolygonsSet(boundary, tol);
@@ -348,7 +348,7 @@ public class SphericalPolygonsSetTest {
new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0xcc5ce49949e0d3ecl));
for (int i = 0; i < 1000; ++i) {
- Coordinates3D v = new Coordinates3D(random.nextVector());
+ Cartesian3D v = new Cartesian3D(random.nextVector());
if ((v.getX() < -sinTol) && (v.getY() < -sinTol) && (v.getZ() < -sinTol)) {
Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(v)));
} else if ((v.getX() < sinTol) && (v.getY() < sinTol) && (v.getZ() < sinTol)) {
@@ -374,8 +374,8 @@ public class SphericalPolygonsSetTest {
public void testPartWithHole() {
double tol = 0.01;
double alpha = 0.7;
- S2Point center = new S2Point(new Coordinates3D(1, 1, 1));
- SphericalPolygonsSet hexa = new SphericalPolygonsSet(center.getVector(), Coordinates3D.PLUS_K, alpha, 6, tol);
+ S2Point center = new S2Point(new Cartesian3D(1, 1, 1));
+ SphericalPolygonsSet hexa = new SphericalPolygonsSet(center.getVector(), Cartesian3D.PLUS_K, alpha, 6, tol);
SphericalPolygonsSet hole = new SphericalPolygonsSet(tol,
new S2Point(FastMath.PI / 6, FastMath.PI / 3),
new S2Point(FastMath.PI / 3, FastMath.PI / 3),
@@ -403,15 +403,15 @@ public class SphericalPolygonsSetTest {
@Test
public void testConcentricSubParts() {
double tol = 0.001;
- Coordinates3D center = new Coordinates3D(1, 1, 1);
- SphericalPolygonsSet hexaOut = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.9, 6, tol);
- SphericalPolygonsSet hexaIn = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.8, 6, tol);
- SphericalPolygonsSet pentaOut = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.7, 5, tol);
- SphericalPolygonsSet pentaIn = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.6, 5, tol);
- SphericalPolygonsSet quadriOut = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.5, 4, tol);
- SphericalPolygonsSet quadriIn = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.4, 4, tol);
- SphericalPolygonsSet triOut = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.25, 3, tol);
- SphericalPolygonsSet triIn = new SphericalPolygonsSet(center, Coordinates3D.PLUS_K, 0.15, 3, tol);
+ Cartesian3D center = new Cartesian3D(1, 1, 1);
+ SphericalPolygonsSet hexaOut = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.9, 6, tol);
+ SphericalPolygonsSet hexaIn = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.8, 6, tol);
+ SphericalPolygonsSet pentaOut = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.7, 5, tol);
+ SphericalPolygonsSet pentaIn = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.6, 5, tol);
+ SphericalPolygonsSet quadriOut = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.5, 4, tol);
+ SphericalPolygonsSet quadriIn = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.4, 4, tol);
+ SphericalPolygonsSet triOut = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.25, 3, tol);
+ SphericalPolygonsSet triIn = new SphericalPolygonsSet(center, Cartesian3D.PLUS_K, 0.15, 3, tol);
RegionFactory<Sphere2D> factory = new RegionFactory<>();
SphericalPolygonsSet hexa = (SphericalPolygonsSet) factory.difference(hexaOut, hexaIn);
@@ -477,7 +477,7 @@ public class SphericalPolygonsSetTest {
RegionFactory<Sphere2D> factory = new RegionFactory<>();
SphericalPolygonsSet zone = (SphericalPolygonsSet) factory.union(continental, corsica);
EnclosingBall<Sphere2D, S2Point> enclosing = zone.getEnclosingCap();
- Coordinates3D enclosingCenter = ((S2Point) enclosing.getCenter()).getVector();
+ Cartesian3D enclosingCenter = ((S2Point) enclosing.getCenter()).getVector();
double step = FastMath.toRadians(0.1);
for (Vertex loopStart : zone.getBoundaryLoops()) {
@@ -485,8 +485,8 @@ public class SphericalPolygonsSetTest {
for (Vertex v = loopStart; count == 0 || v != loopStart; v = v.getOutgoing().getEnd()) {
++count;
for (int i = 0; i < FastMath.ceil(v.getOutgoing().getLength() / step); ++i) {
- Coordinates3D p = v.getOutgoing().getPointAt(i * step);
- Assert.assertTrue(Coordinates3D.angle(p, enclosingCenter) <= enclosing.getRadius());
+ Cartesian3D p = v.getOutgoing().getPointAt(i * step);
+ Assert.assertTrue(Cartesian3D.angle(p, enclosingCenter) <= enclosing.getRadius());
}
}
}
@@ -500,37 +500,37 @@ public class SphericalPolygonsSetTest {
EnclosingBall<Sphere2D, S2Point> continentalInscribed =
((SphericalPolygonsSet) factory.getComplement(continental)).getEnclosingCap();
- Coordinates3D continentalCenter = ((S2Point) continentalInscribed.getCenter()).getVector();
+ Cartesian3D continentalCenter = ((S2Point) continentalInscribed.getCenter()).getVector();
Assert.assertEquals(2.2, FastMath.toDegrees(FastMath.PI - continentalInscribed.getRadius()), 0.1);
for (Vertex loopStart : continental.getBoundaryLoops()) {
int count = 0;
for (Vertex v = loopStart; count == 0 || v != loopStart; v = v.getOutgoing().getEnd()) {
++count;
for (int i = 0; i < FastMath.ceil(v.getOutgoing().getLength() / step); ++i) {
- Coordinates3D p = v.getOutgoing().getPointAt(i * step);
- Assert.assertTrue(Coordinates3D.angle(p, continentalCenter) <= continentalInscribed.getRadius());
+ Cartesian3D p = v.getOutgoing().getPointAt(i * step);
+ Assert.assertTrue(Cartesian3D.angle(p, continentalCenter) <= continentalInscribed.getRadius());
}
}
}
EnclosingBall<Sphere2D, S2Point> corsicaInscribed =
((SphericalPolygonsSet) factory.getComplement(corsica)).getEnclosingCap();
- Coordinates3D corsicaCenter = ((S2Point) corsicaInscribed.getCenter()).getVector();
+ Cartesian3D corsicaCenter = ((S2Point) corsicaInscribed.getCenter()).getVector();
Assert.assertEquals(0.34, FastMath.toDegrees(FastMath.PI - corsicaInscribed.getRadius()), 0.01);
for (Vertex loopStart : corsica.getBoundaryLoops()) {
int count = 0;
for (Vertex v = loopStart; count == 0 || v != loopStart; v = v.getOutgoing().getEnd()) {
++count;
for (int i = 0; i < FastMath.ceil(v.getOutgoing().getLength() / step); ++i) {
- Coordinates3D p = v.getOutgoing().getPointAt(i * step);
- Assert.assertTrue(Coordinates3D.angle(p, corsicaCenter) <= corsicaInscribed.getRadius());
+ Cartesian3D p = v.getOutgoing().getPointAt(i * step);
+ Assert.assertTrue(Cartesian3D.angle(p, corsicaCenter) <= corsicaInscribed.getRadius());
}
}
}
}
- private SubCircle create(Coordinates3D pole, Coordinates3D x, Coordinates3D y,
+ private SubCircle create(Cartesian3D pole, Cartesian3D x, Cartesian3D y,
double tolerance, double ... limits) {
RegionFactory<Sphere1D> factory = new RegionFactory<>();
Circle circle = new Circle(pole, tolerance);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java
index 4404f60..f3bfd8a 100644
--- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/SubCircleTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.geometry.spherical.twod;
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.apache.commons.math4.geometry.partitioning.RegionFactory;
import org.apache.commons.math4.geometry.partitioning.Side;
import org.apache.commons.math4.geometry.partitioning.SubHyperplane.SplitSubHyperplane;
@@ -34,7 +34,7 @@ public class SubCircleTest {
@Test
public void testFullCircle() {
- Circle circle = new Circle(Coordinates3D.PLUS_K, 1.0e-10);
+ Circle circle = new Circle(Cartesian3D.PLUS_K, 1.0e-10);
SubCircle set = circle.wholeHyperplane();
Assert.assertEquals(MathUtils.TWO_PI, set.getSize(), 1.0e-10);
Assert.assertTrue(circle == set.getHyperplane());
@@ -44,21 +44,21 @@ public class SubCircleTest {
@Test
public void testSide() {
- Circle xzPlane = new Circle(Coordinates3D.PLUS_J, 1.0e-10);
+ Circle xzPlane = new Circle(Cartesian3D.PLUS_J, 1.0e-10);
- SubCircle sc1 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0);
+ SubCircle sc1 = create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0);
Assert.assertEquals(Side.BOTH, sc1.split(xzPlane).getSide());
- SubCircle sc2 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0);
+ SubCircle sc2 = create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, 1.0e-10, 1.0, 3.0);
Assert.assertEquals(Side.MINUS, sc2.split(xzPlane).getSide());
- SubCircle sc3 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 5.0, 6.0);
+ SubCircle sc3 = create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, 1.0e-10, 5.0, 6.0);
Assert.assertEquals(Side.PLUS, sc3.split(xzPlane).getSide());
- SubCircle sc4 = create(Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, 1.0e-10, 5.0, 6.0);
+ SubCircle sc4 = create(Cartesian3D.PLUS_J, Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, 1.0e-10, 5.0, 6.0);
Assert.assertEquals(Side.HYPER, sc4.split(xzPlane).getSide());
- SubCircle sc5 = create(Coordinates3D.MINUS_J, Coordinates3D.PLUS_I, Coordinates3D.PLUS_K, 1.0e-10, 5.0, 6.0);
+ SubCircle sc5 = create(Cartesian3D.MINUS_J, Cartesian3D.PLUS_I, Cartesian3D.PLUS_K, 1.0e-10, 5.0, 6.0);
Assert.assertEquals(Side.HYPER, sc5.split(xzPlane).getSide());
}
@@ -66,9 +66,9 @@ public class SubCircleTest {
@Test
public void testSPlit() {
- Circle xzPlane = new Circle(Coordinates3D.PLUS_J, 1.0e-10);
+ Circle xzPlane = new Circle(Cartesian3D.PLUS_J, 1.0e-10);
- SubCircle sc1 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0);
+ SubCircle sc1 = create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0);
SplitSubHyperplane<Sphere2D> split1 = sc1.split(xzPlane);
ArcsSet plus1 = (ArcsSet) ((SubCircle) split1.getPlus()).getRemainingRegion();
ArcsSet minus1 = (ArcsSet) ((SubCircle) split1.getMinus()).getRemainingRegion();
@@ -79,7 +79,7 @@ public class SubCircleTest {
Assert.assertEquals(1.0, minus1.asList().get(0).getInf(), 1.0e-10);
Assert.assertEquals(3.0, minus1.asList().get(0).getSup(), 1.0e-10);
- SubCircle sc2 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0);
+ SubCircle sc2 = create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, 1.0e-10, 1.0, 3.0);
SplitSubHyperplane<Sphere2D> split2 = sc2.split(xzPlane);
Assert.assertNull(split2.getPlus());
ArcsSet minus2 = (ArcsSet) ((SubCircle) split2.getMinus()).getRemainingRegion();
@@ -87,7 +87,7 @@ public class SubCircleTest {
Assert.assertEquals(1.0, minus2.asList().get(0).getInf(), 1.0e-10);
Assert.assertEquals(3.0, minus2.asList().get(0).getSup(), 1.0e-10);
- SubCircle sc3 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 5.0, 6.0);
+ SubCircle sc3 = create(Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, 1.0e-10, 5.0, 6.0);
SplitSubHyperplane<Sphere2D> split3 = sc3.split(xzPlane);
ArcsSet plus3 = (ArcsSet) ((SubCircle) split3.getPlus()).getRemainingRegion();
Assert.assertEquals(1, plus3.asList().size());
@@ -95,13 +95,13 @@ public class SubCircleTest {
Assert.assertEquals(6.0, plus3.asList().get(0).getSup(), 1.0e-10);
Assert.assertNull(split3.getMinus());
- SubCircle sc4 = create(Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, 1.0e-10, 5.0, 6.0);
+ SubCircle sc4 = create(Cartesian3D.PLUS_J, Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, 1.0e-10, 5.0, 6.0);
SplitSubHyperplane<Sphere2D> split4 = sc4.split(xzPlane);
Assert.assertEquals(Side.HYPER, sc4.split(xzPlane).getSide());
Assert.assertNull(split4.getPlus());
Assert.assertNull(split4.getMinus());
- SubCircle sc5 = create(Coordinates3D.MINUS_J, Coordinates3D.PLUS_I, Coordinates3D.PLUS_K, 1.0e-10, 5.0, 6.0);
+ SubCircle sc5 = create(Cartesian3D.MINUS_J, Cartesian3D.PLUS_I, Cartesian3D.PLUS_K, 1.0e-10, 5.0, 6.0);
SplitSubHyperplane<Sphere2D> split5 = sc5.split(xzPlane);
Assert.assertEquals(Side.HYPER, sc5.split(xzPlane).getSide());
Assert.assertNull(split5.getPlus());
@@ -113,9 +113,9 @@ public class SubCircleTest {
public void testSideSplitConsistency() {
double tolerance = 1.0e-6;
- Circle hyperplane = new Circle(new Coordinates3D(9.738804529764676E-5, -0.6772824575010357, -0.7357230887208355),
+ Circle hyperplane = new Circle(new Cartesian3D(9.738804529764676E-5, -0.6772824575010357, -0.7357230887208355),
tolerance);
- SubCircle sub = new SubCircle(new Circle(new Coordinates3D(2.1793884139073498E-4, 0.9790647032675541, -0.20354915700704285),
+ SubCircle sub = new SubCircle(new Circle(new Cartesian3D(2.1793884139073498E-4, 0.9790647032675541, -0.20354915700704285),
tolerance),
new ArcsSet(4.7121441684170700, 4.7125386635004760, tolerance));
SplitSubHyperplane<Sphere2D> split = sub.split(hyperplane);
@@ -125,7 +125,7 @@ public class SubCircleTest {
}
- private SubCircle create(Coordinates3D pole, Coordinates3D x, Coordinates3D y,
+ private SubCircle create(Cartesian3D pole, Cartesian3D x, Cartesian3D y,
double tolerance, double ... limits) {
RegionFactory<Sphere1D> factory = new RegionFactory<>();
Circle circle = new Circle(pole, tolerance);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java
index e52fa34..73281f8 100644
--- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java
+++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.optim.nonlinear.scalar;
import org.apache.commons.math4.analysis.MultivariateFunction;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.optim.InitialGuess;
import org.apache.commons.math4.optim.MaxEval;
import org.apache.commons.math4.optim.PointValuePair;
@@ -72,7 +72,7 @@ public class MultiStartMultivariateOptimizerTest {
Assert.assertEquals(nbStarts, optima.length);
for (PointValuePair o : optima) {
// we check the results of all intermediate restarts here (there are 10 such results)
- Coordinates2D center = new Coordinates2D(o.getPointRef()[0], o.getPointRef()[1]);
+ Cartesian2D center = new Cartesian2D(o.getPointRef()[0], o.getPointRef()[1]);
Assert.assertEquals(69.9597, circle.getRadius(center), 1e-3);
Assert.assertEquals(96.07535, center.getX(), 1.4e-3);
Assert.assertEquals(48.1349, center.getY(), 5e-3);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java
index beb3532..be0e494 100644
--- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java
+++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/CircleScalar.java
@@ -21,7 +21,7 @@ import java.util.ArrayList;
import org.apache.commons.math4.analysis.MultivariateFunction;
import org.apache.commons.math4.analysis.MultivariateVectorFunction;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.optim.nonlinear.scalar.ObjectiveFunction;
import org.apache.commons.math4.optim.nonlinear.scalar.ObjectiveFunctionGradient;
@@ -29,19 +29,19 @@ import org.apache.commons.math4.optim.nonlinear.scalar.ObjectiveFunctionGradient
* Class used in the tests.
*/
public class CircleScalar {
- private ArrayList<Coordinates2D> points;
+ private ArrayList<Cartesian2D> points;
public CircleScalar() {
points = new ArrayList<>();
}
public void addPoint(double px, double py) {
- points.add(new Coordinates2D(px, py));
+ points.add(new Cartesian2D(px, py));
}
- public double getRadius(Coordinates2D center) {
+ public double getRadius(Cartesian2D center) {
double r = 0;
- for (Coordinates2D point : points) {
+ for (Cartesian2D point : points) {
r += point.distance(center);
}
return r / points.size();
@@ -51,10 +51,10 @@ public class CircleScalar {
return new ObjectiveFunction(new MultivariateFunction() {
@Override
public double value(double[] params) {
- Coordinates2D center = new Coordinates2D(params[0], params[1]);
+ Cartesian2D center = new Cartesian2D(params[0], params[1]);
double radius = getRadius(center);
double sum = 0;
- for (Coordinates2D point : points) {
+ for (Cartesian2D point : points) {
double di = point.distance(center) - radius;
sum += di * di;
}
@@ -67,12 +67,12 @@ public class CircleScalar {
return new ObjectiveFunctionGradient(new MultivariateVectorFunction() {
@Override
public double[] value(double[] params) {
- Coordinates2D center = new Coordinates2D(params[0], params[1]);
+ Cartesian2D center = new Cartesian2D(params[0], params[1]);
double radius = getRadius(center);
// gradient of the sum of squared residuals
double dJdX = 0;
double dJdY = 0;
- for (Coordinates2D pk : points) {
+ for (Cartesian2D pk : points) {
double dk = pk.distance(center);
dJdX += (center.getX() - pk.getX()) * (dk - radius) / dk;
dJdY += (center.getY() - pk.getY()) * (dk - radius) / dk;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java
index 54a827e..99ce48a 100644
--- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java
+++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java
@@ -20,7 +20,7 @@ package org.apache.commons.math4.optim.nonlinear.scalar.gradient;
import org.apache.commons.math4.analysis.MultivariateFunction;
import org.apache.commons.math4.analysis.MultivariateVectorFunction;
import org.apache.commons.math4.exception.MathUnsupportedOperationException;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.linear.BlockRealMatrix;
import org.apache.commons.math4.linear.RealMatrix;
import org.apache.commons.math4.optim.InitialGuess;
@@ -431,7 +431,7 @@ public class NonLinearConjugateGradientOptimizerTest {
problem.getObjectiveFunctionGradient(),
GoalType.MINIMIZE,
new InitialGuess(new double[] { 98.680, 47.345 }));
- Coordinates2D center = new Coordinates2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
+ Cartesian2D center = new Cartesian2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
Assert.assertEquals(69.960161753, problem.getRadius(center), 1.0e-8);
Assert.assertEquals(96.075902096, center.getX(), 1.0e-7);
Assert.assertEquals(48.135167894, center.getY(), 1.0e-6);