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:14 UTC
[01/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
Repository: commons-math
Updated Branches:
refs/heads/feature-MATH-1284 b815d2af5 -> c9e49faac
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);
[09/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
Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
index ff8f17e..63e7017 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
@@ -48,8 +48,8 @@ import org.apache.commons.math4.util.MathArrays;
* <p>Focus is oriented on what a rotation <em>do</em> rather than on its
* underlying representation. Once it has been built, and regardless of its
* internal representation, a rotation is an <em>operator</em> which basically
- * transforms three dimensional {@link Coordinates3D vectors} into other three
- * dimensional {@link Coordinates3D vectors}. Depending on the application, the
+ * transforms three dimensional {@link Cartesian3D vectors} into other three
+ * dimensional {@link Cartesian3D vectors}. Depending on the application, the
* meaning of these vectors may vary and the semantics of the rotation also.</p>
* <p>For example in an spacecraft attitude simulation tool, users will often
* consider the vectors are fixed (say the Earth direction for example) and the
@@ -88,7 +88,7 @@ import org.apache.commons.math4.util.MathArrays;
*
* <p>Rotations are guaranteed to be immutable objects.</p>
*
- * @see Coordinates3D
+ * @see Cartesian3D
* @see RotationOrder
* @since 1.2
*/
@@ -162,7 +162,7 @@ public class Rotation implements Serializable {
* @deprecated as of 3.6, replaced with {@link #Rotation(Vector3D, double, RotationConvention)}
*/
@Deprecated
- public Rotation(Coordinates3D axis, double angle) throws MathIllegalArgumentException {
+ public Rotation(Cartesian3D axis, double angle) throws MathIllegalArgumentException {
this(axis, angle, RotationConvention.VECTOR_OPERATOR);
}
@@ -173,7 +173,7 @@ public class Rotation implements Serializable {
* @exception MathIllegalArgumentException if the axis norm is zero
* @since 3.6
*/
- public Rotation(final Coordinates3D axis, final double angle, final RotationConvention convention)
+ public Rotation(final Cartesian3D axis, final double angle, final RotationConvention convention)
throws MathIllegalArgumentException {
double norm = axis.getNorm();
@@ -272,18 +272,18 @@ public class Rotation implements Serializable {
* @exception MathArithmeticException if the norm of one of the vectors is zero,
* or if one of the pair is degenerated (i.e. the vectors of the pair are collinear)
*/
- public Rotation(Coordinates3D u1, Coordinates3D u2, Coordinates3D v1, Coordinates3D v2)
+ public Rotation(Cartesian3D u1, Cartesian3D u2, Cartesian3D v1, Cartesian3D v2)
throws MathArithmeticException {
// build orthonormalized base from u1, u2
// this fails when vectors are null or collinear, which is forbidden to define a rotation
- final Coordinates3D u3 = u1.crossProduct(u2).normalize();
+ final Cartesian3D u3 = u1.crossProduct(u2).normalize();
u2 = u3.crossProduct(u1).normalize();
u1 = u1.normalize();
// build an orthonormalized base from v1, v2
// this fails when vectors are null or collinear, which is forbidden to define a rotation
- final Coordinates3D v3 = v1.crossProduct(v2).normalize();
+ final Cartesian3D v3 = v1.crossProduct(v2).normalize();
v2 = v3.crossProduct(v1).normalize();
v1 = v1.normalize();
@@ -327,7 +327,7 @@ public class Rotation implements Serializable {
* @param v desired image of u by the rotation
* @exception MathArithmeticException if the norm of one of the vectors is zero
*/
- public Rotation(Coordinates3D u, Coordinates3D v) throws MathArithmeticException {
+ public Rotation(Cartesian3D u, Cartesian3D v) throws MathArithmeticException {
double normProduct = u.getNorm() * v.getNorm();
if (normProduct == 0) {
@@ -339,7 +339,7 @@ public class Rotation implements Serializable {
if (dot < ((2.0e-15 - 1.0) * normProduct)) {
// special case u = -v: we select a PI angle rotation around
// an arbitrary vector orthogonal to u
- Coordinates3D w = u.orthogonal();
+ Cartesian3D w = u.orthogonal();
q0 = 0.0;
q1 = -w.getX();
q2 = -w.getY();
@@ -349,7 +349,7 @@ public class Rotation implements Serializable {
// the shortest possible rotation: axis orthogonal to this plane
q0 = FastMath.sqrt(0.5 * (1.0 + dot / normProduct));
double coeff = 1.0 / (2.0 * q0 * normProduct);
- Coordinates3D q = v.crossProduct(u);
+ Cartesian3D q = v.crossProduct(u);
q1 = coeff * q.getX();
q2 = coeff * q.getY();
q3 = coeff * q.getZ();
@@ -522,7 +522,7 @@ public class Rotation implements Serializable {
* @deprecated as of 3.6, replaced with {@link #getAxis(RotationConvention)}
*/
@Deprecated
- public Coordinates3D getAxis() {
+ public Cartesian3D getAxis() {
return getAxis(RotationConvention.VECTOR_OPERATOR);
}
@@ -537,18 +537,18 @@ public class Rotation implements Serializable {
* @see #Rotation(Vector3D, double, RotationConvention)
* @since 3.6
*/
- public Coordinates3D getAxis(final RotationConvention convention) {
+ public Cartesian3D getAxis(final RotationConvention convention) {
final double squaredSine = q1 * q1 + q2 * q2 + q3 * q3;
if (squaredSine == 0) {
- return convention == RotationConvention.VECTOR_OPERATOR ? Coordinates3D.PLUS_I : Coordinates3D.MINUS_I;
+ return convention == RotationConvention.VECTOR_OPERATOR ? Cartesian3D.PLUS_I : Cartesian3D.MINUS_I;
} else {
final double sgn = convention == RotationConvention.VECTOR_OPERATOR ? +1 : -1;
if (q0 < 0) {
final double inverse = sgn / FastMath.sqrt(squaredSine);
- return new Coordinates3D(q1 * inverse, q2 * inverse, q3 * inverse);
+ return new Cartesian3D(q1 * inverse, q2 * inverse, q3 * inverse);
}
final double inverse = -sgn / FastMath.sqrt(squaredSine);
- return new Coordinates3D(q1 * inverse, q2 * inverse, q3 * inverse);
+ return new Cartesian3D(q1 * inverse, q2 * inverse, q3 * inverse);
}
}
@@ -633,8 +633,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (psi) cos (theta), -sin (psi) cos (theta), sin (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -651,8 +651,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (theta) cos (psi), -sin (psi), sin (theta) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -669,8 +669,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// sin (psi) cos (phi), cos (psi) cos (phi), -sin (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -687,8 +687,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// sin (psi), cos (phi) cos (psi), -sin (phi) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -705,8 +705,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// -sin (theta) cos (phi), sin (phi), cos (theta) cos (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -723,8 +723,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// -sin (theta), sin (phi) cos (theta), cos (phi) cos (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -741,8 +741,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (theta), sin (theta) sin (phi2), sin (theta) cos (phi2)
// and we can choose to have theta in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -759,8 +759,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (psi), -sin (psi) cos (phi2), sin (psi) sin (phi2)
// and we can choose to have psi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -777,8 +777,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// sin (phi) sin (theta2), cos (phi), -sin (phi) cos (theta2)
// and we can choose to have phi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -795,8 +795,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// sin (psi) cos (theta2), cos (psi), sin (psi) sin (theta2)
// and we can choose to have psi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -813,8 +813,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// sin (phi) sin (psi2), sin (phi) cos (psi2), cos (phi)
// and we can choose to have phi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -831,8 +831,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// -sin (theta) cos (psi2), sin (theta) sin (psi2), cos (theta)
// and we can choose to have theta in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -851,8 +851,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// sin (theta), -sin (phi) cos (theta), cos (phi) cos (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -869,8 +869,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// -sin (psi), cos (phi) cos (psi), sin (phi) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -887,8 +887,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// sin (theta) cos (phi), -sin (phi), cos (theta) cos (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -905,8 +905,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (theta) cos (psi), sin (psi), -sin (theta) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -923,8 +923,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// -sin (psi) cos (phi), cos (psi) cos (phi), sin (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -941,8 +941,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (psi) cos (theta), sin (psi) cos (theta), -sin (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -959,8 +959,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (theta), sin (theta) sin (phi1), -sin (theta) cos (phi1)
// and we can choose to have theta in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -977,8 +977,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusI) coordinates are :
// cos (psi), sin (psi) cos (phi1), sin (psi) sin (phi1)
// and we can choose to have psi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_I);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getX() < -0.9999999999) || (v2.getX() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -995,8 +995,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// sin (theta1) sin (phi), cos (phi), cos (theta1) sin (phi)
// and we can choose to have phi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -1013,8 +1013,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusJ) coordinates are :
// -cos (theta1) sin (psi), cos (psi), sin (theta1) sin (psi)
// and we can choose to have psi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_J);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getY() < -0.9999999999) || (v2.getY() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -1031,8 +1031,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// sin (psi1) sin (phi), -cos (psi1) sin (phi), cos (phi)
// and we can choose to have phi in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -1049,8 +1049,8 @@ public class Rotation implements Serializable {
// (-r) (Vector3D.plusK) coordinates are :
// cos (psi1) sin (theta), sin (psi1) sin (theta), cos (theta)
// and we can choose to have theta in the interval [0 ; PI]
- Coordinates3D v1 = applyTo(Coordinates3D.PLUS_K);
- Coordinates3D v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
+ Cartesian3D v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getZ() < -0.9999999999) || (v2.getZ() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -1108,7 +1108,7 @@ public class Rotation implements Serializable {
* @param u vector to apply the rotation to
* @return a new vector which is the image of u by the rotation
*/
- public Coordinates3D applyTo(Coordinates3D u) {
+ public Cartesian3D applyTo(Cartesian3D u) {
double x = u.getX();
double y = u.getY();
@@ -1116,7 +1116,7 @@ public class Rotation implements Serializable {
double s = q1 * x + q2 * y + q3 * z;
- return new Coordinates3D(2 * (q0 * (x * q0 - (q2 * z - q3 * y)) + s * q1) - x,
+ return new Cartesian3D(2 * (q0 * (x * q0 - (q2 * z - q3 * y)) + s * q1) - x,
2 * (q0 * (y * q0 - (q3 * x - q1 * z)) + s * q2) - y,
2 * (q0 * (z * q0 - (q1 * y - q2 * x)) + s * q3) - z);
@@ -1145,7 +1145,7 @@ public class Rotation implements Serializable {
* @param u vector to apply the inverse of the rotation to
* @return a new vector which such that u is its image by the rotation
*/
- public Coordinates3D applyInverseTo(Coordinates3D u) {
+ public Cartesian3D applyInverseTo(Cartesian3D u) {
double x = u.getX();
double y = u.getY();
@@ -1154,7 +1154,7 @@ public class Rotation implements Serializable {
double s = q1 * x + q2 * y + q3 * z;
double m0 = -q0;
- return new Coordinates3D(2 * (m0 * (x * m0 - (q2 * z - q3 * y)) + s * q1) - x,
+ return new Cartesian3D(2 * (m0 * (x * m0 - (q2 * z - q3 * y)) + s * q1) - x,
2 * (m0 * (y * m0 - (q3 * x - q1 * z)) + s * q2) - y,
2 * (m0 * (z * m0 - (q1 * y - q2 * x)) + s * q3) - z);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationOrder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationOrder.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationOrder.java
index 0eec6d0..020de0e 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationOrder.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationOrder.java
@@ -35,96 +35,96 @@ public final class RotationOrder {
* around Z
*/
public static final RotationOrder XYZ =
- new RotationOrder("XYZ", Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, Coordinates3D.PLUS_K);
+ new RotationOrder("XYZ", Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, Cartesian3D.PLUS_K);
/** Set of Cardan angles.
* this ordered set of rotations is around X, then around Z, then
* around Y
*/
public static final RotationOrder XZY =
- new RotationOrder("XZY", Coordinates3D.PLUS_I, Coordinates3D.PLUS_K, Coordinates3D.PLUS_J);
+ new RotationOrder("XZY", Cartesian3D.PLUS_I, Cartesian3D.PLUS_K, Cartesian3D.PLUS_J);
/** Set of Cardan angles.
* this ordered set of rotations is around Y, then around X, then
* around Z
*/
public static final RotationOrder YXZ =
- new RotationOrder("YXZ", Coordinates3D.PLUS_J, Coordinates3D.PLUS_I, Coordinates3D.PLUS_K);
+ new RotationOrder("YXZ", Cartesian3D.PLUS_J, Cartesian3D.PLUS_I, Cartesian3D.PLUS_K);
/** Set of Cardan angles.
* this ordered set of rotations is around Y, then around Z, then
* around X
*/
public static final RotationOrder YZX =
- new RotationOrder("YZX", Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, Coordinates3D.PLUS_I);
+ new RotationOrder("YZX", Cartesian3D.PLUS_J, Cartesian3D.PLUS_K, Cartesian3D.PLUS_I);
/** Set of Cardan angles.
* this ordered set of rotations is around Z, then around X, then
* around Y
*/
public static final RotationOrder ZXY =
- new RotationOrder("ZXY", Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J);
+ new RotationOrder("ZXY", Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J);
/** Set of Cardan angles.
* this ordered set of rotations is around Z, then around Y, then
* around X
*/
public static final RotationOrder ZYX =
- new RotationOrder("ZYX", Coordinates3D.PLUS_K, Coordinates3D.PLUS_J, Coordinates3D.PLUS_I);
+ new RotationOrder("ZYX", Cartesian3D.PLUS_K, Cartesian3D.PLUS_J, Cartesian3D.PLUS_I);
/** Set of Euler angles.
* this ordered set of rotations is around X, then around Y, then
* around X
*/
public static final RotationOrder XYX =
- new RotationOrder("XYX", Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, Coordinates3D.PLUS_I);
+ new RotationOrder("XYX", Cartesian3D.PLUS_I, Cartesian3D.PLUS_J, Cartesian3D.PLUS_I);
/** Set of Euler angles.
* this ordered set of rotations is around X, then around Z, then
* around X
*/
public static final RotationOrder XZX =
- new RotationOrder("XZX", Coordinates3D.PLUS_I, Coordinates3D.PLUS_K, Coordinates3D.PLUS_I);
+ new RotationOrder("XZX", Cartesian3D.PLUS_I, Cartesian3D.PLUS_K, Cartesian3D.PLUS_I);
/** Set of Euler angles.
* this ordered set of rotations is around Y, then around X, then
* around Y
*/
public static final RotationOrder YXY =
- new RotationOrder("YXY", Coordinates3D.PLUS_J, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J);
+ new RotationOrder("YXY", Cartesian3D.PLUS_J, Cartesian3D.PLUS_I, Cartesian3D.PLUS_J);
/** Set of Euler angles.
* this ordered set of rotations is around Y, then around Z, then
* around Y
*/
public static final RotationOrder YZY =
- new RotationOrder("YZY", Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, Coordinates3D.PLUS_J);
+ new RotationOrder("YZY", Cartesian3D.PLUS_J, Cartesian3D.PLUS_K, Cartesian3D.PLUS_J);
/** Set of Euler angles.
* this ordered set of rotations is around Z, then around X, then
* around Z
*/
public static final RotationOrder ZXZ =
- new RotationOrder("ZXZ", Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_K);
+ new RotationOrder("ZXZ", Cartesian3D.PLUS_K, Cartesian3D.PLUS_I, Cartesian3D.PLUS_K);
/** Set of Euler angles.
* this ordered set of rotations is around Z, then around Y, then
* around Z
*/
public static final RotationOrder ZYZ =
- new RotationOrder("ZYZ", Coordinates3D.PLUS_K, Coordinates3D.PLUS_J, Coordinates3D.PLUS_K);
+ new RotationOrder("ZYZ", Cartesian3D.PLUS_K, Cartesian3D.PLUS_J, Cartesian3D.PLUS_K);
/** Name of the rotations order. */
private final String name;
/** Axis of the first rotation. */
- private final Coordinates3D a1;
+ private final Cartesian3D a1;
/** Axis of the second rotation. */
- private final Coordinates3D a2;
+ private final Cartesian3D a2;
/** Axis of the third rotation. */
- private final Coordinates3D a3;
+ private final Cartesian3D a3;
/** Private constructor.
* This is a utility class that cannot be instantiated by the user,
@@ -135,7 +135,7 @@ public final class RotationOrder {
* @param a3 axis of the third rotation
*/
private RotationOrder(final String name,
- final Coordinates3D a1, final Coordinates3D a2, final Coordinates3D a3) {
+ final Cartesian3D a1, final Cartesian3D a2, final Cartesian3D a3) {
this.name = name;
this.a1 = a1;
this.a2 = a2;
@@ -153,21 +153,21 @@ public final class RotationOrder {
/** Get the axis of the first rotation.
* @return axis of the first rotation
*/
- public Coordinates3D getA1() {
+ public Cartesian3D getA1() {
return a1;
}
/** Get the axis of the second rotation.
* @return axis of the second rotation
*/
- public Coordinates3D getA2() {
+ public Cartesian3D getA2() {
return a2;
}
/** Get the axis of the second rotation.
* @return axis of the second rotation
*/
- public Coordinates3D getA3() {
+ public Cartesian3D getA3() {
return a3;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Segment.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Segment.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Segment.java
index bf7e81f..6ced496 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Segment.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Segment.java
@@ -23,10 +23,10 @@ package org.apache.commons.math4.geometry.euclidean.threed;
public class Segment {
/** Start point of the segment. */
- private final Coordinates3D start;
+ private final Cartesian3D start;
/** End point of the segments. */
- private final Coordinates3D end;
+ private final Cartesian3D end;
/** Line containing the segment. */
private final Line line;
@@ -36,7 +36,7 @@ public class Segment {
* @param end end point of the segment
* @param line line containing the segment
*/
- public Segment(final Coordinates3D start, final Coordinates3D end, final Line line) {
+ public Segment(final Cartesian3D start, final Cartesian3D end, final Line line) {
this.start = start;
this.end = end;
this.line = line;
@@ -45,14 +45,14 @@ public class Segment {
/** Get the start point of the segment.
* @return start point of the segment
*/
- public Coordinates3D getStart() {
+ public Cartesian3D getStart() {
return start;
}
/** Get the end point of the segment.
* @return end point of the segment
*/
- public Coordinates3D getEnd() {
+ public Cartesian3D getEnd() {
return end;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java
index 08163dd..8ed5a6a 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java
@@ -24,38 +24,38 @@ import org.apache.commons.math4.geometry.enclosing.EnclosingBall;
import org.apache.commons.math4.geometry.enclosing.SupportBallGenerator;
import org.apache.commons.math4.geometry.euclidean.twod.DiskGenerator;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.FastMath;
/** Class generating an enclosing ball from its support points.
* @since 3.3
*/
-public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Coordinates3D> {
+public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Cartesian3D> {
/** {@inheritDoc} */
@Override
- public EnclosingBall<Euclidean3D, Coordinates3D> ballOnSupport(final List<Coordinates3D> support) {
+ public EnclosingBall<Euclidean3D, Cartesian3D> ballOnSupport(final List<Cartesian3D> support) {
if (support.size() < 1) {
- return new EnclosingBall<>(Coordinates3D.ZERO, Double.NEGATIVE_INFINITY);
+ return new EnclosingBall<>(Cartesian3D.ZERO, Double.NEGATIVE_INFINITY);
} else {
- final Coordinates3D vA = support.get(0);
+ final Cartesian3D vA = support.get(0);
if (support.size() < 2) {
return new EnclosingBall<>(vA, 0, vA);
} else {
- final Coordinates3D vB = support.get(1);
+ final Cartesian3D vB = support.get(1);
if (support.size() < 3) {
- return new EnclosingBall<>(new Coordinates3D(0.5, vA, 0.5, vB),
+ return new EnclosingBall<>(new Cartesian3D(0.5, vA, 0.5, vB),
0.5 * vA.distance(vB),
vA, vB);
} else {
- final Coordinates3D vC = support.get(2);
+ final Cartesian3D vC = support.get(2);
if (support.size() < 4) {
// delegate to 2D disk generator
final Plane p = new Plane(vA, vB, vC,
1.0e-10 * (vA.getNorm1() + vB.getNorm1() + vC.getNorm1()));
- final EnclosingBall<Euclidean2D, Coordinates2D> disk =
+ final EnclosingBall<Euclidean2D, Cartesian2D> disk =
new DiskGenerator().ballOnSupport(Arrays.asList(p.toSubSpace(vA),
p.toSubSpace(vB),
p.toSubSpace(vC)));
@@ -65,7 +65,7 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Coordi
disk.getRadius(), vA, vB, vC);
} else {
- final Coordinates3D vD = support.get(3);
+ final Cartesian3D vD = support.get(3);
// a sphere is 3D can be defined as:
// (1) (x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 = r^2
// which can be written:
@@ -118,7 +118,7 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Coordi
final BigFraction dy = c3[0].subtract(centerY);
final BigFraction dz = c4[0].subtract(centerZ);
final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz));
- return new EnclosingBall<>(new Coordinates3D(centerX.doubleValue(),
+ return new EnclosingBall<>(new Cartesian3D(centerX.doubleValue(),
centerY.doubleValue(),
centerZ.doubleValue()),
FastMath.sqrt(r2.doubleValue()),
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinates.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinates.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinates.java
index aa4582a..b82ec20 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinates.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphericalCoordinates.java
@@ -55,7 +55,7 @@ public class SphericalCoordinates implements Serializable {
private static final long serialVersionUID = 20130206L;
/** Cartesian coordinates. */
- private final Coordinates3D v;
+ private final Cartesian3D v;
/** Radius. */
private final double r;
@@ -81,7 +81,7 @@ public class SphericalCoordinates implements Serializable {
/** Build a spherical coordinates transformer from Cartesian coordinates.
* @param v Cartesian coordinates
*/
- public SphericalCoordinates(final Coordinates3D v) {
+ public SphericalCoordinates(final Cartesian3D v) {
// Cartesian coordinates
this.v = v;
@@ -111,7 +111,7 @@ public class SphericalCoordinates implements Serializable {
this.phi = phi;
// Cartesian coordinates
- this.v = new Coordinates3D(r * cosTheta * sinPhi,
+ this.v = new Cartesian3D(r * cosTheta * sinPhi,
r * sinTheta * sinPhi,
r * cosPhi);
@@ -120,7 +120,7 @@ public class SphericalCoordinates implements Serializable {
/** Get the Cartesian coordinates.
* @return Cartesian coordinates
*/
- public Coordinates3D getCartesian() {
+ public Cartesian3D getCartesian() {
return v;
}
@@ -387,7 +387,7 @@ public class SphericalCoordinates implements Serializable {
* @return replacement {@link SphericalCoordinates}
*/
private Object readResolve() {
- return new SphericalCoordinates(new Coordinates3D(x, y, z));
+ return new SphericalCoordinates(new Cartesian3D(x, y, z));
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java
index 1dc0361..8eab249 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.Interval;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.Region.Location;
/** This class represents a subset of a {@link Line}.
@@ -54,7 +54,7 @@ public class SubLine {
* @exception MathIllegalArgumentException if the points are equal
* @since 3.3
*/
- public SubLine(final Coordinates3D start, final Coordinates3D end, final double tolerance)
+ public SubLine(final Cartesian3D start, final Cartesian3D end, final double tolerance)
throws MathIllegalArgumentException {
this(new Line(start, end, tolerance), buildIntervalSet(start, end, tolerance));
}
@@ -88,8 +88,8 @@ public class SubLine {
final List<Segment> segments = new ArrayList<>(list.size());
for (final Interval interval : list) {
- final Coordinates3D start = line.toSpace((Point<Euclidean1D>) new Coordinates1D(interval.getInf()));
- final Coordinates3D end = line.toSpace((Point<Euclidean1D>) new Coordinates1D(interval.getSup()));
+ final Cartesian3D start = line.toSpace(new Cartesian1D(interval.getInf()));
+ final Cartesian3D end = line.toSpace(new Cartesian1D(interval.getSup()));
segments.add(new Segment(start, end, line));
}
@@ -111,10 +111,10 @@ public class SubLine {
* occurring on endpoints lead to null being returned
* @return the intersection point if there is one, null if the sub-lines don't intersect
*/
- public Coordinates3D intersection(final SubLine subLine, final boolean includeEndPoints) {
+ public Cartesian3D intersection(final SubLine subLine, final boolean includeEndPoints) {
// compute the intersection on infinite line
- Coordinates3D v1D = line.intersection(subLine.line);
+ Cartesian3D v1D = line.intersection(subLine.line);
if (v1D == null) {
return null;
}
@@ -140,7 +140,7 @@ public class SubLine {
* @param tolerance tolerance below which points are considered identical
* @exception MathIllegalArgumentException if the points are equal
*/
- private static IntervalsSet buildIntervalSet(final Coordinates3D start, final Coordinates3D end, final double tolerance)
+ private static IntervalsSet buildIntervalSet(final Cartesian3D start, final Cartesian3D end, final double tolerance)
throws MathIllegalArgumentException {
final Line line = new Line(start, end, tolerance);
return new IntervalsSet(line.toSubSpace((Point<Euclidean3D>) start).getX(),
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java
index bb2de1b..adc6860 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java
@@ -16,12 +16,10 @@
*/
package org.apache.commons.math4.geometry.euclidean.threed;
-import org.apache.commons.math4.geometry.Point;
-import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
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.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
@@ -76,11 +74,11 @@ public class SubPlane extends AbstractSubHyperplane<Euclidean3D, Euclidean2D> {
}
// the hyperplanes do intersect
- Coordinates2D p = thisPlane.toSubSpace((Point<Euclidean3D>) inter.toSpace((Point<Euclidean1D>) Coordinates1D.ZERO));
- Coordinates2D q = thisPlane.toSubSpace((Point<Euclidean3D>) inter.toSpace((Point<Euclidean1D>) Coordinates1D.ONE));
- Coordinates3D crossP = Coordinates3D.crossProduct(inter.getDirection(), thisPlane.getNormal());
+ Cartesian2D p = thisPlane.toSubSpace(inter.toSpace(Cartesian1D.ZERO));
+ Cartesian2D q = thisPlane.toSubSpace(inter.toSpace(Cartesian1D.ONE));
+ Cartesian3D crossP = Cartesian3D.crossProduct(inter.getDirection(), thisPlane.getNormal());
if (crossP.dotProduct(otherPlane.getNormal()) < 0) {
- final Coordinates2D tmp = p;
+ final Cartesian2D tmp = p;
p = q;
q = tmp;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
index fd6cce9..dc2c0f9 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
@@ -104,7 +104,7 @@ public class Vector3DFormat extends VectorFormat<Euclidean3D> {
}
/**
- * Formats a {@link Coordinates3D} object to produce a string.
+ * Formats a {@link Cartesian3D} object to produce a string.
* @param vector the object to format.
* @param toAppendTo where the text is to be appended
* @param pos On input: an alignment field, if desired. On output: the
@@ -114,42 +114,42 @@ public class Vector3DFormat extends VectorFormat<Euclidean3D> {
@Override
public StringBuffer format(final Vector<Euclidean3D> vector, final StringBuffer toAppendTo,
final FieldPosition pos) {
- final Coordinates3D v3 = (Coordinates3D) vector;
+ final Cartesian3D v3 = (Cartesian3D) vector;
return format(toAppendTo, pos, v3.getX(), v3.getY(), v3.getZ());
}
/**
- * Parses a string to produce a {@link Coordinates3D} object.
+ * Parses a string to produce a {@link Cartesian3D} object.
* @param source the string to parse
- * @return the parsed {@link Coordinates3D} object.
+ * @return the parsed {@link Cartesian3D} object.
* @throws MathParseException if the beginning of the specified string
* cannot be parsed.
*/
@Override
- public Coordinates3D parse(final String source) throws MathParseException {
+ public Cartesian3D parse(final String source) throws MathParseException {
ParsePosition parsePosition = new ParsePosition(0);
- Coordinates3D result = parse(source, parsePosition);
+ Cartesian3D result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw new MathParseException(source,
parsePosition.getErrorIndex(),
- Coordinates3D.class);
+ Cartesian3D.class);
}
return result;
}
/**
- * Parses a string to produce a {@link Coordinates3D} object.
+ * Parses a string to produce a {@link Cartesian3D} object.
* @param source the string to parse
* @param pos input/ouput parsing parameter.
- * @return the parsed {@link Coordinates3D} object.
+ * @return the parsed {@link Cartesian3D} object.
*/
@Override
- public Coordinates3D parse(final String source, final ParsePosition pos) {
+ public Cartesian3D parse(final String source, final ParsePosition pos) {
final double[] coordinates = parseCoordinates(3, source, pos);
if (coordinates == null) {
return null;
}
- return new Coordinates3D(coordinates[0], coordinates[1], coordinates[2]);
+ return new Cartesian3D(coordinates[0], coordinates[1], coordinates[2]);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
new file mode 100644
index 0000000..0272322
--- /dev/null
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
@@ -0,0 +1,492 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.geometry.euclidean.twod;
+
+import java.text.NumberFormat;
+
+import org.apache.commons.math4.exception.DimensionMismatchException;
+import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.exception.util.LocalizedFormats;
+import org.apache.commons.math4.geometry.Point;
+import org.apache.commons.math4.geometry.Space;
+import org.apache.commons.math4.geometry.Vector;
+import org.apache.commons.math4.util.FastMath;
+import org.apache.commons.math4.util.MathArrays;
+import org.apache.commons.math4.util.MathUtils;
+
+/** This class represents a 2D point or a 2D vector.
+ * <p>An instance of Cartesian2D represents the point with the corresponding
+ * coordinates.</p>
+ * <p>An instance of Cartesian2D also represents the vector which begins at
+ * the origin and ends at the point corresponding to the coordinates.</p>
+ * <p>Instances of this class are guaranteed to be immutable.</p>
+ * @since 4.0
+ */
+public class Cartesian2D implements Point<Euclidean2D>, Vector<Euclidean2D> {
+
+ /** Origin (coordinates: 0, 0). */
+ public static final Cartesian2D ZERO = new Cartesian2D(0, 0);
+
+ // CHECKSTYLE: stop ConstantName
+ /** A vector with all coordinates set to NaN. */
+ public static final Cartesian2D NaN = new Cartesian2D(Double.NaN, Double.NaN);
+ // CHECKSTYLE: resume ConstantName
+
+ /** A vector with all coordinates set to positive infinity. */
+ public static final Cartesian2D POSITIVE_INFINITY =
+ new Cartesian2D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+
+ /** A vector with all coordinates set to negative infinity. */
+ public static final Cartesian2D NEGATIVE_INFINITY =
+ new Cartesian2D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+
+ /** Serializable UID. */
+ private static final long serialVersionUID = 266938651998679754L;
+
+ /** Abscissa. */
+ private final double x;
+
+ /** Ordinate. */
+ private final double y;
+
+ /** Simple constructor.
+ * Build a vector from its coordinates
+ * @param x abscissa
+ * @param y ordinate
+ * @see #getX()
+ * @see #getY()
+ */
+ public Cartesian2D(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** Simple constructor.
+ * Build a vector from its coordinates
+ * @param v coordinates array
+ * @exception DimensionMismatchException if array does not have 2 elements
+ * @see #toArray()
+ */
+ public Cartesian2D(double[] v) throws DimensionMismatchException {
+ if (v.length != 2) {
+ throw new DimensionMismatchException(v.length, 2);
+ }
+ this.x = v[0];
+ this.y = v[1];
+ }
+
+ /** Multiplicative constructor
+ * Build a vector from another one and a scale factor.
+ * The vector built will be a * u
+ * @param a scale factor
+ * @param u base (unscaled) vector
+ */
+ public Cartesian2D(double a, Cartesian2D u) {
+ this.x = a * u.x;
+ this.y = a * u.y;
+ }
+
+ /** Linear constructor
+ * Build a vector from two other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ */
+ public Cartesian2D(double a1, Cartesian2D u1, double a2, Cartesian2D u2) {
+ this.x = a1 * u1.x + a2 * u2.x;
+ this.y = a1 * u1.y + a2 * u2.y;
+ }
+
+ /** Linear constructor
+ * Build a vector from three other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2 + a3 * u3
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ * @param a3 third scale factor
+ * @param u3 third base (unscaled) vector
+ */
+ public Cartesian2D(double a1, Cartesian2D u1, double a2, Cartesian2D u2,
+ double a3, Cartesian2D u3) {
+ this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x;
+ this.y = a1 * u1.y + a2 * u2.y + a3 * u3.y;
+ }
+
+ /** Linear constructor
+ * Build a vector from four other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ * @param a3 third scale factor
+ * @param u3 third base (unscaled) vector
+ * @param a4 fourth scale factor
+ * @param u4 fourth base (unscaled) vector
+ */
+ public Cartesian2D(double a1, Cartesian2D u1, double a2, Cartesian2D u2,
+ double a3, Cartesian2D u3, double a4, Cartesian2D u4) {
+ this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x + a4 * u4.x;
+ this.y = a1 * u1.y + a2 * u2.y + a3 * u3.y + a4 * u4.y;
+ }
+
+ /** Get the abscissa of the vector.
+ * @return abscissa of the vector
+ * @see #Vector2D(double, double)
+ */
+ public double getX() {
+ return x;
+ }
+
+ /** Get the ordinate of the vector.
+ * @return ordinate of the vector
+ * @see #Vector2D(double, double)
+ */
+ public double getY() {
+ return y;
+ }
+
+ /** Get the vector coordinates as a dimension 2 array.
+ * @return vector coordinates
+ * @see #Vector2D(double[])
+ */
+ public double[] toArray() {
+ return new double[] { x, y };
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Space getSpace() {
+ return Euclidean2D.getInstance();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D getZero() {
+ return ZERO;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNorm1() {
+ return FastMath.abs(x) + FastMath.abs(y);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNorm() {
+ return FastMath.sqrt (x * x + y * y);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNormSq() {
+ return x * x + y * y;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNormInf() {
+ return FastMath.max(FastMath.abs(x), FastMath.abs(y));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D add(Vector<Euclidean2D> v) {
+ Cartesian2D v2 = (Cartesian2D) v;
+ return new Cartesian2D(x + v2.getX(), y + v2.getY());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D add(double factor, Vector<Euclidean2D> v) {
+ Cartesian2D v2 = (Cartesian2D) v;
+ return new Cartesian2D(x + factor * v2.getX(), y + factor * v2.getY());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D subtract(Vector<Euclidean2D> p) {
+ Cartesian2D p3 = (Cartesian2D) p;
+ return new Cartesian2D(x - p3.x, y - p3.y);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D subtract(double factor, Vector<Euclidean2D> v) {
+ Cartesian2D v2 = (Cartesian2D) v;
+ return new Cartesian2D(x - factor * v2.getX(), y - factor * v2.getY());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D normalize() throws MathArithmeticException {
+ double s = getNorm();
+ if (s == 0) {
+ throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
+ }
+ return scalarMultiply(1 / s);
+ }
+
+ /** Compute the angular separation between two vectors.
+ * <p>This method computes the angular separation between two
+ * vectors using the dot product for well separated vectors and the
+ * cross product for almost aligned vectors. This allows to have a
+ * good accuracy in all cases, even for vectors very close to each
+ * other.</p>
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return angular separation between v1 and v2
+ * @exception MathArithmeticException if either vector has a null norm
+ */
+ public static double angle(Cartesian2D v1, Cartesian2D v2) throws MathArithmeticException {
+
+ double normProduct = v1.getNorm() * v2.getNorm();
+ if (normProduct == 0) {
+ throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
+ }
+
+ double dot = v1.dotProduct(v2);
+ double threshold = normProduct * 0.9999;
+ if ((dot < -threshold) || (dot > threshold)) {
+ // the vectors are almost aligned, compute using the sine
+ final double n = FastMath.abs(MathArrays.linearCombination(v1.x, v2.y, -v1.y, v2.x));
+ if (dot >= 0) {
+ return FastMath.asin(n / normProduct);
+ }
+ return FastMath.PI - FastMath.asin(n / normProduct);
+ }
+
+ // the vectors are sufficiently separated to use the cosine
+ return FastMath.acos(dot / normProduct);
+
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D negate() {
+ return new Cartesian2D(-x, -y);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian2D scalarMultiply(double a) {
+ return new Cartesian2D(a * x, a * y);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isNaN() {
+ return Double.isNaN(x) || Double.isNaN(y);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isInfinite() {
+ return !isNaN() && (Double.isInfinite(x) || Double.isInfinite(y));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance1(Vector<Euclidean2D> p) {
+ Cartesian2D p3 = (Cartesian2D) p;
+ final double dx = FastMath.abs(p3.x - x);
+ final double dy = FastMath.abs(p3.y - y);
+ return dx + dy;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance(Point<Euclidean2D> p) {
+ return distance((Cartesian2D) p);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance(Vector<Euclidean2D> v) {
+ return distance((Cartesian2D) v);
+ }
+
+ /** Compute the distance between the instance and other coordinates.
+ * @param c other coordinates
+ * @return the distance between the instance and c
+ */
+ public double distance(Cartesian2D c) {
+ final double dx = c.x - x;
+ final double dy = c.y - y;
+ return FastMath.sqrt(dx * dx + dy * dy);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distanceInf(Vector<Euclidean2D> p) {
+ Cartesian2D p3 = (Cartesian2D) p;
+ final double dx = FastMath.abs(p3.x - x);
+ final double dy = FastMath.abs(p3.y - y);
+ return FastMath.max(dx, dy);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distanceSq(Vector<Euclidean2D> p) {
+ Cartesian2D p3 = (Cartesian2D) p;
+ final double dx = p3.x - x;
+ final double dy = p3.y - y;
+ return dx * dx + dy * dy;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double dotProduct(final Vector<Euclidean2D> v) {
+ final Cartesian2D v2 = (Cartesian2D) v;
+ return MathArrays.linearCombination(x, v2.x, y, v2.y);
+ }
+
+ /**
+ * Compute the cross-product of the instance and the given vector.
+ * <p>
+ * The cross product can be used to determine the location of a point
+ * with regard to the line formed by (p1, p2) and is calculated as:
+ * \[
+ * P = (x_2 - x_1)(y_3 - y_1) - (y_2 - y_1)(x_3 - x_1)
+ * \]
+ * with \(p3 = (x_3, y_3)\) being this instance.
+ * <p>
+ * If the result is 0, the points are collinear, i.e. lie on a single straight line L;
+ * if it is positive, this point lies to the left, otherwise to the right of the line
+ * formed by (p1, p2).
+ *
+ * @param p1 first point of the line
+ * @param p2 second point of the line
+ * @return the cross-product
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/Cross_product">Cross product (Wikipedia)</a>
+ */
+ public double crossProduct(final Cartesian2D p1, final Cartesian2D p2) {
+ final double x1 = p2.getX() - p1.getX();
+ final double y1 = getY() - p1.getY();
+ final double x2 = getX() - p1.getX();
+ final double y2 = p2.getY() - p1.getY();
+ return MathArrays.linearCombination(x1, y1, -x2, y2);
+ }
+
+ /** Compute the distance between two points according to the L<sub>2</sub> norm.
+ * <p>Calling this method is equivalent to calling:
+ * <code>p1.subtract(p2).getNorm()</code> except that no intermediate
+ * vector is built</p>
+ * @param p1 first point
+ * @param p2 second point
+ * @return the distance between p1 and p2 according to the L<sub>2</sub> norm
+ */
+ public static double distance(Cartesian2D p1, Cartesian2D p2) {
+ return p1.distance(p2);
+ }
+
+ /** Compute the distance between two points according to the L<sub>∞</sub> norm.
+ * <p>Calling this method is equivalent to calling:
+ * <code>p1.subtract(p2).getNormInf()</code> except that no intermediate
+ * vector is built</p>
+ * @param p1 first point
+ * @param p2 second point
+ * @return the distance between p1 and p2 according to the L<sub>∞</sub> norm
+ */
+ public static double distanceInf(Cartesian2D p1, Cartesian2D p2) {
+ return p1.distanceInf(p2);
+ }
+
+ /** Compute the square of the distance between two points.
+ * <p>Calling this method is equivalent to calling:
+ * <code>p1.subtract(p2).getNormSq()</code> except that no intermediate
+ * vector is built</p>
+ * @param p1 first point
+ * @param p2 second point
+ * @return the square of the distance between p1 and p2
+ */
+ public static double distanceSq(Cartesian2D p1, Cartesian2D p2) {
+ return p1.distanceSq(p2);
+ }
+
+ /**
+ * Test for the equality of two 2D instances.
+ * <p>
+ * If all coordinates of two 2D vectors are exactly the same, and none are
+ * <code>Double.NaN</code>, the two 2D instances are considered to be equal.
+ * </p>
+ * <p>
+ * <code>NaN</code> coordinates are considered to affect globally the vector
+ * and be equals to each other - i.e, if either (or all) coordinates of the
+ * 2D vector are equal to <code>Double.NaN</code>, the 2D vector is equal to
+ * {@link #NaN}.
+ * </p>
+ *
+ * @param other Object to test for equality to this
+ * @return true if two 2D Cartesian objects are equal, false if
+ * object is null, not an instance of Cartesian2D, or
+ * not equal to this Cartesian2D instance
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+
+ if (this == other) {
+ return true;
+ }
+
+ if (other instanceof Cartesian2D) {
+ final Cartesian2D rhs = (Cartesian2D)other;
+ if (rhs.isNaN()) {
+ return this.isNaN();
+ }
+
+ return (x == rhs.x) && (y == rhs.y);
+ }
+ return false;
+ }
+
+ /**
+ * Get a hashCode for the 2D coordinates.
+ * <p>
+ * All NaN values have the same hash code.</p>
+ *
+ * @return a hash code value for this object
+ */
+ @Override
+ public int hashCode() {
+ if (isNaN()) {
+ return 542;
+ }
+ return 122 * (76 * MathUtils.hash(x) + MathUtils.hash(y));
+ }
+
+ /** Get a string representation of this vector.
+ * @return a string representation of this vector
+ */
+ @Override
+ public String toString() {
+ return Vector2DFormat.getInstance().format(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString(final NumberFormat format) {
+ return new Vector2DFormat(format).format(this);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Coordinates2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Coordinates2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Coordinates2D.java
deleted file mode 100644
index e68342e..0000000
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Coordinates2D.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.geometry.euclidean.twod;
-
-import java.text.NumberFormat;
-
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.MathArithmeticException;
-import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.geometry.Point;
-import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.Vector;
-import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.MathArrays;
-import org.apache.commons.math4.util.MathUtils;
-
-/** This class represents a 2D point or a 2D vector.
- * <p>An instance of Coordinates2D represents the point with the corresponding
- * coordinates.</p>
- * <p>An instance of Coordinates2D also represents the vector which begins at
- * the origin and ends at the point corresponding to the coordinates.</p>
- * <p>Instances of this class are guaranteed to be immutable.</p>
- * @since 4.0
- */
-public class Coordinates2D implements Point<Euclidean2D>, Vector<Euclidean2D> {
-
- /** Origin (coordinates: 0, 0). */
- public static final Coordinates2D ZERO = new Coordinates2D(0, 0);
-
- // CHECKSTYLE: stop ConstantName
- /** A vector with all coordinates set to NaN. */
- public static final Coordinates2D NaN = new Coordinates2D(Double.NaN, Double.NaN);
- // CHECKSTYLE: resume ConstantName
-
- /** A vector with all coordinates set to positive infinity. */
- public static final Coordinates2D POSITIVE_INFINITY =
- new Coordinates2D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
-
- /** A vector with all coordinates set to negative infinity. */
- public static final Coordinates2D NEGATIVE_INFINITY =
- new Coordinates2D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
-
- /** Serializable UID. */
- private static final long serialVersionUID = 266938651998679754L;
-
- /** Abscissa. */
- private final double x;
-
- /** Ordinate. */
- private final double y;
-
- /** Simple constructor.
- * Build a vector from its coordinates
- * @param x abscissa
- * @param y ordinate
- * @see #getX()
- * @see #getY()
- */
- public Coordinates2D(double x, double y) {
- this.x = x;
- this.y = y;
- }
-
- /** Simple constructor.
- * Build a vector from its coordinates
- * @param v coordinates array
- * @exception DimensionMismatchException if array does not have 2 elements
- * @see #toArray()
- */
- public Coordinates2D(double[] v) throws DimensionMismatchException {
- if (v.length != 2) {
- throw new DimensionMismatchException(v.length, 2);
- }
- this.x = v[0];
- this.y = v[1];
- }
-
- /** Multiplicative constructor
- * Build a vector from another one and a scale factor.
- * The vector built will be a * u
- * @param a scale factor
- * @param u base (unscaled) vector
- */
- public Coordinates2D(double a, Coordinates2D u) {
- this.x = a * u.x;
- this.y = a * u.y;
- }
-
- /** Linear constructor
- * Build a vector from two other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- */
- public Coordinates2D(double a1, Coordinates2D u1, double a2, Coordinates2D u2) {
- this.x = a1 * u1.x + a2 * u2.x;
- this.y = a1 * u1.y + a2 * u2.y;
- }
-
- /** Linear constructor
- * Build a vector from three other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2 + a3 * u3
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- * @param a3 third scale factor
- * @param u3 third base (unscaled) vector
- */
- public Coordinates2D(double a1, Coordinates2D u1, double a2, Coordinates2D u2,
- double a3, Coordinates2D u3) {
- this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x;
- this.y = a1 * u1.y + a2 * u2.y + a3 * u3.y;
- }
-
- /** Linear constructor
- * Build a vector from four other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- * @param a3 third scale factor
- * @param u3 third base (unscaled) vector
- * @param a4 fourth scale factor
- * @param u4 fourth base (unscaled) vector
- */
- public Coordinates2D(double a1, Coordinates2D u1, double a2, Coordinates2D u2,
- double a3, Coordinates2D u3, double a4, Coordinates2D u4) {
- this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x + a4 * u4.x;
- this.y = a1 * u1.y + a2 * u2.y + a3 * u3.y + a4 * u4.y;
- }
-
- /** Get the abscissa of the vector.
- * @return abscissa of the vector
- * @see #Vector2D(double, double)
- */
- public double getX() {
- return x;
- }
-
- /** Get the ordinate of the vector.
- * @return ordinate of the vector
- * @see #Vector2D(double, double)
- */
- public double getY() {
- return y;
- }
-
- /** Get the vector coordinates as a dimension 2 array.
- * @return vector coordinates
- * @see #Vector2D(double[])
- */
- public double[] toArray() {
- return new double[] { x, y };
- }
-
- /** {@inheritDoc} */
- @Override
- public Space getSpace() {
- return Euclidean2D.getInstance();
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D getZero() {
- return ZERO;
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNorm1() {
- return FastMath.abs(x) + FastMath.abs(y);
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNorm() {
- return FastMath.sqrt (x * x + y * y);
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNormSq() {
- return x * x + y * y;
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNormInf() {
- return FastMath.max(FastMath.abs(x), FastMath.abs(y));
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D add(Vector<Euclidean2D> v) {
- Coordinates2D v2 = (Coordinates2D) v;
- return new Coordinates2D(x + v2.getX(), y + v2.getY());
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D add(double factor, Vector<Euclidean2D> v) {
- Coordinates2D v2 = (Coordinates2D) v;
- return new Coordinates2D(x + factor * v2.getX(), y + factor * v2.getY());
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D subtract(Vector<Euclidean2D> p) {
- Coordinates2D p3 = (Coordinates2D) p;
- return new Coordinates2D(x - p3.x, y - p3.y);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D subtract(double factor, Vector<Euclidean2D> v) {
- Coordinates2D v2 = (Coordinates2D) v;
- return new Coordinates2D(x - factor * v2.getX(), y - factor * v2.getY());
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D normalize() throws MathArithmeticException {
- double s = getNorm();
- if (s == 0) {
- throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
- }
- return scalarMultiply(1 / s);
- }
-
- /** Compute the angular separation between two vectors.
- * <p>This method computes the angular separation between two
- * vectors using the dot product for well separated vectors and the
- * cross product for almost aligned vectors. This allows to have a
- * good accuracy in all cases, even for vectors very close to each
- * other.</p>
- * @param v1 first vector
- * @param v2 second vector
- * @return angular separation between v1 and v2
- * @exception MathArithmeticException if either vector has a null norm
- */
- public static double angle(Coordinates2D v1, Coordinates2D v2) throws MathArithmeticException {
-
- double normProduct = v1.getNorm() * v2.getNorm();
- if (normProduct == 0) {
- throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
- }
-
- double dot = v1.dotProduct(v2);
- double threshold = normProduct * 0.9999;
- if ((dot < -threshold) || (dot > threshold)) {
- // the vectors are almost aligned, compute using the sine
- final double n = FastMath.abs(MathArrays.linearCombination(v1.x, v2.y, -v1.y, v2.x));
- if (dot >= 0) {
- return FastMath.asin(n / normProduct);
- }
- return FastMath.PI - FastMath.asin(n / normProduct);
- }
-
- // the vectors are sufficiently separated to use the cosine
- return FastMath.acos(dot / normProduct);
-
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D negate() {
- return new Coordinates2D(-x, -y);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates2D scalarMultiply(double a) {
- return new Coordinates2D(a * x, a * y);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isNaN() {
- return Double.isNaN(x) || Double.isNaN(y);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isInfinite() {
- return !isNaN() && (Double.isInfinite(x) || Double.isInfinite(y));
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance1(Vector<Euclidean2D> p) {
- Coordinates2D p3 = (Coordinates2D) p;
- final double dx = FastMath.abs(p3.x - x);
- final double dy = FastMath.abs(p3.y - y);
- return dx + dy;
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance(Point<Euclidean2D> p) {
- return distance((Coordinates2D) p);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance(Vector<Euclidean2D> v) {
- return distance((Coordinates2D) v);
- }
-
- /** Compute the distance between the instance and other coordinates.
- * @param c other coordinates
- * @return the distance between the instance and c
- */
- public double distance(Coordinates2D c) {
- final double dx = c.x - x;
- final double dy = c.y - y;
- return FastMath.sqrt(dx * dx + dy * dy);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distanceInf(Vector<Euclidean2D> p) {
- Coordinates2D p3 = (Coordinates2D) p;
- final double dx = FastMath.abs(p3.x - x);
- final double dy = FastMath.abs(p3.y - y);
- return FastMath.max(dx, dy);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distanceSq(Vector<Euclidean2D> p) {
- Coordinates2D p3 = (Coordinates2D) p;
- final double dx = p3.x - x;
- final double dy = p3.y - y;
- return dx * dx + dy * dy;
- }
-
- /** {@inheritDoc} */
- @Override
- public double dotProduct(final Vector<Euclidean2D> v) {
- final Coordinates2D v2 = (Coordinates2D) v;
- return MathArrays.linearCombination(x, v2.x, y, v2.y);
- }
-
- /**
- * Compute the cross-product of the instance and the given points.
- * <p>
- * The cross product can be used to determine the location of a point
- * with regard to the line formed by (p1, p2) and is calculated as:
- * \[
- * P = (x_2 - x_1)(y_3 - y_1) - (y_2 - y_1)(x_3 - x_1)
- * \]
- * with \(p3 = (x_3, y_3)\) being this instance.
- * <p>
- * If the result is 0, the points are collinear, i.e. lie on a single straight line L;
- * if it is positive, this point lies to the left, otherwise to the right of the line
- * formed by (p1, p2).
- *
- * @param p1 first point of the line
- * @param p2 second point of the line
- * @return the cross-product
- *
- * @see <a href="http://en.wikipedia.org/wiki/Cross_product">Cross product (Wikipedia)</a>
- */
- public double crossProduct(final Coordinates2D p1, final Coordinates2D p2) {
- final double x1 = p2.getX() - p1.getX();
- final double y1 = getY() - p1.getY();
- final double x2 = getX() - p1.getX();
- final double y2 = p2.getY() - p1.getY();
- return MathArrays.linearCombination(x1, y1, -x2, y2);
- }
-
- /** Compute the distance between two vectors according to the L<sub>2</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>p1.subtract(p2).getNorm()</code> except that no intermediate
- * vector is built</p>
- * @param p1 first vector
- * @param p2 second vector
- * @return the distance between p1 and p2 according to the L<sub>2</sub> norm
- */
- public static double distance(Coordinates2D p1, Coordinates2D p2) {
- return p1.distance(p2);
- }
-
- /** Compute the distance between two vectors according to the L<sub>∞</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>p1.subtract(p2).getNormInf()</code> except that no intermediate
- * vector is built</p>
- * @param p1 first vector
- * @param p2 second vector
- * @return the distance between p1 and p2 according to the L<sub>∞</sub> norm
- */
- public static double distanceInf(Coordinates2D p1, Coordinates2D p2) {
- return p1.distanceInf(p2);
- }
-
- /** Compute the square of the distance between two vectors.
- * <p>Calling this method is equivalent to calling:
- * <code>p1.subtract(p2).getNormSq()</code> except that no intermediate
- * vector is built</p>
- * @param p1 first vector
- * @param p2 second vector
- * @return the square of the distance between p1 and p2
- */
- public static double distanceSq(Coordinates2D p1, Coordinates2D p2) {
- return p1.distanceSq(p2);
- }
-
- /**
- * Test for the equality of two 2D vectors.
- * <p>
- * If all coordinates of two 2D vectors are exactly the same, and none are
- * <code>Double.NaN</code>, the two 2D vectors are considered to be equal.
- * </p>
- * <p>
- * <code>NaN</code> coordinates are considered to affect globally the vector
- * and be equals to each other - i.e, if either (or all) coordinates of the
- * 2D vector are equal to <code>Double.NaN</code>, the 2D vector is equal to
- * {@link #NaN}.
- * </p>
- *
- * @param other Object to test for equality to this
- * @return true if two 2D vector objects are equal, false if
- * object is null, not an instance of Vector2D, or
- * not equal to this Vector2D instance
- *
- */
- @Override
- public boolean equals(Object other) {
-
- if (this == other) {
- return true;
- }
-
- if (other instanceof Coordinates2D) {
- final Coordinates2D rhs = (Coordinates2D)other;
- if (rhs.isNaN()) {
- return this.isNaN();
- }
-
- return (x == rhs.x) && (y == rhs.y);
- }
- return false;
- }
-
- /**
- * Get a hashCode for the 2D vector.
- * <p>
- * All NaN values have the same hash code.</p>
- *
- * @return a hash code value for this object
- */
- @Override
- public int hashCode() {
- if (isNaN()) {
- return 542;
- }
- return 122 * (76 * MathUtils.hash(x) + MathUtils.hash(y));
- }
-
- /** Get a string representation of this vector.
- * @return a string representation of this vector
- */
- @Override
- public String toString() {
- return Vector2DFormat.getInstance().format(this);
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString(final NumberFormat format) {
- return new Vector2DFormat(format).format(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java
index 7ac90d4..ba2b7cc 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java
@@ -26,26 +26,26 @@ import org.apache.commons.math4.util.FastMath;
/** Class generating an enclosing ball from its support points.
* @since 3.3
*/
-public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Coordinates2D> {
+public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Cartesian2D> {
/** {@inheritDoc} */
@Override
- public EnclosingBall<Euclidean2D, Coordinates2D> ballOnSupport(final List<Coordinates2D> support) {
+ public EnclosingBall<Euclidean2D, Cartesian2D> ballOnSupport(final List<Cartesian2D> support) {
if (support.size() < 1) {
- return new EnclosingBall<>(Coordinates2D.ZERO, Double.NEGATIVE_INFINITY);
+ return new EnclosingBall<>(Cartesian2D.ZERO, Double.NEGATIVE_INFINITY);
} else {
- final Coordinates2D vA = support.get(0);
+ final Cartesian2D vA = support.get(0);
if (support.size() < 2) {
return new EnclosingBall<>(vA, 0, vA);
} else {
- final Coordinates2D vB = support.get(1);
+ final Cartesian2D vB = support.get(1);
if (support.size() < 3) {
- return new EnclosingBall<>(new Coordinates2D(0.5, vA, 0.5, vB),
+ return new EnclosingBall<>(new Cartesian2D(0.5, vA, 0.5, vB),
0.5 * vA.distance(vB),
vA, vB);
} else {
- final Coordinates2D vC = support.get(2);
+ final Cartesian2D vC = support.get(2);
// a disk is 2D can be defined as:
// (1) (x - x_0)^2 + (y - y_0)^2 = r^2
// which can be written:
@@ -86,7 +86,7 @@ public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Coordina
final BigFraction dx = c2[0].subtract(centerX);
final BigFraction dy = c3[0].subtract(centerY);
final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy));
- return new EnclosingBall<>(new Coordinates2D(centerX.doubleValue(),
+ return new EnclosingBall<>(new Cartesian2D(centerX.doubleValue(),
centerY.doubleValue()),
FastMath.sqrt(r2.doubleValue()),
vA, vB, vC);
[19/19] [math] MATH-1284: Fix javadoc references
Posted by ra...@apache.org.
MATH-1284: Fix javadoc references
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/c9e49faa
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/c9e49faa
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/c9e49faa
Branch: refs/heads/feature-MATH-1284
Commit: c9e49faac27b1d79f266712ddee7207625b3b0ae
Parents: 05edf06
Author: Ray DeCampo <ra...@decampo.org>
Authored: Sat May 6 11:03:18 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Sat May 6 11:03:18 2017 -0400
----------------------------------------------------------------------
.../apache/commons/math4/geometry/euclidean/oned/Vector1D.java | 2 +-
.../apache/commons/math4/geometry/euclidean/twod/Vector2D.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9e49faa/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java
index f35c81f..ceeea08 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java
@@ -26,7 +26,7 @@ public abstract class Vector1D implements Vector<Euclidean1D> {
/** Get the abscissa of the vector.
* @return abscissa of the vector
- * @see #Vector1D(double)
+ * @see #Cartesian1D(double)
*/
public abstract double getX();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9e49faa/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java
index 4a2a398..a43c8a0 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java
@@ -25,13 +25,13 @@ public abstract class Vector2D implements Vector<Euclidean2D> {
/** Get the abscissa of the vector.
* @return abscissa of the vector
- * @see #Vector2D(double, double)
+ * @see #Cartesian2D(double, double)
*/
public abstract double getX();
/** Get the ordinate of the vector.
* @return ordinate of the vector
- * @see #Vector2D(double, double)
+ * @see #Cartesian2D(double, double)
*/
public abstract double getY();
[18/19] [math] MATH-1284: Restore Vector3D class as an abstract
implementation of Vector and now Cartesian3D extends Vector3D.
Restore the public interface of Vector3DFormat to act on Vector3D.
Posted by ra...@apache.org.
MATH-1284: Restore Vector3D class as an abstract implementation of Vector<Euclidean3D> and now Cartesian3D extends Vector3D.
Restore the public interface of Vector3DFormat to act on Vector3D.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/05edf063
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/05edf063
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/05edf063
Branch: refs/heads/feature-MATH-1284
Commit: 05edf06360cc8a1a61fbd1ce5f9abf5d83f9d3f9
Parents: 09c55eb
Author: Ray DeCampo <ra...@decampo.org>
Authored: Sat May 6 10:59:17 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Sat May 6 10:59:17 2017 -0400
----------------------------------------------------------------------
.../geometry/euclidean/threed/Cartesian3D.java | 2 +-
.../geometry/euclidean/threed/Vector3D.java | 46 ++++++++++++++++++++
.../euclidean/threed/Vector3DFormat.java | 20 ++++-----
.../threed/Vector3DFormatAbstractTest.java | 42 +++++++++---------
4 files changed, 78 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/05edf063/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
index 5dc04c5..3880edf 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
@@ -39,7 +39,7 @@ import org.apache.commons.math4.util.MathUtils;
* <p>Instance of this class are guaranteed to be immutable.</p>
* @since 4.0
*/
-public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euclidean3D> {
+public class Cartesian3D extends Vector3D implements Serializable, Point<Euclidean3D> {
/** Null vector (coordinates: 0, 0, 0). */
public static final Cartesian3D ZERO = new Cartesian3D(0, 0, 0);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/05edf063/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3D.java
new file mode 100644
index 0000000..23d644a
--- /dev/null
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3D.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math4.geometry.euclidean.threed;
+
+import org.apache.commons.math4.geometry.Vector;
+
+/**
+ * This class implements vectors in a three-dimensional space.
+ * @since 1.2
+ */
+public abstract class Vector3D implements Vector<Euclidean3D> {
+
+ /** Get the abscissa of the vector.
+ * @return abscissa of the vector
+ * @see #Cartesian3D(double, double, double)
+ */
+ public abstract double getX();
+
+ /** Get the ordinate of the vector.
+ * @return ordinate of the vector
+ * @see #Cartesian3D(double, double, double)
+ */
+ public abstract double getY();
+
+ /** Get the height of the vector.
+ * @return height of the vector
+ * @see #Cartesian3D(double, double, double)
+ */
+ public abstract double getZ();
+
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/05edf063/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
index dc2c0f9..1991c53 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DFormat.java
@@ -104,7 +104,7 @@ public class Vector3DFormat extends VectorFormat<Euclidean3D> {
}
/**
- * Formats a {@link Cartesian3D} object to produce a string.
+ * Formats a {@link Vector3D} object to produce a string.
* @param vector the object to format.
* @param toAppendTo where the text is to be appended
* @param pos On input: an alignment field, if desired. On output: the
@@ -114,37 +114,37 @@ public class Vector3DFormat extends VectorFormat<Euclidean3D> {
@Override
public StringBuffer format(final Vector<Euclidean3D> vector, final StringBuffer toAppendTo,
final FieldPosition pos) {
- final Cartesian3D v3 = (Cartesian3D) vector;
+ final Vector3D v3 = (Vector3D) vector;
return format(toAppendTo, pos, v3.getX(), v3.getY(), v3.getZ());
}
/**
- * Parses a string to produce a {@link Cartesian3D} object.
+ * Parses a string to produce a {@link Vector3D} object.
* @param source the string to parse
- * @return the parsed {@link Cartesian3D} object.
+ * @return the parsed {@link Vector3D} object.
* @throws MathParseException if the beginning of the specified string
* cannot be parsed.
*/
@Override
- public Cartesian3D parse(final String source) throws MathParseException {
+ public Vector3D parse(final String source) throws MathParseException {
ParsePosition parsePosition = new ParsePosition(0);
- Cartesian3D result = parse(source, parsePosition);
+ Vector3D result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw new MathParseException(source,
parsePosition.getErrorIndex(),
- Cartesian3D.class);
+ Vector3D.class);
}
return result;
}
/**
- * Parses a string to produce a {@link Cartesian3D} object.
+ * Parses a string to produce a {@link Vector3D} object.
* @param source the string to parse
* @param pos input/ouput parsing parameter.
- * @return the parsed {@link Cartesian3D} object.
+ * @return the parsed {@link Vector3D} object.
*/
@Override
- public Cartesian3D parse(final String source, final ParsePosition pos) {
+ public Vector3D parse(final String source, final ParsePosition pos) {
final double[] coordinates = parseCoordinates(3, source, pos);
if (coordinates == null) {
return null;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/05edf063/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 9092797..5d03373 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
@@ -163,8 +163,8 @@ public abstract class Vector3DFormatAbstractTest {
@Test
public void testParseSimpleNoDecimals() throws MathParseException {
String source = "{1; 1; 1}";
- Cartesian3D expected = new Cartesian3D(1, 1, 1);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(1, 1, 1);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -188,8 +188,8 @@ public abstract class Vector3DFormatAbstractTest {
"23; 1" + getDecimalCharacter() +
"43; 1" + getDecimalCharacter() +
"63}";
- Cartesian3D expected = new Cartesian3D(1.23, 1.43, 1.63);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(1.23, 1.43, 1.63);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -200,8 +200,8 @@ public abstract class Vector3DFormatAbstractTest {
"2323; 1" + getDecimalCharacter() +
"4343; 1" + getDecimalCharacter() +
"6333}";
- Cartesian3D expected = new Cartesian3D(1.2323, 1.4343, 1.6333);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(1.2323, 1.4343, 1.6333);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -212,8 +212,8 @@ public abstract class Vector3DFormatAbstractTest {
"2323; 1" + getDecimalCharacter() +
"4343; 1" + getDecimalCharacter() +
"6333}";
- Cartesian3D expected = new Cartesian3D(-1.2323, 1.4343, 1.6333);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(-1.2323, 1.4343, 1.6333);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -224,8 +224,8 @@ public abstract class Vector3DFormatAbstractTest {
"2323; -1" + getDecimalCharacter() +
"4343; 1" + getDecimalCharacter() +
"6333}";
- Cartesian3D expected = new Cartesian3D(1.2323, -1.4343, 1.6333);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(1.2323, -1.4343, 1.6333);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -236,8 +236,8 @@ public abstract class Vector3DFormatAbstractTest {
"2323; 1" + getDecimalCharacter() +
"4343; -1" + getDecimalCharacter() +
"6333}";
- Cartesian3D expected = new Cartesian3D(1.2323, 1.4343, -1.6333);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(1.2323, 1.4343, -1.6333);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -248,8 +248,8 @@ public abstract class Vector3DFormatAbstractTest {
"2323; -1" + getDecimalCharacter() +
"4343; -1" + getDecimalCharacter() +
"6333}";
- Cartesian3D expected = new Cartesian3D(-1.2323, -1.4343, -1.6333);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(-1.2323, -1.4343, -1.6333);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -260,8 +260,8 @@ public abstract class Vector3DFormatAbstractTest {
"0; -1" + getDecimalCharacter() +
"4343; 1" + getDecimalCharacter() +
"6333}";
- Cartesian3D expected = new Cartesian3D(0.0, -1.4343, 1.6333);
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D expected = new Cartesian3D(0.0, -1.4343, 1.6333);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -272,29 +272,29 @@ public abstract class Vector3DFormatAbstractTest {
"2323 : 1" + getDecimalCharacter() +
"4343 : 1" + getDecimalCharacter() +
"6333]";
- Cartesian3D expected = new Cartesian3D(1.2323, 1.4343, 1.6333);
- Cartesian3D actual = vector3DFormatSquare.parse(source);
+ Vector3D expected = new Cartesian3D(1.2323, 1.4343, 1.6333);
+ Vector3D actual = vector3DFormatSquare.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseNan() throws MathParseException {
String source = "{(NaN); (NaN); (NaN)}";
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(Cartesian3D.NaN, actual);
}
@Test
public void testParsePositiveInfinity() throws MathParseException {
String source = "{(Infinity); (Infinity); (Infinity)}";
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(Cartesian3D.POSITIVE_INFINITY, actual);
}
@Test
public void testParseNegativeInfinity() throws MathParseException {
String source = "{(-Infinity); (-Infinity); (-Infinity)}";
- Cartesian3D actual = vector3DFormat.parse(source);
+ Vector3D actual = vector3DFormat.parse(source);
Assert.assertEquals(Cartesian3D.NEGATIVE_INFINITY, actual);
}
[07/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
Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
index 1e09a2d..8710e47 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math4.geometry.spherical.twod;
-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.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
import org.apache.commons.math4.geometry.partitioning.Region;
@@ -52,7 +52,7 @@ public class SubCircle extends AbstractSubHyperplane<Sphere2D, Sphere1D> {
final Circle thisCircle = (Circle) getHyperplane();
final Circle otherCircle = (Circle) hyperplane;
- final double angle = Coordinates3D.angle(thisCircle.getPole(), otherCircle.getPole());
+ final double angle = Cartesian3D.angle(thisCircle.getPole(), otherCircle.getPole());
if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) {
// the two circles are aligned or opposite
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java b/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
index 16159ec..06feaa5 100644
--- a/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
+++ b/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.ZeroException;
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
import org.apache.commons.math4.geometry.euclidean.threed.RotationConvention;
-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.Test;
import org.junit.Assert;
@@ -121,16 +121,16 @@ public class QuaternionTest {
// qResult = (scalarA * scalarB - vectorA . vectorB) + (scalarA * vectorB + scalarB * vectorA + vectorA ^
// vectorB)
- final Coordinates3D vectorA = new Coordinates3D(qA.getVectorPart());
- final Coordinates3D vectorB = new Coordinates3D(qB.getVectorPart());
- final Coordinates3D vectorResult = new Coordinates3D(qResult.getVectorPart());
+ final Cartesian3D vectorA = new Cartesian3D(qA.getVectorPart());
+ final Cartesian3D vectorB = new Cartesian3D(qB.getVectorPart());
+ final Cartesian3D vectorResult = new Cartesian3D(qResult.getVectorPart());
- final double scalarPartRef = qA.getScalarPart() * qB.getScalarPart() - Coordinates3D.dotProduct(vectorA, vectorB);
+ final double scalarPartRef = qA.getScalarPart() * qB.getScalarPart() - Cartesian3D.dotProduct(vectorA, vectorB);
Assert.assertEquals(scalarPartRef, qResult.getScalarPart(), EPS);
- final Coordinates3D vectorPartRef = ((vectorA.scalarMultiply(qB.getScalarPart())).add(vectorB.scalarMultiply(qA
- .getScalarPart()))).add(Coordinates3D.crossProduct(vectorA, vectorB));
+ final Cartesian3D vectorPartRef = ((vectorA.scalarMultiply(qB.getScalarPart())).add(vectorB.scalarMultiply(qA
+ .getScalarPart()))).add(Cartesian3D.crossProduct(vectorA, vectorB));
final double norm = (vectorResult.subtract(vectorPartRef)).getNorm();
Assert.assertEquals(0, norm, EPS);
@@ -167,12 +167,12 @@ public class QuaternionTest {
final double[] vectorQ = quaternion.getVectorPart();
final double[] vectorResultQxV = qResultQxV.getVectorPart();
- final double scalarPartRefQxV = -Coordinates3D.dotProduct(new Coordinates3D(vectorQ), new Coordinates3D(vector));
+ final double scalarPartRefQxV = -Cartesian3D.dotProduct(new Cartesian3D(vectorQ), new Cartesian3D(vector));
Assert.assertEquals(scalarPartRefQxV, qResultQxV.getScalarPart(), EPS);
- final Coordinates3D vectorPartRefQxV = (new Coordinates3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Coordinates3D
- .crossProduct(new Coordinates3D(vectorQ), new Coordinates3D(vector)));
- final double normQxV = (new Coordinates3D(vectorResultQxV).subtract(vectorPartRefQxV)).getNorm();
+ final Cartesian3D vectorPartRefQxV = (new Cartesian3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Cartesian3D
+ .crossProduct(new Cartesian3D(vectorQ), new Cartesian3D(vector)));
+ final double normQxV = (new Cartesian3D(vectorResultQxV).subtract(vectorPartRefQxV)).getNorm();
Assert.assertEquals(0, normQxV, EPS);
// Case : Product between a vector and a quaternion : VxQ
@@ -189,12 +189,12 @@ public class QuaternionTest {
// comparison with the result given by the formula :
// qResult = (- vector . vectorQ) + (scalarQ * vector + vector ^ vectorQ)
- final double scalarPartRefVxQ = -Coordinates3D.dotProduct(new Coordinates3D(vectorQ), new Coordinates3D(vector));
+ final double scalarPartRefVxQ = -Cartesian3D.dotProduct(new Cartesian3D(vectorQ), new Cartesian3D(vector));
Assert.assertEquals(scalarPartRefVxQ, qResultVxQ.getScalarPart(), EPS);
- final Coordinates3D vectorPartRefVxQ = (new Coordinates3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Coordinates3D
- .crossProduct(new Coordinates3D(vector), new Coordinates3D(vectorQ)));
- final double normVxQ = (new Coordinates3D(vectorResultVxQ).subtract(vectorPartRefVxQ)).getNorm();
+ final Cartesian3D vectorPartRefVxQ = (new Cartesian3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Cartesian3D
+ .crossProduct(new Cartesian3D(vector), new Cartesian3D(vectorQ)));
+ final double normVxQ = (new Cartesian3D(vectorResultVxQ).subtract(vectorPartRefVxQ)).getNorm();
Assert.assertEquals(0, normVxQ, EPS);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
index 648fee3..1bea90a 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem;
import org.apache.commons.math4.fitting.leastsquares.MultivariateJacobianFunction;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem.Evaluation;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.linear.Array2DRowRealMatrix;
import org.apache.commons.math4.linear.ArrayRealVector;
import org.apache.commons.math4.linear.BlockRealMatrix;
@@ -412,7 +412,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
double rms = optimum.getRMS();
Assert.assertEquals(1.768262623567235, FastMath.sqrt(circle.getN()) * rms, TOl);
- Coordinates2D center = new Coordinates2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
+ Cartesian2D center = new Cartesian2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
Assert.assertEquals(69.96016176931406, circle.getRadius(center), 1e-6);
Assert.assertEquals(96.07590211815305, center.getX(), 1e-6);
Assert.assertEquals(48.13516790438953, center.getY(), 1e-6);
@@ -455,7 +455,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
Optimum optimum = optimizer.optimize(builder(circle).weight(new DiagonalMatrix(weights)).start(start).build());
- Coordinates2D center = new Coordinates2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
+ Cartesian2D center = new Cartesian2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
Assert.assertTrue(optimum.getEvaluations() < 25);
Assert.assertEquals(0.043, optimum.getRMS(), 1e-3);
Assert.assertEquals(0.292235, circle.getRadius(center), 1e-6);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
index 414ee2c..db9cef8 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
@@ -20,29 +20,29 @@ import java.util.ArrayList;
import org.apache.commons.math4.analysis.MultivariateMatrixFunction;
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;
/**
* Class used in the tests.
*/
class CircleVectorial {
- private ArrayList<Coordinates2D> points;
+ private ArrayList<Cartesian2D> points;
public CircleVectorial() {
points = new ArrayList<>();
}
public void addPoint(double px, double py) {
- points.add(new Coordinates2D(px, py));
+ points.add(new Cartesian2D(px, py));
}
public int getN() {
return points.size();
}
- 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();
@@ -52,7 +52,7 @@ class CircleVectorial {
return 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);
double[] residuals = new double[points.size()];
for (int i = 0; i < residuals.length; i++) {
@@ -69,11 +69,11 @@ class CircleVectorial {
@Override
public double[][] value(double[] params) {
final int n = points.size();
- final Coordinates2D center = new Coordinates2D(params[0], params[1]);
+ final Cartesian2D center = new Cartesian2D(params[0], params[1]);
double dRdX = 0;
double dRdY = 0;
- for (Coordinates2D pk : points) {
+ for (Cartesian2D pk : points) {
double dk = pk.distance(center);
dRdX += (center.getX() - pk.getX()) / dk;
dRdY += (center.getY() - pk.getY()) / dk;
@@ -84,7 +84,7 @@ class CircleVectorial {
// Jacobian of the radius residuals.
double[][] jacobian = new double[n][2];
for (int i = 0; i < n; i++) {
- final Coordinates2D pi = points.get(i);
+ final Cartesian2D pi = points.get(i);
final double di = pi.distance(center);
jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX;
jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
index 5f121e0..626a3a0 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
@@ -25,7 +25,7 @@ import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem;
import org.apache.commons.math4.fitting.leastsquares.GaussNewtonOptimizer.Decomposition;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.geometry.euclidean.threed.Plane;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.optim.SimpleVectorValueChecker;
import org.apache.commons.math4.util.FastMath;
import org.junit.Assert;
@@ -140,8 +140,8 @@ public class GaussNewtonOptimizerWithSVDTest
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Plane span = new Plane(Coordinates3D.ZERO, new Coordinates3D(1, 2, -3), new Coordinates3D(2, 1, 0), TOl);
- double expected = FastMath.abs(span.getOffset(new Coordinates3D(1, 1, 1)));
+ Plane span = new Plane(Cartesian3D.ZERO, new Cartesian3D(1, 2, -3), new Cartesian3D(2, 1, 0), TOl);
+ double expected = FastMath.abs(span.getOffset(new Cartesian3D(1, 1, 1)));
double actual = optimum.getResiduals().getNorm();
//verify
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
index 56980a6..8d0f495 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.fitting.leastsquares.LevenbergMarquardtOptimizer
import org.apache.commons.math4.fitting.leastsquares.ParameterValidator;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem.Evaluation;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.linear.DiagonalMatrix;
import org.apache.commons.math4.linear.RealMatrix;
import org.apache.commons.math4.linear.RealVector;
@@ -270,7 +270,7 @@ public class LevenbergMarquardtOptimizerTest
final CircleProblem circle = new CircleProblem(xSigma, ySigma);
final int numPoints = 10;
- for (Coordinates2D p : factory.generate(numPoints)) {
+ for (Cartesian2D p : factory.generate(numPoints)) {
circle.addPoint(p.getX(), p.getY());
}
@@ -307,7 +307,7 @@ public class LevenbergMarquardtOptimizerTest
final CircleProblem circle = new CircleProblem(xSigma, ySigma);
final int numPoints = 10;
- for (Coordinates2D p : factory.generate(numPoints)) {
+ for (Cartesian2D p : factory.generate(numPoints)) {
circle.addPoint(p.getX(), p.getY());
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
index a849c03..312b67f 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.fitting.leastsquares;
import org.apache.commons.math4.distribution.NormalDistribution;
import org.apache.commons.math4.distribution.RealDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.util.FastMath;
@@ -65,8 +65,8 @@ public class RandomCirclePointGenerator {
* @param n Number of points to create.
* @return the cloud of {@code n} points.
*/
- public Coordinates2D[] generate(int n) {
- final Coordinates2D[] cloud = new Coordinates2D[n];
+ public Cartesian2D[] generate(int n) {
+ final Cartesian2D[] cloud = new Cartesian2D[n];
for (int i = 0; i < n; i++) {
cloud[i] = create();
}
@@ -78,11 +78,11 @@ public class RandomCirclePointGenerator {
*
* @return a point.
*/
- private Coordinates2D create() {
+ private Cartesian2D create() {
final double t = tP.sample();
final double pX = cX.sample() + radius * FastMath.cos(t);
final double pY = cY.sample() + radius * FastMath.sin(t);
- return new Coordinates2D(pX, pY);
+ return new Cartesian2D(pX, pY);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
index 2e08195..bde0468 100644
--- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.enclosing.EnclosingBall;
import org.apache.commons.math4.geometry.enclosing.WelzlEncloser;
import org.apache.commons.math4.geometry.euclidean.twod.DiskGenerator;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.junit.Assert;
@@ -36,36 +36,36 @@ public class WelzlEncloser2DTest {
@Test
public void testNullList() {
DiskGenerator generator = new DiskGenerator();
- WelzlEncloser<Euclidean2D, Coordinates2D> encloser =
+ WelzlEncloser<Euclidean2D, Cartesian2D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean2D, Coordinates2D> ball = encloser.enclose(null);
+ EnclosingBall<Euclidean2D, Cartesian2D> ball = encloser.enclose(null);
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testNoPoints() {
DiskGenerator generator = new DiskGenerator();
- WelzlEncloser<Euclidean2D, Coordinates2D> encloser =
+ WelzlEncloser<Euclidean2D, Cartesian2D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean2D, Coordinates2D> ball = encloser.enclose(new ArrayList<Coordinates2D>());
+ EnclosingBall<Euclidean2D, Cartesian2D> ball = encloser.enclose(new ArrayList<Cartesian2D>());
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testRegularPoints() {
- List<Coordinates2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54, 11, 15);
+ List<Cartesian2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54, 11, 15);
checkDisk(list, Arrays.asList(list.get(2), list.get(3), list.get(4)));
}
@Test
public void testSolutionOnDiameter() {
- List<Coordinates2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54);
+ List<Cartesian2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54);
checkDisk(list, Arrays.asList(list.get(2), list.get(3)));
}
@Test
public void testReducingBall1() {
- List<Coordinates2D> list = buildList(0.05380958511396061, 0.57332359658700000,
+ List<Cartesian2D> list = buildList(0.05380958511396061, 0.57332359658700000,
0.99348810731127870, 0.02056421361521466,
0.01203950647796437, 0.99779675042261860,
0.00810189987706078, 0.00589246003827815,
@@ -75,7 +75,7 @@ public class WelzlEncloser2DTest {
@Test
public void testReducingBall2() {
- List<Coordinates2D> list = buildList(0.016930586154703, 0.333955448537779,
+ List<Cartesian2D> list = buildList(0.016930586154703, 0.333955448537779,
0.987189104892331, 0.969778855274507,
0.983696889599935, 0.012904580013266,
0.013114499572905, 0.034740156356895);
@@ -87,39 +87,39 @@ public class WelzlEncloser2DTest {
UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xa2a63cad12c01fb2l);
for (int k = 0; k < 100; ++k) {
int nbPoints = random.nextInt(10000);
- List<Coordinates2D> points = new ArrayList<>();
+ List<Cartesian2D> points = new ArrayList<>();
for (int i = 0; i < nbPoints; ++i) {
double x = random.nextDouble();
double y = random.nextDouble();
- points.add(new Coordinates2D(x, y));
+ points.add(new Cartesian2D(x, y));
}
checkDisk(points);
}
}
- private List<Coordinates2D> buildList(final double ... coordinates) {
- List<Coordinates2D> list = new ArrayList<>(coordinates.length / 2);
+ private List<Cartesian2D> buildList(final double ... coordinates) {
+ List<Cartesian2D> list = new ArrayList<>(coordinates.length / 2);
for (int i = 0; i < coordinates.length; i += 2) {
- list.add(new Coordinates2D(coordinates[i], coordinates[i + 1]));
+ list.add(new Cartesian2D(coordinates[i], coordinates[i + 1]));
}
return list;
}
- private void checkDisk(List<Coordinates2D> points, List<Coordinates2D> refSupport) {
+ private void checkDisk(List<Cartesian2D> points, List<Cartesian2D> refSupport) {
- EnclosingBall<Euclidean2D, Coordinates2D> disk = checkDisk(points);
+ EnclosingBall<Euclidean2D, Cartesian2D> disk = checkDisk(points);
// compare computed disk with expected disk
DiskGenerator generator = new DiskGenerator();
- EnclosingBall<Euclidean2D, Coordinates2D> expected = generator.ballOnSupport(refSupport);
+ EnclosingBall<Euclidean2D, Cartesian2D> expected = generator.ballOnSupport(refSupport);
Assert.assertEquals(refSupport.size(), disk.getSupportSize());
Assert.assertEquals(expected.getRadius(), disk.getRadius(), 1.0e-10);
Assert.assertEquals(expected.getCenter().getX(), disk.getCenter().getX(), 1.0e-10);
Assert.assertEquals(expected.getCenter().getY(), disk.getCenter().getY(), 1.0e-10);
- for (Coordinates2D s : disk.getSupport()) {
+ for (Cartesian2D s : disk.getSupport()) {
boolean found = false;
- for (Coordinates2D rs : refSupport) {
+ for (Cartesian2D rs : refSupport) {
if (s == rs) {
found = true;
}
@@ -129,14 +129,14 @@ public class WelzlEncloser2DTest {
// check removing any point of the support disk fails to enclose the point
for (int i = 0; i < disk.getSupportSize(); ++i) {
- List<Coordinates2D> reducedSupport = new ArrayList<>();
+ List<Cartesian2D> reducedSupport = new ArrayList<>();
int count = 0;
- for (Coordinates2D s : disk.getSupport()) {
+ for (Cartesian2D s : disk.getSupport()) {
if (count++ != i) {
reducedSupport.add(s);
}
}
- EnclosingBall<Euclidean2D, Coordinates2D> reducedDisk = generator.ballOnSupport(reducedSupport);
+ EnclosingBall<Euclidean2D, Cartesian2D> reducedDisk = generator.ballOnSupport(reducedSupport);
boolean foundOutside = false;
for (int j = 0; j < points.size() && !foundOutside; ++j) {
if (!reducedDisk.contains(points.get(j), 1.0e-10)) {
@@ -148,20 +148,20 @@ public class WelzlEncloser2DTest {
}
- private EnclosingBall<Euclidean2D, Coordinates2D> checkDisk(List<Coordinates2D> points) {
+ private EnclosingBall<Euclidean2D, Cartesian2D> checkDisk(List<Cartesian2D> points) {
- WelzlEncloser<Euclidean2D, Coordinates2D> encloser =
+ WelzlEncloser<Euclidean2D, Cartesian2D> encloser =
new WelzlEncloser<>(1.0e-10, new DiskGenerator());
- EnclosingBall<Euclidean2D, Coordinates2D> disk = encloser.enclose(points);
+ EnclosingBall<Euclidean2D, Cartesian2D> disk = encloser.enclose(points);
// all points are enclosed
- for (Coordinates2D v : points) {
+ for (Cartesian2D v : points) {
Assert.assertTrue(disk.contains(v, 1.0e-10));
}
- for (Coordinates2D v : points) {
+ for (Cartesian2D v : points) {
boolean inSupport = false;
- for (Coordinates2D s : disk.getSupport()) {
+ for (Cartesian2D s : disk.getSupport()) {
if (v == s) {
inSupport = true;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
index c2af261..4bd3d04 100644
--- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
@@ -25,7 +25,7 @@ import org.apache.commons.math4.geometry.enclosing.EnclosingBall;
import org.apache.commons.math4.geometry.enclosing.WelzlEncloser;
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;
@@ -38,67 +38,67 @@ public class WelzlEncloser3DTest {
@Test
public void testNullList() {
SphereGenerator generator = new SphereGenerator();
- WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
+ WelzlEncloser<Euclidean3D, Cartesian3D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(null);
+ EnclosingBall<Euclidean3D, Cartesian3D> ball = encloser.enclose(null);
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testNoPoints() {
SphereGenerator generator = new SphereGenerator();
- WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
+ WelzlEncloser<Euclidean3D, Cartesian3D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(new ArrayList<Coordinates3D>());
+ EnclosingBall<Euclidean3D, Cartesian3D> ball = encloser.enclose(new ArrayList<Cartesian3D>());
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testReducingBall() {
- List<Coordinates3D> list =
- Arrays.asList(new Coordinates3D(-7.140397329568118, -16.571661242582177, 11.714458961735405),
- new Coordinates3D(-7.137986707455888, -16.570767323375720, 11.708602108715928),
- new Coordinates3D(-7.139185068549035, -16.570891204702250, 11.715554057357394),
- new Coordinates3D(-7.142682716997507, -16.571609818234290, 11.710787934580328),
- new Coordinates3D(-7.139018392423351, -16.574405614157020, 11.710518716711425),
- new Coordinates3D(-7.140870659936730, -16.567993074240455, 11.710914678204503),
- new Coordinates3D(-7.136350173659562, -16.570498228820930, 11.713965225900928),
- new Coordinates3D(-7.141675762759172, -16.572852471407028, 11.714033471449508),
- new Coordinates3D(-7.140453077221105, -16.570212820780647, 11.708624578004980),
- new Coordinates3D(-7.140322188726825, -16.574152894557717, 11.710305611121410),
- new Coordinates3D(-7.141116131477088, -16.574061164624560, 11.712938509321699));
- WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
+ List<Cartesian3D> list =
+ Arrays.asList(new Cartesian3D(-7.140397329568118, -16.571661242582177, 11.714458961735405),
+ new Cartesian3D(-7.137986707455888, -16.570767323375720, 11.708602108715928),
+ new Cartesian3D(-7.139185068549035, -16.570891204702250, 11.715554057357394),
+ new Cartesian3D(-7.142682716997507, -16.571609818234290, 11.710787934580328),
+ new Cartesian3D(-7.139018392423351, -16.574405614157020, 11.710518716711425),
+ new Cartesian3D(-7.140870659936730, -16.567993074240455, 11.710914678204503),
+ new Cartesian3D(-7.136350173659562, -16.570498228820930, 11.713965225900928),
+ new Cartesian3D(-7.141675762759172, -16.572852471407028, 11.714033471449508),
+ new Cartesian3D(-7.140453077221105, -16.570212820780647, 11.708624578004980),
+ new Cartesian3D(-7.140322188726825, -16.574152894557717, 11.710305611121410),
+ new Cartesian3D(-7.141116131477088, -16.574061164624560, 11.712938509321699));
+ WelzlEncloser<Euclidean3D, Cartesian3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
- EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(list);
+ EnclosingBall<Euclidean3D, Cartesian3D> ball = encloser.enclose(list);
Assert.assertTrue(ball.getRadius() > 0);
}
@Test
public void testInfiniteLoop() {
// this test used to generate an infinite loop
- List<Coordinates3D> list =
- Arrays.asList(new Coordinates3D( -0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
- new Coordinates3D( -0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
- new Coordinates3D( -0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
- new Coordinates3D( -1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
- new Coordinates3D( 0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
- new Coordinates3D( -1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
- new Coordinates3D( -1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
- new Coordinates3D( 0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
- new Coordinates3D( -0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
- new Coordinates3D( -1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
- new Coordinates3D( -0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
- new Coordinates3D( -0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
- new Coordinates3D( -1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
- new Coordinates3D( -0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
- new Coordinates3D( -0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
- new Coordinates3D( -0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
- new Coordinates3D( -1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
- new Coordinates3D( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
-
- WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
+ List<Cartesian3D> list =
+ Arrays.asList(new Cartesian3D( -0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
+ new Cartesian3D( -0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
+ new Cartesian3D( -0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
+ new Cartesian3D( -1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
+ new Cartesian3D( 0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
+ new Cartesian3D( -1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
+ new Cartesian3D( -1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
+ new Cartesian3D( 0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
+ new Cartesian3D( -0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
+ new Cartesian3D( -1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
+ new Cartesian3D( -0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
+ new Cartesian3D( -0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
+ new Cartesian3D( -1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
+ new Cartesian3D( -0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
+ new Cartesian3D( -0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
+ new Cartesian3D( -0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
+ new Cartesian3D( -1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
+ new Cartesian3D( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
+
+ WelzlEncloser<Euclidean3D, Cartesian3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
- EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(list);
+ EnclosingBall<Euclidean3D, Cartesian3D> ball = encloser.enclose(list);
Assert.assertTrue(ball.getRadius() > 0);
}
@@ -112,13 +112,13 @@ public class WelzlEncloser3DTest {
// define the reference sphere we want to compute
double d = 25 * random.nextDouble();
double refRadius = 10 * random.nextDouble();
- Coordinates3D refCenter = new Coordinates3D(d, new Coordinates3D(sr.nextVector()));
+ Cartesian3D refCenter = new Cartesian3D(d, new Cartesian3D(sr.nextVector()));
// set up a large sample inside the reference sphere
int nbPoints = random.nextInt(1000);
- List<Coordinates3D> points = new ArrayList<>();
+ List<Cartesian3D> points = new ArrayList<>();
for (int i = 0; i < nbPoints; ++i) {
double r = refRadius * random.nextDouble();
- points.add(new Coordinates3D(1.0, refCenter, r, new Coordinates3D(sr.nextVector())));
+ points.add(new Cartesian3D(1.0, refCenter, r, new Cartesian3D(sr.nextVector())));
}
// test we find a sphere at most as large as the one used for random drawings
@@ -127,23 +127,23 @@ public class WelzlEncloser3DTest {
}
}
- private void checkSphere(List<Coordinates3D> points, double refRadius) {
+ private void checkSphere(List<Cartesian3D> points, double refRadius) {
- EnclosingBall<Euclidean3D, Coordinates3D> sphere = checkSphere(points);
+ EnclosingBall<Euclidean3D, Cartesian3D> sphere = checkSphere(points);
// compare computed sphere with bounding sphere
Assert.assertTrue(sphere.getRadius() <= refRadius);
// check removing any point of the support Sphere fails to enclose the point
for (int i = 0; i < sphere.getSupportSize(); ++i) {
- List<Coordinates3D> reducedSupport = new ArrayList<>();
+ List<Cartesian3D> reducedSupport = new ArrayList<>();
int count = 0;
- for (Coordinates3D s : sphere.getSupport()) {
+ for (Cartesian3D s : sphere.getSupport()) {
if (count++ != i) {
reducedSupport.add(s);
}
}
- EnclosingBall<Euclidean3D, Coordinates3D> reducedSphere =
+ EnclosingBall<Euclidean3D, Cartesian3D> reducedSphere =
new SphereGenerator().ballOnSupport(reducedSupport);
boolean foundOutside = false;
for (int j = 0; j < points.size() && !foundOutside; ++j) {
@@ -156,20 +156,20 @@ public class WelzlEncloser3DTest {
}
- private EnclosingBall<Euclidean3D, Coordinates3D> checkSphere(List<Coordinates3D> points) {
+ private EnclosingBall<Euclidean3D, Cartesian3D> checkSphere(List<Cartesian3D> points) {
- WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
+ WelzlEncloser<Euclidean3D, Cartesian3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
- EnclosingBall<Euclidean3D, Coordinates3D> Sphere = encloser.enclose(points);
+ EnclosingBall<Euclidean3D, Cartesian3D> Sphere = encloser.enclose(points);
// all points are enclosed
- for (Coordinates3D v : points) {
+ for (Cartesian3D v : points) {
Assert.assertTrue(Sphere.contains(v, 1.0e-10));
}
- for (Coordinates3D v : points) {
+ for (Cartesian3D v : points) {
boolean inSupport = false;
- for (Coordinates3D s : Sphere.getSupport()) {
+ for (Cartesian3D s : Sphere.getSupport()) {
if (v == s) {
inSupport = true;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
index 50b406b..5281ba1 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
@@ -18,10 +18,6 @@ package org.apache.commons.math4.geometry.euclidean.oned;
import java.util.List;
-import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
-import org.apache.commons.math4.geometry.euclidean.oned.Interval;
-import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
import org.apache.commons.math4.geometry.partitioning.Region;
import org.apache.commons.math4.geometry.partitioning.RegionFactory;
import org.apache.commons.math4.util.FastMath;
@@ -35,12 +31,12 @@ public class IntervalsSetTest {
public void testInterval() {
IntervalsSet set = new IntervalsSet(2.3, 5.7, 1.0e-10);
Assert.assertEquals(3.4, set.getSize(), 1.0e-10);
- Assert.assertEquals(4.0, ((Coordinates1D) set.getBarycenter()).getX(), 1.0e-10);
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(2.3)));
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(5.7)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(1.2)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(8.7)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(3.0)));
+ Assert.assertEquals(4.0, ((Cartesian1D) set.getBarycenter()).getX(), 1.0e-10);
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Cartesian1D(2.3)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Cartesian1D(5.7)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian1D(1.2)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian1D(8.7)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Cartesian1D(3.0)));
Assert.assertEquals(2.3, set.getInf(), 1.0e-10);
Assert.assertEquals(5.7, set.getSup(), 1.0e-10);
}
@@ -48,11 +44,11 @@ public class IntervalsSetTest {
@Test
public void testInfinite() {
IntervalsSet set = new IntervalsSet(9.0, Double.POSITIVE_INFINITY, 1.0e-10);
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(9.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(8.4)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Cartesian1D(9.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian1D(8.4)));
for (double e = 1.0; e <= 6.0; e += 1.0) {
Assert.assertEquals(Region.Location.INSIDE,
- set.checkPoint(new Coordinates1D(FastMath.pow(10.0, e))));
+ set.checkPoint(new Cartesian1D(FastMath.pow(10.0, e))));
}
Assert.assertTrue(Double.isInfinite(set.getSize()));
Assert.assertEquals(9.0, set.getInf(), 1.0e-10);
@@ -73,16 +69,16 @@ public class IntervalsSetTest {
new IntervalsSet(9.0, Double.POSITIVE_INFINITY, 1.0e-10)),
new IntervalsSet(Double.NEGATIVE_INFINITY, 11.0, 1.0e-10));
Assert.assertEquals(5.0, set.getSize(), 1.0e-10);
- Assert.assertEquals(5.9, ((Coordinates1D) set.getBarycenter()).getX(), 1.0e-10);
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(0.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(4.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(8.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(12.0)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(1.2)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(5.9)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(9.01)));
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(5.0)));
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(11.0)));
+ Assert.assertEquals(5.9, ((Cartesian1D) set.getBarycenter()).getX(), 1.0e-10);
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian1D(0.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian1D(4.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian1D(8.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian1D(12.0)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Cartesian1D(1.2)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Cartesian1D(5.9)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Cartesian1D(9.01)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Cartesian1D(5.0)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Cartesian1D(11.0)));
Assert.assertEquals( 1.0, set.getInf(), 1.0e-10);
Assert.assertEquals(11.0, set.getSup(), 1.0e-10);
@@ -101,7 +97,7 @@ public class IntervalsSetTest {
public void testSinglePoint() {
IntervalsSet set = new IntervalsSet(1.0, 1.0, 1.0e-10);
Assert.assertEquals(0.0, set.getSize(), Precision.SAFE_MIN);
- Assert.assertEquals(1.0, ((Coordinates1D) set.getBarycenter()).getX(), Precision.EPSILON);
+ Assert.assertEquals(1.0, ((Cartesian1D) set.getBarycenter()).getX(), Precision.EPSILON);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
index 2e26cef..2cb5ae2 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
@@ -22,7 +22,6 @@ import java.text.ParsePosition;
import java.util.Locale;
import org.apache.commons.math4.exception.MathParseException;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
import org.apache.commons.math4.geometry.euclidean.oned.Vector1DFormat;
import org.junit.Assert;
import org.junit.Test;
@@ -45,7 +44,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testSimpleNoDecimals() {
- Coordinates1D c = new Coordinates1D(1);
+ Cartesian1D c = new Cartesian1D(1);
String expected = "{1}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -53,7 +52,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testSimpleWithDecimals() {
- Coordinates1D c = new Coordinates1D(1.23);
+ Cartesian1D c = new Cartesian1D(1.23);
String expected =
"{1" + getDecimalCharacter() +
"23}";
@@ -63,7 +62,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testSimpleWithDecimalsTrunc() {
- Coordinates1D c = new Coordinates1D(1.232323232323);
+ Cartesian1D c = new Cartesian1D(1.232323232323);
String expected =
"{1" + getDecimalCharacter() +
"2323232323}";
@@ -73,7 +72,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testNegativeX() {
- Coordinates1D c = new Coordinates1D(-1.232323232323);
+ Cartesian1D c = new Cartesian1D(-1.232323232323);
String expected =
"{-1" + getDecimalCharacter() +
"2323232323}";
@@ -83,7 +82,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testNonDefaultSetting() {
- Coordinates1D c = new Coordinates1D(1);
+ Cartesian1D c = new Cartesian1D(1);
String expected = "[1]";
String actual = vector1DFormatSquare.format(c);
Assert.assertEquals(expected, actual);
@@ -94,7 +93,7 @@ public abstract class Vector1DFormatAbstractTest {
Locale defaultLocal = Locale.getDefault();
Locale.setDefault(getLocale());
- Coordinates1D c = new Coordinates1D(232.22222222222);
+ Cartesian1D c = new Cartesian1D(232.22222222222);
String expected =
"{232" + getDecimalCharacter() +
"2222222222}";
@@ -106,7 +105,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testNan() {
- Coordinates1D c = Coordinates1D.NaN;
+ Cartesian1D c = Cartesian1D.NaN;
String expected = "{(NaN)}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -114,7 +113,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testPositiveInfinity() {
- Coordinates1D c = Coordinates1D.POSITIVE_INFINITY;
+ Cartesian1D c = Cartesian1D.POSITIVE_INFINITY;
String expected = "{(Infinity)}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -122,7 +121,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void tesNegativeInfinity() {
- Coordinates1D c = Coordinates1D.NEGATIVE_INFINITY;
+ Cartesian1D c = Cartesian1D.NEGATIVE_INFINITY;
String expected = "{(-Infinity)}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -131,14 +130,14 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testParseSimpleNoDecimals() throws MathParseException {
String source = "{1}";
- Coordinates1D expected = new Coordinates1D(1);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(1);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseIgnoredWhitespace() {
- Coordinates1D expected = new Coordinates1D(1);
+ Cartesian1D expected = new Cartesian1D(1);
ParsePosition pos1 = new ParsePosition(0);
String source1 = "{1}";
Assert.assertEquals(expected, vector1DFormat.parse(source1, pos1));
@@ -154,8 +153,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"23}";
- Coordinates1D expected = new Coordinates1D(1.23);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(1.23);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -164,8 +163,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Coordinates1D expected = new Coordinates1D(1.2323);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(1.2323);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -174,8 +173,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{-1" + getDecimalCharacter() +
"2323}";
- Coordinates1D expected = new Coordinates1D(-1.2323);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(-1.2323);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -184,8 +183,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Coordinates1D expected = new Coordinates1D(1.2323);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(1.2323);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -194,8 +193,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Coordinates1D expected = new Coordinates1D(1.2323);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(1.2323);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -204,8 +203,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{-1" + getDecimalCharacter() +
"2323}";
- Coordinates1D expected = new Coordinates1D(-1.2323);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(-1.2323);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -214,8 +213,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{0" + getDecimalCharacter() +
"0}";
- Coordinates1D expected = new Coordinates1D(0.0);
- Coordinates1D actual = vector1DFormat.parse(source);
+ Cartesian1D expected = new Cartesian1D(0.0);
+ Cartesian1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -224,30 +223,30 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"[1" + getDecimalCharacter() +
"2323]";
- Coordinates1D expected = new Coordinates1D(1.2323);
- Coordinates1D actual = vector1DFormatSquare.parse(source);
+ Cartesian1D expected = new Cartesian1D(1.2323);
+ Cartesian1D actual = vector1DFormatSquare.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseNan() throws MathParseException {
String source = "{(NaN)}";
- Coordinates1D actual = vector1DFormat.parse(source);
- Assert.assertEquals(Coordinates1D.NaN, actual);
+ Cartesian1D actual = vector1DFormat.parse(source);
+ Assert.assertEquals(Cartesian1D.NaN, actual);
}
@Test
public void testParsePositiveInfinity() throws MathParseException {
String source = "{(Infinity)}";
- Coordinates1D actual = vector1DFormat.parse(source);
- Assert.assertEquals(Coordinates1D.POSITIVE_INFINITY, actual);
+ Cartesian1D actual = vector1DFormat.parse(source);
+ Assert.assertEquals(Cartesian1D.POSITIVE_INFINITY, actual);
}
@Test
public void testParseNegativeInfinity() throws MathParseException {
String source = "{(-Infinity)}";
- Coordinates1D actual = vector1DFormat.parse(source);
- Assert.assertEquals(Coordinates1D.NEGATIVE_INFINITY, actual);
+ Cartesian1D actual = vector1DFormat.parse(source);
+ Assert.assertEquals(Cartesian1D.NEGATIVE_INFINITY, actual);
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
index 832716c..c1db959 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
@@ -25,7 +25,6 @@ import java.util.Locale;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
import org.junit.Assert;
@@ -34,143 +33,143 @@ import org.junit.Test;
public class Vector1DTest {
@Test
public void testConstructors() throws DimensionMismatchException {
- checkVector(new Coordinates1D(3, new Coordinates1D(FastMath.PI / 3)),
+ checkVector(new Cartesian1D(3, new Cartesian1D(FastMath.PI / 3)),
FastMath.PI);
- checkVector(new Coordinates1D(2, Coordinates1D.ONE, -3, new Coordinates1D(2)),
+ checkVector(new Cartesian1D(2, Cartesian1D.ONE, -3, new Cartesian1D(2)),
-4);
- checkVector(new Coordinates1D(2, Coordinates1D.ONE,
- 5, new Coordinates1D(2),
- -3, new Coordinates1D(3)),
+ checkVector(new Cartesian1D(2, Cartesian1D.ONE,
+ 5, new Cartesian1D(2),
+ -3, new Cartesian1D(3)),
3);
- checkVector(new Coordinates1D(2, Coordinates1D.ONE,
- 5, new Coordinates1D(2),
- 5, new Coordinates1D(-2),
- -3, new Coordinates1D(-3)),
+ checkVector(new Cartesian1D(2, Cartesian1D.ONE,
+ 5, new Cartesian1D(2),
+ 5, new Cartesian1D(-2),
+ -3, new Cartesian1D(-3)),
11);
}
@Test
public void testSpace() {
- Space space = new Coordinates1D(1).getSpace();
+ Space space = new Cartesian1D(1).getSpace();
Assert.assertEquals(1, space.getDimension());
}
@Test
public void testZero() {
- Assert.assertEquals(0, new Coordinates1D(1).getZero().getNorm(), 1.0e-15);
+ Assert.assertEquals(0, new Cartesian1D(1).getZero().getNorm(), 1.0e-15);
}
@Test
public void testEquals() {
- Coordinates1D u1 = new Coordinates1D(1);
- Coordinates1D u2 = new Coordinates1D(1);
+ Cartesian1D u1 = new Cartesian1D(1);
+ Cartesian1D u2 = new Cartesian1D(1);
Assert.assertTrue(u1.equals(u1));
Assert.assertTrue(u1.equals(u2));
- Assert.assertFalse(u1.equals(new Coordinates1D(1 + 10 * Precision.EPSILON)));
- Assert.assertTrue(new Coordinates1D(Double.NaN).equals(new Coordinates1D(Double.NaN)));
+ Assert.assertFalse(u1.equals(new Cartesian1D(1 + 10 * Precision.EPSILON)));
+ Assert.assertTrue(new Cartesian1D(Double.NaN).equals(new Cartesian1D(Double.NaN)));
}
@Test
public void testHash() {
- Assert.assertEquals(new Coordinates1D(Double.NaN).hashCode(), new Coordinates1D(Double.NaN).hashCode());
- Coordinates1D u = new Coordinates1D(1);
- Coordinates1D v = new Coordinates1D(1 + 10 * Precision.EPSILON);
+ Assert.assertEquals(new Cartesian1D(Double.NaN).hashCode(), new Cartesian1D(Double.NaN).hashCode());
+ Cartesian1D u = new Cartesian1D(1);
+ Cartesian1D v = new Cartesian1D(1 + 10 * Precision.EPSILON);
Assert.assertTrue(u.hashCode() != v.hashCode());
}
@Test
public void testInfinite() {
- Assert.assertTrue(new Coordinates1D(Double.NEGATIVE_INFINITY).isInfinite());
- Assert.assertTrue(new Coordinates1D(Double.POSITIVE_INFINITY).isInfinite());
- Assert.assertFalse(new Coordinates1D(1).isInfinite());
- Assert.assertFalse(new Coordinates1D(Double.NaN).isInfinite());
+ Assert.assertTrue(new Cartesian1D(Double.NEGATIVE_INFINITY).isInfinite());
+ Assert.assertTrue(new Cartesian1D(Double.POSITIVE_INFINITY).isInfinite());
+ Assert.assertFalse(new Cartesian1D(1).isInfinite());
+ Assert.assertFalse(new Cartesian1D(Double.NaN).isInfinite());
}
@Test
public void testNaN() {
- Assert.assertTrue(new Coordinates1D(Double.NaN).isNaN());
- Assert.assertFalse(new Coordinates1D(1).isNaN());
- Assert.assertFalse(new Coordinates1D(Double.NEGATIVE_INFINITY).isNaN());
+ Assert.assertTrue(new Cartesian1D(Double.NaN).isNaN());
+ Assert.assertFalse(new Cartesian1D(1).isNaN());
+ Assert.assertFalse(new Cartesian1D(Double.NEGATIVE_INFINITY).isNaN());
}
@Test
public void testToString() {
- Assert.assertEquals("{3}", new Coordinates1D(3).toString());
+ Assert.assertEquals("{3}", new Cartesian1D(3).toString());
NumberFormat format = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
- Assert.assertEquals("{3.000}", new Coordinates1D(3).toString(format));
+ Assert.assertEquals("{3.000}", new Cartesian1D(3).toString(format));
}
@Test
public void testCoordinates() {
- Coordinates1D v = new Coordinates1D(1);
+ Cartesian1D v = new Cartesian1D(1);
Assert.assertTrue(FastMath.abs(v.getX() - 1) < 1.0e-12);
}
@Test
public void testNorm1() {
- Assert.assertEquals(0.0, Coordinates1D.ZERO.getNorm1(), 0);
- Assert.assertEquals(6.0, new Coordinates1D(6).getNorm1(), 0);
+ Assert.assertEquals(0.0, Cartesian1D.ZERO.getNorm1(), 0);
+ Assert.assertEquals(6.0, new Cartesian1D(6).getNorm1(), 0);
}
@Test
public void testNorm() {
- Assert.assertEquals(0.0, Coordinates1D.ZERO.getNorm(), 0);
- Assert.assertEquals(3.0, new Coordinates1D(-3).getNorm(), 1.0e-12);
+ Assert.assertEquals(0.0, Cartesian1D.ZERO.getNorm(), 0);
+ Assert.assertEquals(3.0, new Cartesian1D(-3).getNorm(), 1.0e-12);
}
@Test
public void testNormSq() {
- Assert.assertEquals(0.0, new Coordinates1D(0).getNormSq(), 0);
- Assert.assertEquals(9.0, new Coordinates1D(-3).getNormSq(), 1.0e-12);
+ Assert.assertEquals(0.0, new Cartesian1D(0).getNormSq(), 0);
+ Assert.assertEquals(9.0, new Cartesian1D(-3).getNormSq(), 1.0e-12);
}
@Test
public void testNormInf() {
- Assert.assertEquals(0.0, Coordinates1D.ZERO.getNormInf(), 0);
- Assert.assertEquals(3.0, new Coordinates1D(-3).getNormInf(), 0);
+ Assert.assertEquals(0.0, Cartesian1D.ZERO.getNormInf(), 0);
+ Assert.assertEquals(3.0, new Cartesian1D(-3).getNormInf(), 0);
}
@Test
public void testDistance1() {
- Coordinates1D v1 = new Coordinates1D(1);
- Coordinates1D v2 = new Coordinates1D(-4);
- Assert.assertEquals(0.0, new Coordinates1D(-1).distance1(new Coordinates1D(-1)), 0);
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, new Cartesian1D(-1).distance1(new Cartesian1D(-1)), 0);
Assert.assertEquals(5.0, v1.distance1(v2), 1.0e-12);
Assert.assertEquals(v1.subtract(v2).getNorm1(), v1.distance1(v2), 1.0e-12);
}
@Test
public void testDistance() {
- Coordinates1D v1 = new Coordinates1D(1);
- Coordinates1D v2 = new Coordinates1D(-4);
- Assert.assertEquals(0.0, Coordinates1D.distance(new Coordinates1D(-1), new Coordinates1D(-1)), 0);
- Assert.assertEquals(5.0, Coordinates1D.distance(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNorm(), Coordinates1D.distance(v1, v2), 1.0e-12);
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, Cartesian1D.distance(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
+ Assert.assertEquals(5.0, Cartesian1D.distance(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNorm(), Cartesian1D.distance(v1, v2), 1.0e-12);
}
@Test
public void testDistanceSq() {
- Coordinates1D v1 = new Coordinates1D(1);
- Coordinates1D v2 = new Coordinates1D(-4);
- Assert.assertEquals(0.0, Coordinates1D.distanceSq(new Coordinates1D(-1), new Coordinates1D(-1)), 0);
- Assert.assertEquals(25.0, Coordinates1D.distanceSq(v1, v2), 1.0e-12);
- Assert.assertEquals(Coordinates1D.distance(v1, v2) * Coordinates1D.distance(v1, v2),
- Coordinates1D.distanceSq(v1, v2), 1.0e-12);
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, Cartesian1D.distanceSq(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
+ Assert.assertEquals(25.0, Cartesian1D.distanceSq(v1, v2), 1.0e-12);
+ Assert.assertEquals(Cartesian1D.distance(v1, v2) * Cartesian1D.distance(v1, v2),
+ Cartesian1D.distanceSq(v1, v2), 1.0e-12);
}
@Test
public void testDistanceInf() {
- Coordinates1D v1 = new Coordinates1D(1);
- Coordinates1D v2 = new Coordinates1D(-4);
- Assert.assertEquals(0.0, Coordinates1D.distanceInf(new Coordinates1D(-1), new Coordinates1D(-1)), 0);
- Assert.assertEquals(5.0, Coordinates1D.distanceInf(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNormInf(), Coordinates1D.distanceInf(v1, v2), 1.0e-12);
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, Cartesian1D.distanceInf(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
+ Assert.assertEquals(5.0, Cartesian1D.distanceInf(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNormInf(), Cartesian1D.distanceInf(v1, v2), 1.0e-12);
}
@Test
public void testSubtract() {
- Coordinates1D v1 = new Coordinates1D(1);
- Coordinates1D v2 = new Coordinates1D(-3);
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-3);
v1 = v1.subtract(v2);
checkVector(v1, 4);
@@ -180,8 +179,8 @@ public class Vector1DTest {
@Test
public void testAdd() {
- Coordinates1D v1 = new Coordinates1D(1);
- Coordinates1D v2 = new Coordinates1D(-3);
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-3);
v1 = v1.add(v2);
checkVector(v1, -2);
@@ -191,7 +190,7 @@ public class Vector1DTest {
@Test
public void testScalarProduct() {
- Coordinates1D v = new Coordinates1D(1);
+ Cartesian1D v = new Cartesian1D(1);
v = v.scalarMultiply(3);
checkVector(v, 3);
@@ -200,9 +199,9 @@ public class Vector1DTest {
@Test
public void testNormalize() throws MathArithmeticException {
- Assert.assertEquals(1.0, new Coordinates1D(5).normalize().getNorm(), 1.0e-12);
+ Assert.assertEquals(1.0, new Cartesian1D(5).normalize().getNorm(), 1.0e-12);
try {
- Coordinates1D.ZERO.normalize();
+ Cartesian1D.ZERO.normalize();
Assert.fail("an exception should have been thrown");
} catch (MathArithmeticException ae) {
// expected behavior
@@ -211,10 +210,10 @@ public class Vector1DTest {
@Test
public void testNegate() {
- checkVector(new Coordinates1D(0.1).negate(), -0.1);
+ checkVector(new Cartesian1D(0.1).negate(), -0.1);
}
- private void checkVector(Coordinates1D v, double x) {
+ private void checkVector(Cartesian1D v, double x) {
Assert.assertEquals(x, v.getX(), 1.0e-12);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
index 65f45a3..b54e2e0 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.FieldVector3D;
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.linear.MatrixUtils;
import org.apache.commons.math4.linear.RealMatrix;
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
@@ -975,7 +975,7 @@ public class FieldRotationDSTest {
FieldVector3D<DerivativeStructure> uds = createVector(x, y, z);
FieldVector3D<DerivativeStructure> ruds = r.applyTo(uds);
FieldVector3D<DerivativeStructure> rIuds = r.applyInverseTo(uds);
- Coordinates3D u = new Coordinates3D(x, y, z);
+ Cartesian3D u = new Cartesian3D(x, y, z);
FieldVector3D<DerivativeStructure> ru = r.applyTo(u);
FieldVector3D<DerivativeStructure> rIu = r.applyInverseTo(u);
DerivativeStructure[] ruArray = new DerivativeStructure[3];
@@ -1000,7 +1000,7 @@ public class FieldRotationDSTest {
UnitSphereRandomVectorGenerator g = new UnitSphereRandomVectorGenerator(3, random);
for (int i = 0; i < 10; ++i) {
double[] unit1 = g.nextVector();
- Rotation r1 = new Rotation(new Coordinates3D(unit1[0], unit1[1], unit1[2]),
+ Rotation r1 = new Rotation(new Cartesian3D(unit1[0], unit1[1], unit1[2]),
random.nextDouble(), RotationConvention.VECTOR_OPERATOR);
FieldRotation<DerivativeStructure> r1Prime = new FieldRotation<>(new DerivativeStructure(4, 1, 0, r1.getQ0()),
new DerivativeStructure(4, 1, 1, r1.getQ1()),
@@ -1051,7 +1051,7 @@ public class FieldRotationDSTest {
FieldRotation<DerivativeStructure> r = new FieldRotation<>(createAxis(kx, ky, kz),
createAngle(theta),
RotationConvention.VECTOR_OPERATOR);
- Coordinates3D a = new Coordinates3D(kx / n, ky / n, kz / n);
+ Cartesian3D a = new Cartesian3D(kx / n, ky / n, kz / n);
// Jacobian of the normalized rotation axis a with respect to the Cartesian vector k
RealMatrix dadk = MatrixUtils.createRealMatrix(new double[][] {
@@ -1063,15 +1063,15 @@ public class FieldRotationDSTest {
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);
FieldVector3D<DerivativeStructure> v = r.applyTo(createVector(x, y, z));
// explicit formula for rotation of vector u around axis a with angle theta
- double dot = Coordinates3D.dotProduct(u, a);
- Coordinates3D cross = Coordinates3D.crossProduct(a, u);
+ double dot = Cartesian3D.dotProduct(u, a);
+ Cartesian3D cross = Cartesian3D.crossProduct(a, u);
double c1 = 1 - cosTheta;
double c2 = c1 * dot;
- Coordinates3D rt = new Coordinates3D(cosTheta, u, c2, a, sinTheta, cross);
+ Cartesian3D rt = new Cartesian3D(cosTheta, u, c2, a, sinTheta, cross);
Assert.assertEquals(rt.getX(), v.getX().getReal(), eps);
Assert.assertEquals(rt.getY(), v.getY().getReal(), eps);
Assert.assertEquals(rt.getZ(), v.getZ().getReal(), eps);
@@ -1100,8 +1100,8 @@ public class FieldRotationDSTest {
// derivative with respect to rotation angle
// (analytical differentiation of the explicit formula)
- Coordinates3D dvdTheta =
- new Coordinates3D(-sinTheta, u, sinTheta * dot, a, cosTheta, cross);
+ Cartesian3D dvdTheta =
+ new Cartesian3D(-sinTheta, u, sinTheta * dot, a, cosTheta, cross);
Assert.assertEquals(dvdTheta.getX(), v.getX().getPartialDerivative(0, 0, 0, 1), eps);
Assert.assertEquals(dvdTheta.getY(), v.getY().getPartialDerivative(0, 0, 0, 1), eps);
Assert.assertEquals(dvdTheta.getZ(), v.getZ().getPartialDerivative(0, 0, 0, 1), eps);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
index 4e250c0..f4f3403 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.FieldVector3D;
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.random.UnitSphereRandomVectorGenerator;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
@@ -816,7 +816,7 @@ public class FieldRotationDfpTest {
FieldVector3D<Dfp> uds = createVector(x, y, z);
FieldVector3D<Dfp> ruds = r.applyTo(uds);
FieldVector3D<Dfp> rIuds = r.applyInverseTo(uds);
- Coordinates3D u = new Coordinates3D(x, y, z);
+ Cartesian3D u = new Cartesian3D(x, y, z);
FieldVector3D<Dfp> ru = r.applyTo(u);
FieldVector3D<Dfp> rIu = r.applyInverseTo(u);
Dfp[] ruArray = new Dfp[3];
@@ -842,7 +842,7 @@ public class FieldRotationDfpTest {
UnitSphereRandomVectorGenerator g = new UnitSphereRandomVectorGenerator(3, random);
for (int i = 0; i < 10; ++i) {
double[] unit1 = g.nextVector();
- Rotation r1 = new Rotation(new Coordinates3D(unit1[0], unit1[1], unit1[2]),
+ Rotation r1 = new Rotation(new Cartesian3D(unit1[0], unit1[1], unit1[2]),
random.nextDouble(), RotationConvention.VECTOR_OPERATOR);
FieldRotation<Dfp> r1Prime = new FieldRotation<>(field.newDfp(r1.getQ0()),
field.newDfp(r1.getQ1()),
[05/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
Posted by ra...@apache.org.
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
[15/19] [math] MATH-1284: Replace uses of "Vector1D" in comments and
supporting files with "Cartesian1D".
Posted by ra...@apache.org.
MATH-1284: Replace uses of "Vector1D" in comments and supporting files with "Cartesian1D".
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/a27ca511
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/a27ca511
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/a27ca511
Branch: refs/heads/feature-MATH-1284
Commit: a27ca511a591caf813c26862a888e90e54af19a9
Parents: e508ad0
Author: Ray DeCampo <ra...@decampo.org>
Authored: Thu May 4 07:30:27 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Thu May 4 07:30:27 2017 -0400
----------------------------------------------------------------------
.../geometry/euclidean/oned/Cartesian1D.java | 6 +-
.../math4/geometry/partitioning/Embedding.java | 2 +-
src/site/xdoc/userguide/geometry.xml | 4 +-
.../euclidean/oned/Cartesian1DTest.java | 219 +++++++++++++++++++
.../geometry/euclidean/oned/Vector1DTest.java | 219 -------------------
5 files changed, 225 insertions(+), 225 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a27ca511/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
index 0a248a1..f406125 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
@@ -126,7 +126,7 @@ public class Cartesian1D implements Point<Euclidean1D>, Vector<Euclidean1D> {
/** Get the abscissa of the vector.
* @return abscissa of the vector
- * @see #Vector1D(double)
+ * @see #Cartesian1D(double)
*/
public double getX() {
return x;
@@ -332,8 +332,8 @@ public class Cartesian1D implements Point<Euclidean1D>, Vector<Euclidean1D> {
*
* @param other Object to test for equality to this
* @return true if two 1D vector objects are equal, false if
- * object is null, not an instance of Vector1D, or
- * not equal to this Vector1D instance
+ * object is null, not an instance of Cartesian1D, or
+ * not equal to this Cartesian1D instance
*
*/
@Override
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a27ca511/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
index ae48f11..9e78d90 100644
--- a/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
+++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.geometry.Space;
* org.apache.commons.math4.geometry.euclidean.threed.Line Line} in 3D
* implements Embedding<{@link
* org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D Cartesian3D}, {link
- * org.apache.commons.math4.geometry.euclidean.oned.Vector1D Vector1D}, i.e. it
+ * org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D Cartesian1D}, i.e. it
* maps directly dimensions 3 and 1.</p>
* <p>In the 3D euclidean space, hyperplanes are 2D planes, and the 1D
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a27ca511/src/site/xdoc/userguide/geometry.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/userguide/geometry.xml b/src/site/xdoc/userguide/geometry.xml
index 6c76e3b..4242c96 100644
--- a/src/site/xdoc/userguide/geometry.xml
+++ b/src/site/xdoc/userguide/geometry.xml
@@ -76,8 +76,8 @@
<subsection name="11.2 Euclidean spaces" href="euclidean">
<p>
- <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.html">
- Vector1D</a>, <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.html">
+ <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.html">
+ Cartesian1D</a>, <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.html">
Cartesian2D</a> and <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.html">
Cartesian3D</a> provide simple vector types. One important feature is
that instances of these classes are guaranteed
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a27ca511/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1DTest.java
new file mode 100644
index 0000000..2b60c3d
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1DTest.java
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math4.geometry.euclidean.oned;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.util.Locale;
+
+import org.apache.commons.math4.exception.DimensionMismatchException;
+import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.geometry.Space;
+import org.apache.commons.math4.util.FastMath;
+import org.apache.commons.math4.util.Precision;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Cartesian1DTest {
+ @Test
+ public void testConstructors() throws DimensionMismatchException {
+ checkVector(new Cartesian1D(3, new Cartesian1D(FastMath.PI / 3)),
+ FastMath.PI);
+ checkVector(new Cartesian1D(2, Cartesian1D.ONE, -3, new Cartesian1D(2)),
+ -4);
+ checkVector(new Cartesian1D(2, Cartesian1D.ONE,
+ 5, new Cartesian1D(2),
+ -3, new Cartesian1D(3)),
+ 3);
+ checkVector(new Cartesian1D(2, Cartesian1D.ONE,
+ 5, new Cartesian1D(2),
+ 5, new Cartesian1D(-2),
+ -3, new Cartesian1D(-3)),
+ 11);
+ }
+
+ @Test
+ public void testSpace() {
+ Space space = new Cartesian1D(1).getSpace();
+ Assert.assertEquals(1, space.getDimension());
+ }
+
+ @Test
+ public void testZero() {
+ Assert.assertEquals(0, new Cartesian1D(1).getZero().getNorm(), 1.0e-15);
+ }
+
+ @Test
+ public void testEquals() {
+ Cartesian1D u1 = new Cartesian1D(1);
+ Cartesian1D u2 = new Cartesian1D(1);
+ Assert.assertTrue(u1.equals(u1));
+ Assert.assertTrue(u1.equals(u2));
+ Assert.assertFalse(u1.equals(new Cartesian1D(1 + 10 * Precision.EPSILON)));
+ Assert.assertTrue(new Cartesian1D(Double.NaN).equals(new Cartesian1D(Double.NaN)));
+ }
+
+ @Test
+ public void testHash() {
+ Assert.assertEquals(new Cartesian1D(Double.NaN).hashCode(), new Cartesian1D(Double.NaN).hashCode());
+ Cartesian1D u = new Cartesian1D(1);
+ Cartesian1D v = new Cartesian1D(1 + 10 * Precision.EPSILON);
+ Assert.assertTrue(u.hashCode() != v.hashCode());
+ }
+
+ @Test
+ public void testInfinite() {
+ Assert.assertTrue(new Cartesian1D(Double.NEGATIVE_INFINITY).isInfinite());
+ Assert.assertTrue(new Cartesian1D(Double.POSITIVE_INFINITY).isInfinite());
+ Assert.assertFalse(new Cartesian1D(1).isInfinite());
+ Assert.assertFalse(new Cartesian1D(Double.NaN).isInfinite());
+ }
+
+ @Test
+ public void testNaN() {
+ Assert.assertTrue(new Cartesian1D(Double.NaN).isNaN());
+ Assert.assertFalse(new Cartesian1D(1).isNaN());
+ Assert.assertFalse(new Cartesian1D(Double.NEGATIVE_INFINITY).isNaN());
+ }
+
+ @Test
+ public void testToString() {
+ Assert.assertEquals("{3}", new Cartesian1D(3).toString());
+ NumberFormat format = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
+ Assert.assertEquals("{3.000}", new Cartesian1D(3).toString(format));
+ }
+
+ @Test
+ public void testCoordinates() {
+ Cartesian1D v = new Cartesian1D(1);
+ Assert.assertTrue(FastMath.abs(v.getX() - 1) < 1.0e-12);
+ }
+
+ @Test
+ public void testNorm1() {
+ Assert.assertEquals(0.0, Cartesian1D.ZERO.getNorm1(), 0);
+ Assert.assertEquals(6.0, new Cartesian1D(6).getNorm1(), 0);
+ }
+
+ @Test
+ public void testNorm() {
+ Assert.assertEquals(0.0, Cartesian1D.ZERO.getNorm(), 0);
+ Assert.assertEquals(3.0, new Cartesian1D(-3).getNorm(), 1.0e-12);
+ }
+
+ @Test
+ public void testNormSq() {
+ Assert.assertEquals(0.0, new Cartesian1D(0).getNormSq(), 0);
+ Assert.assertEquals(9.0, new Cartesian1D(-3).getNormSq(), 1.0e-12);
+ }
+
+ @Test
+ public void testNormInf() {
+ Assert.assertEquals(0.0, Cartesian1D.ZERO.getNormInf(), 0);
+ Assert.assertEquals(3.0, new Cartesian1D(-3).getNormInf(), 0);
+ }
+
+ @Test
+ public void testDistance1() {
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, new Cartesian1D(-1).distance1(new Cartesian1D(-1)), 0);
+ Assert.assertEquals(5.0, v1.distance1(v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNorm1(), v1.distance1(v2), 1.0e-12);
+ }
+
+ @Test
+ public void testDistance() {
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, Cartesian1D.distance(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
+ Assert.assertEquals(5.0, Cartesian1D.distance(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNorm(), Cartesian1D.distance(v1, v2), 1.0e-12);
+ }
+
+ @Test
+ public void testDistanceSq() {
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, Cartesian1D.distanceSq(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
+ Assert.assertEquals(25.0, Cartesian1D.distanceSq(v1, v2), 1.0e-12);
+ Assert.assertEquals(Cartesian1D.distance(v1, v2) * Cartesian1D.distance(v1, v2),
+ Cartesian1D.distanceSq(v1, v2), 1.0e-12);
+ }
+
+ @Test
+ public void testDistanceInf() {
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-4);
+ Assert.assertEquals(0.0, Cartesian1D.distanceInf(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
+ Assert.assertEquals(5.0, Cartesian1D.distanceInf(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNormInf(), Cartesian1D.distanceInf(v1, v2), 1.0e-12);
+ }
+
+ @Test
+ public void testSubtract() {
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-3);
+ v1 = v1.subtract(v2);
+ checkVector(v1, 4);
+
+ checkVector(v2.subtract(v1), -7);
+ checkVector(v2.subtract(3, v1), -15);
+ }
+
+ @Test
+ public void testAdd() {
+ Cartesian1D v1 = new Cartesian1D(1);
+ Cartesian1D v2 = new Cartesian1D(-3);
+ v1 = v1.add(v2);
+ checkVector(v1, -2);
+
+ checkVector(v2.add(v1), -5);
+ checkVector(v2.add(3, v1), -9);
+ }
+
+ @Test
+ public void testScalarProduct() {
+ Cartesian1D v = new Cartesian1D(1);
+ v = v.scalarMultiply(3);
+ checkVector(v, 3);
+
+ checkVector(v.scalarMultiply(0.5), 1.5);
+ }
+
+ @Test
+ public void testNormalize() throws MathArithmeticException {
+ Assert.assertEquals(1.0, new Cartesian1D(5).normalize().getNorm(), 1.0e-12);
+ try {
+ Cartesian1D.ZERO.normalize();
+ Assert.fail("an exception should have been thrown");
+ } catch (MathArithmeticException ae) {
+ // expected behavior
+ }
+ }
+
+ @Test
+ public void testNegate() {
+ checkVector(new Cartesian1D(0.1).negate(), -0.1);
+ }
+
+ private void checkVector(Cartesian1D v, double x) {
+ Assert.assertEquals(x, v.getX(), 1.0e-12);
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a27ca511/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
deleted file mode 100644
index c1db959..0000000
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.geometry.euclidean.oned;
-
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
-import java.util.Locale;
-
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.MathArithmeticException;
-import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.Precision;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class Vector1DTest {
- @Test
- public void testConstructors() throws DimensionMismatchException {
- checkVector(new Cartesian1D(3, new Cartesian1D(FastMath.PI / 3)),
- FastMath.PI);
- checkVector(new Cartesian1D(2, Cartesian1D.ONE, -3, new Cartesian1D(2)),
- -4);
- checkVector(new Cartesian1D(2, Cartesian1D.ONE,
- 5, new Cartesian1D(2),
- -3, new Cartesian1D(3)),
- 3);
- checkVector(new Cartesian1D(2, Cartesian1D.ONE,
- 5, new Cartesian1D(2),
- 5, new Cartesian1D(-2),
- -3, new Cartesian1D(-3)),
- 11);
- }
-
- @Test
- public void testSpace() {
- Space space = new Cartesian1D(1).getSpace();
- Assert.assertEquals(1, space.getDimension());
- }
-
- @Test
- public void testZero() {
- Assert.assertEquals(0, new Cartesian1D(1).getZero().getNorm(), 1.0e-15);
- }
-
- @Test
- public void testEquals() {
- Cartesian1D u1 = new Cartesian1D(1);
- Cartesian1D u2 = new Cartesian1D(1);
- Assert.assertTrue(u1.equals(u1));
- Assert.assertTrue(u1.equals(u2));
- Assert.assertFalse(u1.equals(new Cartesian1D(1 + 10 * Precision.EPSILON)));
- Assert.assertTrue(new Cartesian1D(Double.NaN).equals(new Cartesian1D(Double.NaN)));
- }
-
- @Test
- public void testHash() {
- Assert.assertEquals(new Cartesian1D(Double.NaN).hashCode(), new Cartesian1D(Double.NaN).hashCode());
- Cartesian1D u = new Cartesian1D(1);
- Cartesian1D v = new Cartesian1D(1 + 10 * Precision.EPSILON);
- Assert.assertTrue(u.hashCode() != v.hashCode());
- }
-
- @Test
- public void testInfinite() {
- Assert.assertTrue(new Cartesian1D(Double.NEGATIVE_INFINITY).isInfinite());
- Assert.assertTrue(new Cartesian1D(Double.POSITIVE_INFINITY).isInfinite());
- Assert.assertFalse(new Cartesian1D(1).isInfinite());
- Assert.assertFalse(new Cartesian1D(Double.NaN).isInfinite());
- }
-
- @Test
- public void testNaN() {
- Assert.assertTrue(new Cartesian1D(Double.NaN).isNaN());
- Assert.assertFalse(new Cartesian1D(1).isNaN());
- Assert.assertFalse(new Cartesian1D(Double.NEGATIVE_INFINITY).isNaN());
- }
-
- @Test
- public void testToString() {
- Assert.assertEquals("{3}", new Cartesian1D(3).toString());
- NumberFormat format = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
- Assert.assertEquals("{3.000}", new Cartesian1D(3).toString(format));
- }
-
- @Test
- public void testCoordinates() {
- Cartesian1D v = new Cartesian1D(1);
- Assert.assertTrue(FastMath.abs(v.getX() - 1) < 1.0e-12);
- }
-
- @Test
- public void testNorm1() {
- Assert.assertEquals(0.0, Cartesian1D.ZERO.getNorm1(), 0);
- Assert.assertEquals(6.0, new Cartesian1D(6).getNorm1(), 0);
- }
-
- @Test
- public void testNorm() {
- Assert.assertEquals(0.0, Cartesian1D.ZERO.getNorm(), 0);
- Assert.assertEquals(3.0, new Cartesian1D(-3).getNorm(), 1.0e-12);
- }
-
- @Test
- public void testNormSq() {
- Assert.assertEquals(0.0, new Cartesian1D(0).getNormSq(), 0);
- Assert.assertEquals(9.0, new Cartesian1D(-3).getNormSq(), 1.0e-12);
- }
-
- @Test
- public void testNormInf() {
- Assert.assertEquals(0.0, Cartesian1D.ZERO.getNormInf(), 0);
- Assert.assertEquals(3.0, new Cartesian1D(-3).getNormInf(), 0);
- }
-
- @Test
- public void testDistance1() {
- Cartesian1D v1 = new Cartesian1D(1);
- Cartesian1D v2 = new Cartesian1D(-4);
- Assert.assertEquals(0.0, new Cartesian1D(-1).distance1(new Cartesian1D(-1)), 0);
- Assert.assertEquals(5.0, v1.distance1(v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNorm1(), v1.distance1(v2), 1.0e-12);
- }
-
- @Test
- public void testDistance() {
- Cartesian1D v1 = new Cartesian1D(1);
- Cartesian1D v2 = new Cartesian1D(-4);
- Assert.assertEquals(0.0, Cartesian1D.distance(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
- Assert.assertEquals(5.0, Cartesian1D.distance(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNorm(), Cartesian1D.distance(v1, v2), 1.0e-12);
- }
-
- @Test
- public void testDistanceSq() {
- Cartesian1D v1 = new Cartesian1D(1);
- Cartesian1D v2 = new Cartesian1D(-4);
- Assert.assertEquals(0.0, Cartesian1D.distanceSq(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
- Assert.assertEquals(25.0, Cartesian1D.distanceSq(v1, v2), 1.0e-12);
- Assert.assertEquals(Cartesian1D.distance(v1, v2) * Cartesian1D.distance(v1, v2),
- Cartesian1D.distanceSq(v1, v2), 1.0e-12);
- }
-
- @Test
- public void testDistanceInf() {
- Cartesian1D v1 = new Cartesian1D(1);
- Cartesian1D v2 = new Cartesian1D(-4);
- Assert.assertEquals(0.0, Cartesian1D.distanceInf(new Cartesian1D(-1), new Cartesian1D(-1)), 0);
- Assert.assertEquals(5.0, Cartesian1D.distanceInf(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNormInf(), Cartesian1D.distanceInf(v1, v2), 1.0e-12);
- }
-
- @Test
- public void testSubtract() {
- Cartesian1D v1 = new Cartesian1D(1);
- Cartesian1D v2 = new Cartesian1D(-3);
- v1 = v1.subtract(v2);
- checkVector(v1, 4);
-
- checkVector(v2.subtract(v1), -7);
- checkVector(v2.subtract(3, v1), -15);
- }
-
- @Test
- public void testAdd() {
- Cartesian1D v1 = new Cartesian1D(1);
- Cartesian1D v2 = new Cartesian1D(-3);
- v1 = v1.add(v2);
- checkVector(v1, -2);
-
- checkVector(v2.add(v1), -5);
- checkVector(v2.add(3, v1), -9);
- }
-
- @Test
- public void testScalarProduct() {
- Cartesian1D v = new Cartesian1D(1);
- v = v.scalarMultiply(3);
- checkVector(v, 3);
-
- checkVector(v.scalarMultiply(0.5), 1.5);
- }
-
- @Test
- public void testNormalize() throws MathArithmeticException {
- Assert.assertEquals(1.0, new Cartesian1D(5).normalize().getNorm(), 1.0e-12);
- try {
- Cartesian1D.ZERO.normalize();
- Assert.fail("an exception should have been thrown");
- } catch (MathArithmeticException ae) {
- // expected behavior
- }
- }
-
- @Test
- public void testNegate() {
- checkVector(new Cartesian1D(0.1).negate(), -0.1);
- }
-
- private void checkVector(Cartesian1D v, double x) {
- Assert.assertEquals(x, v.getX(), 1.0e-12);
- }
-}
[12/19] [math] MATH-1284: Replace uses of "Vector3D" in comments and
supporting files with "Cartesian3D".
Posted by ra...@apache.org.
MATH-1284: Replace uses of "Vector3D" in comments and supporting files with "Cartesian3D".
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/a3984815
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/a3984815
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/a3984815
Branch: refs/heads/feature-MATH-1284
Commit: a3984815ebf24df07c2add09fbf0069f54666a20
Parents: e21d4d4
Author: Ray DeCampo <ra...@decampo.org>
Authored: Sun Apr 30 08:26:36 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Sun Apr 30 08:26:36 2017 -0400
----------------------------------------------------------------------
findbugs-exclude-filter.xml | 6 +-
.../geometry/euclidean/threed/Cartesian3D.java | 24 ++--
.../euclidean/threed/FieldRotation.java | 48 ++++----
.../euclidean/threed/FieldVector3D.java | 14 +--
.../geometry/euclidean/threed/Rotation.java | 110 +++++++++----------
.../euclidean/threed/RotationConvention.java | 16 +--
.../math4/geometry/partitioning/Embedding.java | 2 +-
.../math4/geometry/spherical/twod/Circle.java | 4 +-
.../spherical/twod/SphericalPolygonsSet.java | 2 +-
src/site/design/threeD.puml | 4 +-
src/site/xdoc/userguide/geometry.xml | 12 +-
11 files changed, 121 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index 86d0087..7a90945 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -81,9 +81,9 @@
<!-- The following equality test is intentional and needed for semantic purposes -->
<Match>
<Or>
- <Class name="org.apache.commons.math4.geometry.euclidean.oned.Vector1D" />
- <Class name="org.apache.commons.math4.geometry.euclidean.twod.Vector2D" />
- <Class name="org.apache.commons.math4.geometry.euclidean.threed.Vector3D" />
+ <Class name="org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D" />
+ <Class name="org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D" />
+ <Class name="org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D" />
</Or>
<Method name="equals" params="java.lang.Object" returns="boolean" />
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
index 85696f6..5dc04c5 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
@@ -196,7 +196,7 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
/** Get the abscissa of the vector.
* @return abscissa of the vector
- * @see #Vector3D(double, double, double)
+ * @see #Cartesian3D(double, double, double)
*/
public double getX() {
return x;
@@ -204,7 +204,7 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
/** Get the ordinate of the vector.
* @return ordinate of the vector
- * @see #Vector3D(double, double, double)
+ * @see #Cartesian3D(double, double, double)
*/
public double getY() {
return y;
@@ -212,7 +212,7 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
/** Get the height of the vector.
* @return height of the vector
- * @see #Vector3D(double, double, double)
+ * @see #Cartesian3D(double, double, double)
*/
public double getZ() {
return z;
@@ -220,7 +220,7 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
/** Get the vector coordinates as a dimension 3 array.
* @return vector coordinates
- * @see #Vector3D(double[])
+ * @see #Cartesian3D(double[])
*/
public double[] toArray() {
return new double[] { x, y, z };
@@ -266,7 +266,7 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
/** Get the azimuth of the vector.
* @return azimuth (α) of the vector, between -π and +π
- * @see #Vector3D(double, double)
+ * @see #Cartesian3D(double, double)
*/
public double getAlpha() {
return FastMath.atan2(y, x);
@@ -274,7 +274,7 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
/** Get the elevation of the vector.
* @return elevation (δ) of the vector, between -π/2 and +π/2
- * @see #Vector3D(double, double)
+ * @see #Cartesian3D(double, double)
*/
public double getDelta() {
return FastMath.asin(z / getNorm());
@@ -324,9 +324,9 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
* following example shows how to build a frame having the k axis
* aligned with the known vector u :
* <pre><code>
- * Vector3D k = u.normalize();
- * Vector3D i = k.orthogonal();
- * Vector3D j = Vector3D.crossProduct(k, i);
+ * Cartesian3D k = u.normalize();
+ * Cartesian3D i = k.orthogonal();
+ * Cartesian3D j = Cartesian3D.crossProduct(k, i);
* </code></pre></p>
* @return a new normalized vector orthogonal to the instance
* @exception MathArithmeticException if the norm of the instance is null
@@ -423,8 +423,8 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
*
* @param other Object to test for equality to this
* @return true if two 3D vector objects are equal, false if
- * object is null, not an instance of Vector3D, or
- * not equal to this Vector3D instance
+ * object is null, not an instance of Cartesian3D, or
+ * not equal to this Cartesian3D instance
*
*/
@Override
@@ -476,7 +476,7 @@ public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euc
/** Compute the cross-product of the instance with another vector.
* @param v other vector
- * @return the cross product this ^ v as a new Vector3D
+ * @return the cross product this ^ v as a new Cartesian3D
*/
public Cartesian3D crossProduct(final Vector<Euclidean3D> v) {
final Cartesian3D v3 = (Cartesian3D) v;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
index 6392e3f..d3853c0 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
@@ -815,9 +815,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else {
if (order == RotationOrder.XYZ) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (theta) cos (psi), -cos (theta) sin (psi), sin (theta)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// sin (theta), -sin (phi) cos (theta), cos (phi) cos (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
@@ -831,9 +831,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.XZY) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (psi) cos (theta), -sin (psi), cos (psi) sin (theta)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// -sin (psi), cos (phi) cos (psi), sin (phi) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
@@ -847,9 +847,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.YXZ) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// cos (phi) sin (psi), cos (phi) cos (psi), -sin (phi)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// sin (theta) cos (phi), -sin (phi), cos (theta) cos (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
@@ -863,9 +863,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.YZX) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// sin (psi), cos (psi) cos (phi), -cos (psi) sin (phi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (theta) cos (psi), sin (psi), -sin (theta) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
@@ -879,9 +879,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.ZXY) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// -cos (phi) sin (theta), sin (phi), cos (phi) cos (theta)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// -sin (psi) cos (phi), cos (psi) cos (phi), sin (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
@@ -895,9 +895,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.ZYX) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// -sin (theta), cos (theta) sin (phi), cos (theta) cos (phi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (psi) cos (theta), sin (psi) cos (theta), -sin (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
@@ -911,9 +911,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.XYX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (theta), sin (phi2) sin (theta), cos (phi2) sin (theta)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (theta), sin (theta) sin (phi1), -sin (theta) cos (phi1)
// and we can choose to have theta in the interval [0 ; PI]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
@@ -927,9 +927,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.XZX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (psi), -cos (phi2) sin (psi), sin (phi2) sin (psi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (psi), sin (psi) cos (phi1), sin (psi) sin (phi1)
// and we can choose to have psi in the interval [0 ; PI]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
@@ -943,9 +943,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.YXY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// sin (phi) sin (theta2), cos (phi), -sin (phi) cos (theta2)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// sin (theta1) sin (phi), cos (phi), cos (theta1) sin (phi)
// and we can choose to have phi in the interval [0 ; PI]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
@@ -959,9 +959,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.YZY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// sin (psi) cos (theta2), cos (psi), sin (psi) sin (theta2)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// -cos (theta1) sin (psi), cos (psi), sin (theta1) sin (psi)
// and we can choose to have psi in the interval [0 ; PI]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
@@ -975,9 +975,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else if (order == RotationOrder.ZXZ) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// sin (phi) sin (psi2), sin (phi) cos (psi2), cos (phi)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// sin (psi1) sin (phi), -cos (psi1) sin (phi), cos (phi)
// and we can choose to have phi in the interval [0 ; PI]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
@@ -991,9 +991,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
} else { // last possibility is ZYZ
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// -sin (theta) cos (psi2), sin (theta) sin (psi2), cos (theta)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// cos (psi1) sin (theta), sin (psi1) sin (theta), cos (theta)
// and we can choose to have theta in the interval [0 ; PI]
FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
index ac31622..6f93fdd 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
@@ -535,9 +535,9 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* following example shows how to build a frame having the k axis
* aligned with the known vector u :
* <pre><code>
- * Vector3D k = u.normalize();
- * Vector3D i = k.orthogonal();
- * Vector3D j = Vector3D.crossProduct(k, i);
+ * Cartesian3D k = u.normalize();
+ * Cartesian3D i = k.orthogonal();
+ * Cartesian3D j = Cartesian3D.crossProduct(k, i);
* </code></pre></p>
* @return a new normalized vector orthogonal to the instance
* @exception MathArithmeticException if the norm of the instance is null
@@ -707,8 +707,8 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
*
* @param other Object to test for equality to this
* @return true if two 3D vector objects are equal, false if
- * object is null, not an instance of Vector3D, or
- * not equal to this Vector3D instance
+ * object is null, not an instance of FieldVector3D, or
+ * not equal to this FieldVector3D instance
*
*/
@Override
@@ -776,7 +776,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
/** Compute the cross-product of the instance with another vector.
* @param v other vector
- * @return the cross product this ^ v as a new Vector3D
+ * @return the cross product this ^ v as a new FieldVector3D
*/
public FieldVector3D<T> crossProduct(final FieldVector3D<T> v) {
return new FieldVector3D<>(x.linearCombination(y, v.z, z.negate(), v.y),
@@ -786,7 +786,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
/** Compute the cross-product of the instance with another vector.
* @param v other vector
- * @return the cross product this ^ v as a new Vector3D
+ * @return the cross product this ^ v as a new FieldVector3D
*/
public FieldVector3D<T> crossProduct(final Cartesian3D v) {
return new FieldVector3D<>(x.linearCombination(v.getZ(), y, -v.getY(), z),
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
index 63e7017..a14eb6f 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Rotation.java
@@ -72,8 +72,8 @@ import org.apache.commons.math4.util.MathArrays;
* class does not push the user towards one specific definition and hence does not
* provide methods like <code>projectVectorIntoDestinationFrame</code> or
* <code>computeTransformedDirection</code>. It provides simpler and more generic
- * methods: {@link #applyTo(Vector3D) applyTo(Vector3D)} and {@link
- * #applyInverseTo(Vector3D) applyInverseTo(Vector3D)}.</p>
+ * methods: {@link #applyTo(Cartesian3D) applyTo(Cartesian3D)} and {@link
+ * #applyInverseTo(Cartesian3D) applyInverseTo(Cartesian3D)}.</p>
*
* <p>Since a rotation is basically a vectorial operator, several rotations can be
* composed together and the composite operation <code>r = r<sub>1</sub> o
@@ -153,13 +153,13 @@ public class Rotation implements Serializable {
/** Build a rotation from an axis and an angle.
* <p>
* Calling this constructor is equivalent to call
- * {@link #Rotation(Vector3D, double, RotationConvention)
+ * {@link #Rotation(Cartesian3D, double, RotationConvention)
* new Rotation(axis, angle, RotationConvention.VECTOR_OPERATOR)}
* </p>
* @param axis axis around which to rotate
* @param angle rotation angle.
* @exception MathIllegalArgumentException if the axis norm is zero
- * @deprecated as of 3.6, replaced with {@link #Rotation(Vector3D, double, RotationConvention)}
+ * @deprecated as of 3.6, replaced with {@link #Rotation(Cartesian3D, double, RotationConvention)}
*/
@Deprecated
public Rotation(Cartesian3D axis, double angle) throws MathIllegalArgumentException {
@@ -518,7 +518,7 @@ public class Rotation implements Serializable {
* {@link #getAxis(RotationConvention) getAxis(RotationConvention.VECTOR_OPERATOR)}
* </p>
* @return normalized axis of the rotation
- * @see #Rotation(Vector3D, double, RotationConvention)
+ * @see #Rotation(Cartesian3D, double, RotationConvention)
* @deprecated as of 3.6, replaced with {@link #getAxis(RotationConvention)}
*/
@Deprecated
@@ -534,7 +534,7 @@ public class Rotation implements Serializable {
* </p>
* @param convention convention to use for the semantics of the angle
* @return normalized axis of the rotation
- * @see #Rotation(Vector3D, double, RotationConvention)
+ * @see #Rotation(Cartesian3D, double, RotationConvention)
* @since 3.6
*/
public Cartesian3D getAxis(final RotationConvention convention) {
@@ -554,7 +554,7 @@ public class Rotation implements Serializable {
/** Get the angle of the rotation.
* @return angle of the rotation (between 0 and π)
- * @see #Rotation(Vector3D, double)
+ * @see #Rotation(Cartesian3D, double)
*/
public double getAngle() {
if ((q0 < -0.1) || (q0 > 0.1)) {
@@ -628,9 +628,9 @@ public class Rotation implements Serializable {
if (convention == RotationConvention.VECTOR_OPERATOR) {
if (order == RotationOrder.XYZ) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// sin (theta), -cos (theta) sin (phi), cos (theta) cos (phi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (psi) cos (theta), -sin (psi) cos (theta), sin (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
@@ -646,9 +646,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.XZY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// -sin (psi), cos (psi) cos (phi), cos (psi) sin (phi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (theta) cos (psi), -sin (psi), sin (theta) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -664,9 +664,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YXZ) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// cos (phi) sin (theta), -sin (phi), cos (phi) cos (theta)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// sin (psi) cos (phi), cos (psi) cos (phi), -sin (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
@@ -682,9 +682,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YZX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (psi) cos (theta), sin (psi), -cos (psi) sin (theta)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// sin (psi), cos (phi) cos (psi), -sin (phi) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -700,9 +700,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.ZXY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// -cos (phi) sin (psi), cos (phi) cos (psi), sin (phi)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// -sin (theta) cos (phi), sin (phi), cos (theta) cos (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -718,9 +718,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.ZYX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (theta) cos (psi), cos (theta) sin (psi), -sin (theta)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// -sin (theta), sin (phi) cos (theta), cos (phi) cos (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -736,9 +736,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.XYX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (theta), sin (phi1) sin (theta), -cos (phi1) sin (theta)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (theta), sin (theta) sin (phi2), sin (theta) cos (phi2)
// and we can choose to have theta in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -754,9 +754,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.XZX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (psi), cos (phi1) sin (psi), sin (phi1) sin (psi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (psi), -sin (psi) cos (phi2), sin (psi) sin (phi2)
// and we can choose to have psi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -772,9 +772,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YXY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// sin (theta1) sin (phi), cos (phi), cos (theta1) sin (phi)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// sin (phi) sin (theta2), cos (phi), -sin (phi) cos (theta2)
// and we can choose to have phi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -790,9 +790,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YZY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// -cos (theta1) sin (psi), cos (psi), sin (theta1) sin (psi)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// sin (psi) cos (theta2), cos (psi), sin (psi) sin (theta2)
// and we can choose to have psi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -808,9 +808,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.ZXZ) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// sin (psi1) sin (phi), -cos (psi1) sin (phi), cos (phi)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// sin (phi) sin (psi2), sin (phi) cos (psi2), cos (phi)
// and we can choose to have phi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
@@ -826,9 +826,9 @@ public class Rotation implements Serializable {
} else { // last possibility is ZYZ
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// cos (psi1) sin (theta), sin (psi1) sin (theta), cos (theta)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// -sin (theta) cos (psi2), sin (theta) sin (psi2), cos (theta)
// and we can choose to have theta in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
@@ -846,9 +846,9 @@ public class Rotation implements Serializable {
} else {
if (order == RotationOrder.XYZ) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (theta) cos (psi), -cos (theta) sin (psi), sin (theta)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// sin (theta), -sin (phi) cos (theta), cos (phi) cos (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -864,9 +864,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.XZY) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (psi) cos (theta), -sin (psi), cos (psi) sin (theta)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// -sin (psi), cos (phi) cos (psi), sin (phi) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -882,9 +882,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YXZ) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// cos (phi) sin (psi), cos (phi) cos (psi), -sin (phi)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// sin (theta) cos (phi), -sin (phi), cos (theta) cos (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -900,9 +900,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YZX) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// sin (psi), cos (psi) cos (phi), -cos (psi) sin (phi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (theta) cos (psi), sin (psi), -sin (theta) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -918,9 +918,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.ZXY) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// -cos (phi) sin (theta), sin (phi), cos (phi) cos (theta)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// -sin (psi) cos (phi), cos (psi) cos (phi), sin (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
@@ -936,9 +936,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.ZYX) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// -sin (theta), cos (theta) sin (phi), cos (theta) cos (phi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (psi) cos (theta), sin (psi) cos (theta), -sin (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
@@ -954,9 +954,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.XYX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (theta), sin (phi2) sin (theta), cos (phi2) sin (theta)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (theta), sin (theta) sin (phi1), -sin (theta) cos (phi1)
// and we can choose to have theta in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -972,9 +972,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.XZX) {
- // r (Vector3D.plusI) coordinates are :
+ // r (Cartesian3D.plusI) coordinates are :
// cos (psi), -cos (phi2) sin (psi), sin (phi2) sin (psi)
- // (-r) (Vector3D.plusI) coordinates are :
+ // (-r) (Cartesian3D.plusI) coordinates are :
// cos (psi), sin (psi) cos (phi1), sin (psi) sin (phi1)
// and we can choose to have psi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_I);
@@ -990,9 +990,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YXY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// sin (phi) sin (theta2), cos (phi), -sin (phi) cos (theta2)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// sin (theta1) sin (phi), cos (phi), cos (theta1) sin (phi)
// and we can choose to have phi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -1008,9 +1008,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.YZY) {
- // r (Vector3D.plusJ) coordinates are :
+ // r (Cartesian3D.plusJ) coordinates are :
// sin (psi) cos (theta2), cos (psi), sin (psi) sin (theta2)
- // (-r) (Vector3D.plusJ) coordinates are :
+ // (-r) (Cartesian3D.plusJ) coordinates are :
// -cos (theta1) sin (psi), cos (psi), sin (theta1) sin (psi)
// and we can choose to have psi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_J);
@@ -1026,9 +1026,9 @@ public class Rotation implements Serializable {
} else if (order == RotationOrder.ZXZ) {
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// sin (phi) sin (psi2), sin (phi) cos (psi2), cos (phi)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// sin (psi1) sin (phi), -cos (psi1) sin (phi), cos (phi)
// and we can choose to have phi in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
@@ -1044,9 +1044,9 @@ public class Rotation implements Serializable {
} else { // last possibility is ZYZ
- // r (Vector3D.plusK) coordinates are :
+ // r (Cartesian3D.plusK) coordinates are :
// -sin (theta) cos (psi2), sin (theta) sin (psi2), cos (theta)
- // (-r) (Vector3D.plusK) coordinates are :
+ // (-r) (Cartesian3D.plusK) coordinates are :
// cos (psi1) sin (theta), sin (psi1) sin (theta), cos (theta)
// and we can choose to have theta in the interval [0 ; PI]
Cartesian3D v1 = applyTo(Cartesian3D.PLUS_K);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationConvention.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationConvention.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationConvention.java
index d9871c5..0c4eb80 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationConvention.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/RotationConvention.java
@@ -31,10 +31,10 @@ public enum RotationConvention {
* </p>
* <p>
* This means that if we define rotation r is a 90 degrees rotation around
- * the Z axis, the image of vector {@link Vector3D#PLUS_I} would be
- * {@link Vector3D#PLUS_J}, the image of vector {@link Vector3D#PLUS_J}
- * would be {@link Vector3D#MINUS_I}, the image of vector {@link Vector3D#PLUS_K}
- * would be {@link Vector3D#PLUS_K}, and the image of vector with coordinates (1, 2, 3)
+ * the Z axis, the image of vector {@link Cartesian3D#PLUS_I} would be
+ * {@link Cartesian3D#PLUS_J}, the image of vector {@link Cartesian3D#PLUS_J}
+ * would be {@link Cartesian3D#MINUS_I}, the image of vector {@link Cartesian3D#PLUS_K}
+ * would be {@link Cartesian3D#PLUS_K}, and the image of vector with coordinates (1, 2, 3)
* would be vector (-2, 1, 3). This means that the vector rotates counterclockwise.
* </p>
* <p>
@@ -58,10 +58,10 @@ public enum RotationConvention {
* </p>
* <p>
* This means that if we define rotation r is a 90 degrees rotation around
- * the Z axis, the image of vector {@link Vector3D#PLUS_I} would be
- * {@link Vector3D#MINUS_J}, the image of vector {@link Vector3D#PLUS_J}
- * would be {@link Vector3D#PLUS_I}, the image of vector {@link Vector3D#PLUS_K}
- * would be {@link Vector3D#PLUS_K}, and the image of vector with coordinates (1, 2, 3)
+ * the Z axis, the image of vector {@link Cartesian3D#PLUS_I} would be
+ * {@link Cartesian3D#MINUS_J}, the image of vector {@link Cartesian3D#PLUS_J}
+ * would be {@link Cartesian3D#PLUS_I}, the image of vector {@link Cartesian3D#PLUS_K}
+ * would be {@link Cartesian3D#PLUS_K}, and the image of vector with coordinates (1, 2, 3)
* would be vector (2, -1, 3). This means that the coordinates of the vector rotates
* clockwise, because they are expressed with respect to a destination frame that is rotated
* counterclockwise.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
index d5f58ba..ae48f11 100644
--- a/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
+++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/Embedding.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.geometry.Space;
* of the dimensions differences. As an example, {@link
* org.apache.commons.math4.geometry.euclidean.threed.Line Line} in 3D
* implements Embedding<{@link
- * org.apache.commons.math4.geometry.euclidean.threed.Vector3D Vector3D}, {link
+ * org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D Cartesian3D}, {link
* org.apache.commons.math4.geometry.euclidean.oned.Vector1D Vector1D}, i.e. it
* maps directly dimensions 3 and 1.</p>
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
index ab8c2c5..3805967 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
@@ -147,7 +147,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
}
/** {@inheritDoc}
- * @see #getPhase(Vector3D)
+ * @see #getPhase(Cartesian3D)
*/
@Override
public S1Point toSubSpace(final Point<Sphere2D> point) {
@@ -256,7 +256,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
}
/** {@inheritDoc}
- * @see #getOffset(Vector3D)
+ * @see #getOffset(Cartesian3D)
*/
@Override
public double getOffset(final Point<Sphere2D> point) {
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
index 0f5d115..83c6936 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
@@ -435,7 +435,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
* EnclosingBall<Sphere2D, S2Point> cap = complexShape.getEnclosingCap();
*
* // check lots of points
- * for (Vector3D p : points) {
+ * for (Cartesian3D p : points) {
*
* final Location l;
* if (cap.contains(p)) {
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/site/design/threeD.puml
----------------------------------------------------------------------
diff --git a/src/site/design/threeD.puml b/src/site/design/threeD.puml
index 43175f6..de13ded 100644
--- a/src/site/design/threeD.puml
+++ b/src/site/design/threeD.puml
@@ -64,7 +64,7 @@
package threed #DDDBD8 {
class Euclidean3D
- class Vector3D
+ class Cartesian3D
class Line
class SubLine
class Plane
@@ -72,7 +72,7 @@
class PolyhedronsSet
Space <|.. Euclidean3D
- Vector_S_ <|.. Vector3D
+ Vector_S_ <|.. Cartesian3D
Hyperplane_S_ <|.. Plane
SubHyperplane_S_ <|.. SubPlane
Region_S_ <|.. PolyhedronsSet
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a3984815/src/site/xdoc/userguide/geometry.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/userguide/geometry.xml b/src/site/xdoc/userguide/geometry.xml
index fc6c635..ab9c551 100644
--- a/src/site/xdoc/userguide/geometry.xml
+++ b/src/site/xdoc/userguide/geometry.xml
@@ -78,8 +78,8 @@
<p>
<a href="../apidocs/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.html">
Vector1D</a>, <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.html">
- Vector2D</a> and <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/threed/Vector3D.html">
- Vector3D</a> provide simple vector types. One important feature is
+ Vector2D</a> and <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.html">
+ Cartesian3D</a> provide simple vector types. One important feature is
that instances of these classes are guaranteed
to be immutable, this greatly simplifies modeling dynamical systems
with changing states: once a vector has been computed, a reference to it
@@ -109,7 +109,7 @@
<p>
<a href="../apidocs/org/apache/commons/math4/geometry/euclidean/threed/Rotation.html">
Rotation</a> represents 3D rotations.
- Rotation instances are also immutable objects, as Vector3D instances.
+ Rotation instances are also immutable objects, as Cartesian3D instances.
</p>
<p>
Rotations can be represented by several different mathematical
@@ -174,8 +174,8 @@
definition and hence does not provide methods like
<code>projectVectorIntoDestinationFrame</code> or
<code>computeTransformedDirection</code>. It provides simpler and more
- generic methods: <code>applyTo(Vector3D)</code> and
- <code>applyInverseTo(Vector3D)</code>.
+ generic methods: <code>applyTo(Cartesian3D)</code> and
+ <code>applyInverseTo(Cartesian3D)</code>.
</p>
<p>
Since a rotation is basically a vectorial operator, several
@@ -303,7 +303,7 @@ PolygonsSet empty = new PolygonsSet(new BSPTree<Euclidean2D>(false), toler
constructor is:
</p>
<source>
-PolyhedronsSet(List<Vector3D> vertices, List<int[]> facets, double tolerance);
+PolyhedronsSet(List<Cartesian3D> vertices, List<int[]> facets, double tolerance);
</source>
<p>
The vertices list contains all the vertices of the polyhedrons, the facets list defines the facets,
[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
Posted by ra...@apache.org.
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]));
}
[14/19] [math] MATH-1284: Replace uses of Vector3D in user guide with
Cartesian2D.
Posted by ra...@apache.org.
MATH-1284: Replace uses of Vector3D in user guide with Cartesian2D.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/e508ad09
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/e508ad09
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/e508ad09
Branch: refs/heads/feature-MATH-1284
Commit: e508ad09d79302d3cc6b86077d4a6ddb0679a0f5
Parents: c7d2047
Author: Ray DeCampo <ra...@decampo.org>
Authored: Thu May 4 07:27:37 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Thu May 4 07:27:37 2017 -0400
----------------------------------------------------------------------
.../math4/userguide/sofm/ChineseRings.java | 20 ++++++++++----------
.../userguide/sofm/ChineseRingsClassifier.java | 10 +++++-----
2 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e508ad09/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
index 57393a6..a497da6 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
@@ -20,7 +20,7 @@ package org.apache.commons.math4.userguide.sofm;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
import org.apache.commons.math4.distribution.RealDistribution;
@@ -32,7 +32,7 @@ import org.apache.commons.math4.distribution.UniformRealDistribution;
*/
public class ChineseRings {
/** Points in the two rings. */
- private final Vector3D[] points;
+ private final Cartesian3D[] points;
/**
* @param orientationRing1 Vector othogonal to the plane containing the
@@ -44,7 +44,7 @@ public class ChineseRings {
* @param numPointsRing1 Number of points in the first ring.
* @param numPointsRing2 Number of points in the second ring.
*/
- public ChineseRings(Vector3D orientationRing1,
+ public ChineseRings(Cartesian3D orientationRing1,
double radiusRing1,
double halfWidthRing1,
double radiusRing2,
@@ -52,9 +52,9 @@ public class ChineseRings {
int numPointsRing1,
int numPointsRing2) {
// First ring (centered at the origin).
- final Vector3D[] firstRing = new Vector3D[numPointsRing1];
+ final Cartesian3D[] firstRing = new Cartesian3D[numPointsRing1];
// Second ring (centered around the first ring).
- final Vector3D[] secondRing = new Vector3D[numPointsRing2];
+ final Cartesian3D[] secondRing = new Cartesian3D[numPointsRing2];
// Create two rings lying in xy-plane.
final UnitSphereRandomVectorGenerator unit
@@ -72,7 +72,7 @@ public class ChineseRings {
final double[] v = unit.nextVector();
final double r = radius1.sample();
// First ring is in the xy-plane, centered at (0, 0, 0).
- firstRing[i] = new Vector3D(v[0] * r,
+ firstRing[i] = new Cartesian3D(v[0] * r,
v[1] * r,
widthRing1.sample());
}
@@ -87,16 +87,16 @@ public class ChineseRings {
final double[] v = unit.nextVector();
final double r = radius2.sample();
// Second ring is in the xz-plane, centered at (radiusRing1, 0, 0).
- secondRing[i] = new Vector3D(radiusRing1 + v[0] * r,
+ secondRing[i] = new Cartesian3D(radiusRing1 + v[0] * r,
widthRing2.sample(),
v[1] * r);
}
// Move first and second rings into position.
- final Rotation rot = new Rotation(Vector3D.PLUS_K,
+ final Rotation rot = new Rotation(Cartesian3D.PLUS_K,
orientationRing1.normalize());
int count = 0;
- points = new Vector3D[numPointsRing1 + numPointsRing2];
+ points = new Cartesian3D[numPointsRing1 + numPointsRing2];
for (int i = 0; i < numPointsRing1; i++) {
points[count++] = rot.applyTo(firstRing[i]);
}
@@ -108,7 +108,7 @@ public class ChineseRings {
/**
* Gets all the points.
*/
- public Vector3D[] getPoints() {
+ public Cartesian3D[] getPoints() {
return points.clone();
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e508ad09/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
index f6a420b..598aa1c 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
@@ -38,7 +38,7 @@ import org.apache.commons.math4.ml.neuralnet.sofm.KohonenTrainingTask;
import org.apache.commons.math4.ml.distance.DistanceMeasure;
import org.apache.commons.math4.ml.distance.EuclideanDistance;
import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
-import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.exception.MathUnsupportedOperationException;
@@ -61,7 +61,7 @@ public class ChineseRingsClassifier {
private final DistanceMeasure distance = new EuclideanDistance();
public static void main(String[] args) {
- final ChineseRings rings = new ChineseRings(new Vector3D(1, 2, 3),
+ final ChineseRings rings = new ChineseRings(new Cartesian3D(1, 2, 3),
25, 2,
20, 1,
2000, 1500);
@@ -185,7 +185,7 @@ public class ChineseRingsClassifier {
new SummaryStatistics(),
new SummaryStatistics()
};
- for (Vector3D p : rings.getPoints()) {
+ for (Cartesian3D p : rings.getPoints()) {
centre[0].addValue(p.getX());
centre[1].addValue(p.getY());
centre[2].addValue(p.getZ());
@@ -220,7 +220,7 @@ public class ChineseRingsClassifier {
public Iterator<double[]> iterator() {
return new Iterator<double[]>() {
/** Data. */
- final Vector3D[] points = rings.getPoints();
+ final Cartesian3D[] points = rings.getPoints();
/** Number of samples. */
private int n = 0;
@@ -253,7 +253,7 @@ public class ChineseRingsClassifier {
private Iterator<double[]> createRandomIterator(final long numSamples) {
return new Iterator<double[]>() {
/** Data. */
- final Vector3D[] points = rings.getPoints();
+ final Cartesian3D[] points = rings.getPoints();
/** RNG. */
final UniformRandomProvider rng = RandomSource.create(RandomSource.KISS);
/** Number of samples. */
[13/19] [math] MATH-1284: Replace uses of "Vector2D" in comments and
supporting files with "Cartesian2D".
Posted by ra...@apache.org.
MATH-1284: Replace uses of "Vector2D" in comments and supporting files with "Cartesian2D".
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/c7d20472
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/c7d20472
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/c7d20472
Branch: refs/heads/feature-MATH-1284
Commit: c7d20472de0dad34bce9483557f43c524e4f3e16
Parents: a398481
Author: Ray DeCampo <ra...@decampo.org>
Authored: Thu May 4 07:25:15 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Thu May 4 07:25:15 2017 -0400
----------------------------------------------------------------------
.../geometry/euclidean/twod/Cartesian2D.java | 6 +-
.../math4/geometry/euclidean/twod/Line.java | 4 +-
.../geometry/euclidean/twod/NestedLoops.java | 2 +-
src/site/design/twoD.puml | 4 +-
src/site/xdoc/userguide/geometry.xml | 4 +-
src/site/xdoc/userguide/leastsquares.xml | 20 +-
.../euclidean/twod/Cartesian2DTest.java | 235 +++++++++++++++++++
.../geometry/euclidean/twod/Vector2DTest.java | 235 -------------------
.../userguide/ClusterAlgorithmComparison.java | 40 ++--
.../LowDiscrepancyGeneratorComparison.java | 43 ++--
.../userguide/geometry/GeometryExample.java | 36 +--
11 files changed, 314 insertions(+), 315 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
index 0272322..51109d0 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
@@ -149,7 +149,7 @@ public class Cartesian2D implements Point<Euclidean2D>, Vector<Euclidean2D> {
/** Get the abscissa of the vector.
* @return abscissa of the vector
- * @see #Vector2D(double, double)
+ * @see #Cartesian2D(double, double)
*/
public double getX() {
return x;
@@ -157,7 +157,7 @@ public class Cartesian2D implements Point<Euclidean2D>, Vector<Euclidean2D> {
/** Get the ordinate of the vector.
* @return ordinate of the vector
- * @see #Vector2D(double, double)
+ * @see #Cartesian2D(double, double)
*/
public double getY() {
return y;
@@ -165,7 +165,7 @@ public class Cartesian2D implements Point<Euclidean2D>, Vector<Euclidean2D> {
/** Get the vector coordinates as a dimension 2 array.
* @return vector coordinates
- * @see #Vector2D(double[])
+ * @see #Cartesian2D(double[])
*/
public double[] toArray() {
return new double[] { x, y };
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
index 36f0998..561cdc7 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
@@ -202,8 +202,8 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* instance.</p>
* <p>
* As long as neither the instance nor its reverse are modified
- * (i.e. as long as none of the {@link #reset(Vector2D, Vector2D)},
- * {@link #reset(Vector2D, double)}, {@link #revertSelf()},
+ * (i.e. as long as none of the {@link #reset(Cartesian2D, Cartesian2D)},
+ * {@link #reset(Cartesian2D, double)}, {@link #revertSelf()},
* {@link #setAngle(double)} or {@link #setOriginOffset(double)}
* methods are called), then the line and its reverse remain linked
* together so that {@code line.getReverse().getReverse() == line}.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
index 3a5038e..dcfc76a 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
@@ -165,7 +165,7 @@ class NestedLoops {
/** Correct the orientation of the loops contained in the tree.
* <p>This is this method that really inverts the loops that where
- * provided through the {@link #add(Vector2D[]) add} method if
+ * provided through the {@link #add(Cartesian2D[]) add} method if
* they are mis-oriented</p>
*/
public void correctOrientation() {
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/site/design/twoD.puml
----------------------------------------------------------------------
diff --git a/src/site/design/twoD.puml b/src/site/design/twoD.puml
index b7f02d7..fb738bb 100644
--- a/src/site/design/twoD.puml
+++ b/src/site/design/twoD.puml
@@ -64,13 +64,13 @@
package twod #DDDBD8 {
class Euclidean2D
- class Vector2D
+ class Cartesian2D
class Line
class SubLine
class PolygonsSet
Space <|.. Euclidean2D
- Vector_S_ <|.. Vector2D
+ Vector_S_ <|.. Cartesian2D
Hyperplane_S_ <|.. Line
SubHyperplane_S_ <|.. SubLine
Region_S_ <|.. PolygonsSet
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/site/xdoc/userguide/geometry.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/userguide/geometry.xml b/src/site/xdoc/userguide/geometry.xml
index ab9c551..6c76e3b 100644
--- a/src/site/xdoc/userguide/geometry.xml
+++ b/src/site/xdoc/userguide/geometry.xml
@@ -77,8 +77,8 @@
<subsection name="11.2 Euclidean spaces" href="euclidean">
<p>
<a href="../apidocs/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.html">
- Vector1D</a>, <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.html">
- Vector2D</a> and <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.html">
+ Vector1D</a>, <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.html">
+ Cartesian2D</a> and <a href="../apidocs/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.html">
Cartesian3D</a> provide simple vector types. One important feature is
that instances of these classes are guaranteed
to be immutable, this greatly simplifies modeling dynamical systems
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/site/xdoc/userguide/leastsquares.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/userguide/leastsquares.xml b/src/site/xdoc/userguide/leastsquares.xml
index 8da9e78..35cd27b 100644
--- a/src/site/xdoc/userguide/leastsquares.xml
+++ b/src/site/xdoc/userguide/leastsquares.xml
@@ -306,12 +306,12 @@
</p>
<source>
final double radius = 70.0;
- final Vector2D[] observedPoints = new Vector2D[] {
- new Vector2D( 30.0, 68.0),
- new Vector2D( 50.0, -6.0),
- new Vector2D(110.0, -20.0),
- new Vector2D( 35.0, 15.0),
- new Vector2D( 45.0, 97.0)
+ final Cartesian2D[] observedPoints = new Cartesian2D[] {
+ new Cartesian2D( 30.0, 68.0),
+ new Cartesian2D( 50.0, -6.0),
+ new Cartesian2D(110.0, -20.0),
+ new Cartesian2D( 35.0, 15.0),
+ new Cartesian2D( 45.0, 97.0)
};
// the model function components are the distances to current estimated center,
@@ -319,14 +319,14 @@
MultivariateJacobianFunction distancesToCurrentCenter = new MultivariateJacobianFunction() {
public Pair<RealVector, RealMatrix> value(final RealVector point) {
- Vector2D center = new Vector2D(point.getEntry(0), point.getEntry(1));
+ Cartesian2D center = new Cartesian2D(point.getEntry(0), point.getEntry(1));
RealVector value = new ArrayRealVector(observedPoints.length);
RealMatrix jacobian = new Array2DRowRealMatrix(observedPoints.length, 2);
for (int i = 0; i < observedPoints.length; ++i) {
- Vector2D o = observedPoints[i];
- double modelI = Vector2D.distance(o, center);
+ Cartesian2D o = observedPoints[i];
+ double modelI = Cartesian2D.distance(o, center);
value.setEntry(i, modelI);
// derivative with respect to p0 = x center
jacobian.setEntry(i, 0, (center.getX() - o.getX()) / modelI);
@@ -353,7 +353,7 @@
maxIterations(1000).
build();
LeastSquaresOptimizer.Optimum optimum = new LevenbergMarquardtOptimizer().optimize(problem);
- Vector2D fittedCenter = new Vector2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
+ Cartesian2D fittedCenter = new Cartesian2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
System.out.println("fitted center: " + fittedCenter.getX() + " " + fittedCenter.getY());
System.out.println("RMS: " + optimum.getRMS());
System.out.println("evaluations: " + optimum.getEvaluations());
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2DTest.java
new file mode 100644
index 0000000..924a4ef
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2DTest.java
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.geometry.euclidean.twod;
+
+import org.apache.commons.math4.exception.DimensionMismatchException;
+import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.util.FastMath;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Cartesian2DTest {
+
+ private static final double EPS = Math.ulp(1d);
+
+ @Test
+ public void testScaledVectorTripleConstructor() {
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D oneTwo = new Cartesian2D(1.0,2.0);
+ Cartesian2D oneThree = new Cartesian2D(1.0,3.0);
+
+ Cartesian2D tripleCombo = new Cartesian2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree);
+
+ Assert.assertEquals(3.0 * 1 + 1.0 * 1 + 2.5 * 1,tripleCombo.getX(), EPS);
+ Assert.assertEquals(3.0 * 1 + 1.0 * 2 + 2.5 * 3,tripleCombo.getY(), EPS);
+ }
+
+ @Test
+ public void testScaledVectorQuadrupleConstructor() {
+ Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
+ Cartesian2D oneTwo = new Cartesian2D(1.0, 2.0);
+ Cartesian2D oneThree = new Cartesian2D(1.0, 3.0);
+ Cartesian2D oneFour = new Cartesian2D(1.0, 4.0);
+
+ Cartesian2D tripleCombo = new Cartesian2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree, 2.0, oneFour);
+
+ Assert.assertEquals(3.0 * 1.0 + 1.0 * 1.0 + 2.5 * 1.0 + 2.0 * 1.0,tripleCombo.getX(), EPS);
+ Assert.assertEquals(3.0 * 1.0 + 1.0 * 2.0 + 2.5 * 3.0 + 2.0 * 4.0,tripleCombo.getY(), EPS);
+ }
+
+ @Test
+ public void testConstructorExceptions() {
+ double[] v = new double[] {0.0, 1.0, 2.0};
+ try {
+ new Cartesian2D(v);
+ }
+ catch (Exception e) {
+ Assert.assertTrue(e instanceof DimensionMismatchException);
+ }
+ }
+
+ @Test
+ public void testToArray() {
+ Cartesian2D oneTwo = new Cartesian2D(1.0, 2.0);
+ double[] array = oneTwo.toArray();
+ Assert.assertEquals(1.0, array[0], EPS);
+ Assert.assertEquals(2.0, array[1], EPS);
+ }
+
+ @Test
+ public void testGetZero() {
+ Cartesian2D zero = (new Cartesian2D(1.0, 1.0)).getZero();
+ Assert.assertEquals(0.0, zero.getX(), EPS);
+ Assert.assertEquals(0.0, zero.getY(), EPS);
+ }
+
+ @Test
+ public void testNorm1() {
+ Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
+ Assert.assertEquals(3.0, oneTwo.getNorm1(), EPS);
+ }
+
+ @Test
+ public void testNormSq() {
+ Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
+ Assert.assertEquals(5.0, oneTwo.getNormSq(), EPS);
+ }
+
+ @Test
+ public void testNormInf() {
+ Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
+ Assert.assertEquals(2.0, oneTwo.getNormInf(), EPS);
+ }
+
+ @Test
+ public void testVectorAddition() {
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.add(threeFive);
+ Assert.assertEquals(2.0, addition.getX(), EPS);
+ Assert.assertEquals(7.0, addition.getY(), EPS);
+ }
+
+ @Test
+ public void testScaledVectorAddition() {
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.add(2.0, threeFive);
+ Assert.assertEquals(5.0, addition.getX(), EPS);
+ Assert.assertEquals(12.0, addition.getY(), EPS);
+ }
+
+ @Test
+ public void testVectorSubtraction() {
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.subtract(threeFive);
+ Assert.assertEquals(-4.0, addition.getX(), EPS);
+ Assert.assertEquals(-3.0, addition.getY(), EPS);
+ }
+
+ @Test
+ public void testScaledVectorSubtraction() {
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.subtract(2.0, threeFive);
+ Assert.assertEquals(-7.0, addition.getX(), EPS);
+ Assert.assertEquals(-8.0, addition.getY(), EPS);
+ }
+
+ @Test
+ public void testNormalize() {
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D normalizedMinusOneTwo = minusOneTwo.normalize();
+ Assert.assertEquals(-1.0/FastMath.sqrt(5), normalizedMinusOneTwo.getX(), EPS);
+ Assert.assertEquals(2.0/FastMath.sqrt(5), normalizedMinusOneTwo.getY(), EPS);
+ Cartesian2D zero = minusOneTwo.getZero();
+ try {
+ zero.normalize();
+ }
+ catch (Exception e) {
+ Assert.assertTrue(e instanceof MathArithmeticException);
+ }
+ }
+
+ @Test
+ public void testAngle() {
+ Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
+ try {
+ Cartesian2D.angle(oneOne.getZero(), oneOne.getZero());
+ }
+ catch (Exception e) {
+ Assert.assertTrue(e instanceof MathArithmeticException);
+ }
+ Cartesian2D oneZero = new Cartesian2D(1.0,0.0);
+ double angle = Cartesian2D.angle(oneOne, oneZero);
+ Assert.assertEquals(FastMath.PI/4, angle, EPS);
+ Assert.assertEquals(0.004999958333958323, Cartesian2D.angle(new Cartesian2D(20.0,0.0), new Cartesian2D(20.0,0.1)), EPS);
+ }
+
+ @Test
+ public void testNegate() {
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D negated = oneOne.negate();
+ Assert.assertEquals(-1.0, negated.getX(), EPS);
+ Assert.assertEquals(-1.0, negated.getY(), EPS);
+ }
+
+ @Test
+ public void testIsInfinite() {
+ Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
+ Cartesian2D infiniteVector = new Cartesian2D(Double.POSITIVE_INFINITY, 0.0);
+ Assert.assertFalse(oneOne.isInfinite());
+ Assert.assertTrue(infiniteVector.isInfinite());
+ }
+
+ @Test
+ public void testDistance1() {
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D fiveEleven = new Cartesian2D(5.0,11.0);
+ double distance1 = oneOne.distance1(fiveEleven);
+ Assert.assertEquals(14.0, distance1, EPS);
+ }
+
+ @Test
+ public void testDistanceInf() {
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D fiveEleven = new Cartesian2D(5.0,11.0);
+ double distanceInf = oneOne.distanceInf(fiveEleven);
+ double staticDistanceInf = Cartesian2D.distanceInf(oneOne, fiveEleven);
+ Assert.assertEquals(10.0, distanceInf, EPS);
+ Assert.assertEquals(distanceInf, staticDistanceInf, EPS);
+ }
+
+ @Test
+ public void testDistanceSq() {
+ Cartesian2D oneFive = new Cartesian2D(1.0, 5.0);
+ Cartesian2D fourOne = new Cartesian2D(4.0, 1.0);
+ double distanceSq = oneFive.distanceSq(fourOne);
+ double staticDistanceSq = Cartesian2D.distanceSq(oneFive, fourOne);
+ Assert.assertEquals(25.0, distanceSq, EPS);
+ Assert.assertEquals(distanceSq, staticDistanceSq, EPS);
+ }
+
+ @Test
+ public void testHashCode() {
+ int hashCode = (new Cartesian2D(1.0,1.0)).hashCode();
+ Assert.assertEquals(887095296, hashCode);
+ Assert.assertEquals(542, (new Cartesian2D(Double.NaN, Double.NaN)).hashCode());
+ }
+
+
+ @Test
+ public void testToString() {
+ Assert.assertEquals("{1; 2}", (new Cartesian2D(1.0,2.0)).toString());
+ }
+
+ @Test
+ public void testCrossProduct() {
+ Cartesian2D p1 = new Cartesian2D(1, 1);
+ Cartesian2D p2 = new Cartesian2D(2, 2);
+
+ Cartesian2D p3 = new Cartesian2D(3, 3);
+ Assert.assertEquals(0.0, p3.crossProduct(p1, p2), EPS);
+
+ Cartesian2D p4 = new Cartesian2D(1, 2);
+ Assert.assertEquals(1.0, p4.crossProduct(p1, p2), EPS);
+
+ Cartesian2D p5 = new Cartesian2D(2, 1);
+ Assert.assertEquals(-1.0, p5.crossProduct(p1, p2), EPS);
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java
deleted file mode 100644
index cb760b2..0000000
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.geometry.euclidean.twod;
-
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.MathArithmeticException;
-import org.apache.commons.math4.util.FastMath;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class Vector2DTest {
-
- private static final double EPS = Math.ulp(1d);
-
- @Test
- public void testScaledVectorTripleConstructor() {
- Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
- Cartesian2D oneTwo = new Cartesian2D(1.0,2.0);
- Cartesian2D oneThree = new Cartesian2D(1.0,3.0);
-
- Cartesian2D tripleCombo = new Cartesian2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree);
-
- Assert.assertEquals(3.0 * 1 + 1.0 * 1 + 2.5 * 1,tripleCombo.getX(), EPS);
- Assert.assertEquals(3.0 * 1 + 1.0 * 2 + 2.5 * 3,tripleCombo.getY(), EPS);
- }
-
- @Test
- public void testScaledVectorQuadrupleConstructor() {
- Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
- Cartesian2D oneTwo = new Cartesian2D(1.0, 2.0);
- Cartesian2D oneThree = new Cartesian2D(1.0, 3.0);
- Cartesian2D oneFour = new Cartesian2D(1.0, 4.0);
-
- Cartesian2D tripleCombo = new Cartesian2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree, 2.0, oneFour);
-
- Assert.assertEquals(3.0 * 1.0 + 1.0 * 1.0 + 2.5 * 1.0 + 2.0 * 1.0,tripleCombo.getX(), EPS);
- Assert.assertEquals(3.0 * 1.0 + 1.0 * 2.0 + 2.5 * 3.0 + 2.0 * 4.0,tripleCombo.getY(), EPS);
- }
-
- @Test
- public void testConstructorExceptions() {
- double[] v = new double[] {0.0, 1.0, 2.0};
- try {
- new Cartesian2D(v);
- }
- catch (Exception e) {
- Assert.assertTrue(e instanceof DimensionMismatchException);
- }
- }
-
- @Test
- public void testToArray() {
- Cartesian2D oneTwo = new Cartesian2D(1.0, 2.0);
- double[] array = oneTwo.toArray();
- Assert.assertEquals(1.0, array[0], EPS);
- Assert.assertEquals(2.0, array[1], EPS);
- }
-
- @Test
- public void testGetZero() {
- Cartesian2D zero = (new Cartesian2D(1.0, 1.0)).getZero();
- Assert.assertEquals(0.0, zero.getX(), EPS);
- Assert.assertEquals(0.0, zero.getY(), EPS);
- }
-
- @Test
- public void testNorm1() {
- Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
- Assert.assertEquals(3.0, oneTwo.getNorm1(), EPS);
- }
-
- @Test
- public void testNormSq() {
- Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
- Assert.assertEquals(5.0, oneTwo.getNormSq(), EPS);
- }
-
- @Test
- public void testNormInf() {
- Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
- Assert.assertEquals(2.0, oneTwo.getNormInf(), EPS);
- }
-
- @Test
- public void testVectorAddition() {
- Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
- Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
- Cartesian2D addition = minusOneTwo.add(threeFive);
- Assert.assertEquals(2.0, addition.getX(), EPS);
- Assert.assertEquals(7.0, addition.getY(), EPS);
- }
-
- @Test
- public void testScaledVectorAddition() {
- Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
- Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
- Cartesian2D addition = minusOneTwo.add(2.0, threeFive);
- Assert.assertEquals(5.0, addition.getX(), EPS);
- Assert.assertEquals(12.0, addition.getY(), EPS);
- }
-
- @Test
- public void testVectorSubtraction() {
- Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
- Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
- Cartesian2D addition = minusOneTwo.subtract(threeFive);
- Assert.assertEquals(-4.0, addition.getX(), EPS);
- Assert.assertEquals(-3.0, addition.getY(), EPS);
- }
-
- @Test
- public void testScaledVectorSubtraction() {
- Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
- Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
- Cartesian2D addition = minusOneTwo.subtract(2.0, threeFive);
- Assert.assertEquals(-7.0, addition.getX(), EPS);
- Assert.assertEquals(-8.0, addition.getY(), EPS);
- }
-
- @Test
- public void testNormalize() {
- Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
- Cartesian2D normalizedMinusOneTwo = minusOneTwo.normalize();
- Assert.assertEquals(-1.0/FastMath.sqrt(5), normalizedMinusOneTwo.getX(), EPS);
- Assert.assertEquals(2.0/FastMath.sqrt(5), normalizedMinusOneTwo.getY(), EPS);
- Cartesian2D zero = minusOneTwo.getZero();
- try {
- zero.normalize();
- }
- catch (Exception e) {
- Assert.assertTrue(e instanceof MathArithmeticException);
- }
- }
-
- @Test
- public void testAngle() {
- Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
- try {
- Cartesian2D.angle(oneOne.getZero(), oneOne.getZero());
- }
- catch (Exception e) {
- Assert.assertTrue(e instanceof MathArithmeticException);
- }
- Cartesian2D oneZero = new Cartesian2D(1.0,0.0);
- double angle = Cartesian2D.angle(oneOne, oneZero);
- Assert.assertEquals(FastMath.PI/4, angle, EPS);
- Assert.assertEquals(0.004999958333958323, Cartesian2D.angle(new Cartesian2D(20.0,0.0), new Cartesian2D(20.0,0.1)), EPS);
- }
-
- @Test
- public void testNegate() {
- Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
- Cartesian2D negated = oneOne.negate();
- Assert.assertEquals(-1.0, negated.getX(), EPS);
- Assert.assertEquals(-1.0, negated.getY(), EPS);
- }
-
- @Test
- public void testIsInfinite() {
- Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
- Cartesian2D infiniteVector = new Cartesian2D(Double.POSITIVE_INFINITY, 0.0);
- Assert.assertFalse(oneOne.isInfinite());
- Assert.assertTrue(infiniteVector.isInfinite());
- }
-
- @Test
- public void testDistance1() {
- Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
- Cartesian2D fiveEleven = new Cartesian2D(5.0,11.0);
- double distance1 = oneOne.distance1(fiveEleven);
- Assert.assertEquals(14.0, distance1, EPS);
- }
-
- @Test
- public void testDistanceInf() {
- Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
- Cartesian2D fiveEleven = new Cartesian2D(5.0,11.0);
- double distanceInf = oneOne.distanceInf(fiveEleven);
- double staticDistanceInf = Cartesian2D.distanceInf(oneOne, fiveEleven);
- Assert.assertEquals(10.0, distanceInf, EPS);
- Assert.assertEquals(distanceInf, staticDistanceInf, EPS);
- }
-
- @Test
- public void testDistanceSq() {
- Cartesian2D oneFive = new Cartesian2D(1.0, 5.0);
- Cartesian2D fourOne = new Cartesian2D(4.0, 1.0);
- double distanceSq = oneFive.distanceSq(fourOne);
- double staticDistanceSq = Cartesian2D.distanceSq(oneFive, fourOne);
- Assert.assertEquals(25.0, distanceSq, EPS);
- Assert.assertEquals(distanceSq, staticDistanceSq, EPS);
- }
-
- @Test
- public void testHashCode() {
- int hashCode = (new Cartesian2D(1.0,1.0)).hashCode();
- Assert.assertEquals(887095296, hashCode);
- Assert.assertEquals(542, (new Cartesian2D(Double.NaN, Double.NaN)).hashCode());
- }
-
-
- @Test
- public void testToString() {
- Assert.assertEquals("{1; 2}", (new Cartesian2D(1.0,2.0)).toString());
- }
-
- @Test
- public void testCrossProduct() {
- Cartesian2D p1 = new Cartesian2D(1, 1);
- Cartesian2D p2 = new Cartesian2D(2, 2);
-
- Cartesian2D p3 = new Cartesian2D(3, 3);
- Assert.assertEquals(0.0, p3.crossProduct(p1, p2), EPS);
-
- Cartesian2D p4 = new Cartesian2D(1, 2);
- Assert.assertEquals(1.0, p4.crossProduct(p1, p2), EPS);
-
- Cartesian2D p5 = new Cartesian2D(2, 1);
- Assert.assertEquals(-1.0, p5.crossProduct(p1, p2), EPS);
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
index 035c2e9..3c5ddd1 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
@@ -40,7 +40,7 @@ import org.apache.commons.rng.sampling.ListSampler;
import org.apache.commons.math4.distribution.RealDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.distribution.NormalDistribution;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.ml.clustering.CentroidCluster;
import org.apache.commons.math4.ml.clustering.Cluster;
import org.apache.commons.math4.ml.clustering.Clusterable;
@@ -61,7 +61,7 @@ import org.apache.commons.math4.userguide.ExampleUtils.ExampleFrame;
*/
public class ClusterAlgorithmComparison {
- public static List<Vector2D> makeCircles(int samples,
+ public static List<Cartesian2D> makeCircles(int samples,
boolean shuffle,
double noise,
double factor,
@@ -72,12 +72,12 @@ public class ClusterAlgorithmComparison {
RealDistribution.Sampler dist = new NormalDistribution(0.0, noise).createSampler(rng);
- List<Vector2D> points = new ArrayList<Vector2D>();
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
double range = 2.0 * FastMath.PI;
double step = range / (samples / 2.0 + 1);
for (double angle = 0; angle < range; angle += step) {
- Vector2D outerCircle = new Vector2D(FastMath.cos(angle), FastMath.sin(angle));
- Vector2D innerCircle = outerCircle.scalarMultiply(factor);
+ Cartesian2D outerCircle = new Cartesian2D(FastMath.cos(angle), FastMath.sin(angle));
+ Cartesian2D innerCircle = outerCircle.scalarMultiply(factor);
points.add(outerCircle.add(generateNoiseVector(dist)));
points.add(innerCircle.add(generateNoiseVector(dist)));
@@ -90,7 +90,7 @@ public class ClusterAlgorithmComparison {
return points;
}
- public static List<Vector2D> makeMoons(int samples,
+ public static List<Cartesian2D> makeMoons(int samples,
boolean shuffle,
double noise,
UniformRandomProvider rng) {
@@ -99,17 +99,17 @@ public class ClusterAlgorithmComparison {
int nSamplesOut = samples / 2;
int nSamplesIn = samples - nSamplesOut;
- List<Vector2D> points = new ArrayList<Vector2D>();
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
double range = FastMath.PI;
double step = range / (nSamplesOut / 2.0);
for (double angle = 0; angle < range; angle += step) {
- Vector2D outerCircle = new Vector2D(FastMath.cos(angle), FastMath.sin(angle));
+ Cartesian2D outerCircle = new Cartesian2D(FastMath.cos(angle), FastMath.sin(angle));
points.add(outerCircle.add(generateNoiseVector(dist)));
}
step = range / (nSamplesIn / 2.0);
for (double angle = 0; angle < range; angle += step) {
- Vector2D innerCircle = new Vector2D(1 - FastMath.cos(angle), 1 - FastMath.sin(angle) - 0.5);
+ Cartesian2D innerCircle = new Cartesian2D(1 - FastMath.cos(angle), 1 - FastMath.sin(angle) - 0.5);
points.add(innerCircle.add(generateNoiseVector(dist)));
}
@@ -120,7 +120,7 @@ public class ClusterAlgorithmComparison {
return points;
}
- public static List<Vector2D> makeBlobs(int samples,
+ public static List<Cartesian2D> makeBlobs(int samples,
int centers,
double clusterStd,
double min,
@@ -130,9 +130,9 @@ public class ClusterAlgorithmComparison {
RealDistribution.Sampler uniform = new UniformRealDistribution(min, max).createSampler(rng);
RealDistribution.Sampler gauss = new NormalDistribution(0.0, clusterStd).createSampler(rng);
- Vector2D[] centerPoints = new Vector2D[centers];
+ Cartesian2D[] centerPoints = new Cartesian2D[centers];
for (int i = 0; i < centers; i++) {
- centerPoints[i] = new Vector2D(uniform.sample(), uniform.sample());
+ centerPoints[i] = new Cartesian2D(uniform.sample(), uniform.sample());
}
int[] nSamplesPerCenter = new int[centers];
@@ -143,7 +143,7 @@ public class ClusterAlgorithmComparison {
nSamplesPerCenter[i]++;
}
- List<Vector2D> points = new ArrayList<Vector2D>();
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
for (int i = 0; i < centers; i++) {
for (int j = 0; j < nSamplesPerCenter[i]; j++) {
points.add(centerPoints[i].add(generateNoiseVector(gauss)));
@@ -157,26 +157,26 @@ public class ClusterAlgorithmComparison {
return points;
}
- public static List<Vector2D> makeRandom(int samples) {
+ public static List<Cartesian2D> makeRandom(int samples) {
SobolSequenceGenerator generator = new SobolSequenceGenerator(2);
generator.skipTo(999999);
- List<Vector2D> points = new ArrayList<Vector2D>();
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
for (double i = 0; i < samples; i++) {
double[] vector = generator.nextVector();
vector[0] = vector[0] * 2 - 1;
vector[1] = vector[1] * 2 - 1;
- Vector2D point = new Vector2D(vector);
+ Cartesian2D point = new Cartesian2D(vector);
points.add(point);
}
return points;
}
- public static Vector2D generateNoiseVector(RealDistribution.Sampler distribution) {
- return new Vector2D(distribution.sample(), distribution.sample());
+ public static Cartesian2D generateNoiseVector(RealDistribution.Sampler distribution) {
+ return new Cartesian2D(distribution.sample(), distribution.sample());
}
- public static List<DoublePoint> normalize(final List<Vector2D> input,
+ public static List<DoublePoint> normalize(final List<Cartesian2D> input,
double minX,
double maxX,
double minY,
@@ -184,7 +184,7 @@ public class ClusterAlgorithmComparison {
double rangeX = maxX - minX;
double rangeY = maxY - minY;
List<DoublePoint> points = new ArrayList<DoublePoint>();
- for (Vector2D p : input) {
+ for (Cartesian2D p : input) {
double[] arr = p.toArray();
arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
arr[1] = (arr[1] - minY) / rangeY * 2 - 1;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java b/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
index e43cba4..12b3be3 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
@@ -35,9 +35,8 @@ import javax.swing.JTextArea;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.random.HaltonSequenceGenerator;
-import org.apache.commons.math4.random.RandomGenerator;
import org.apache.commons.math4.random.RandomVectorGenerator;
import org.apache.commons.math4.random.SobolSequenceGenerator;
import org.apache.commons.math4.random.UncorrelatedRandomVectorGenerator;
@@ -51,11 +50,11 @@ import org.apache.commons.math4.userguide.ExampleUtils.ExampleFrame;
*/
public class LowDiscrepancyGeneratorComparison {
- public static List<Vector2D> makeCircle(int samples, final RandomVectorGenerator generator) {
- List<Vector2D> points = new ArrayList<Vector2D>();
+ public static List<Cartesian2D> makeCircle(int samples, final RandomVectorGenerator generator) {
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
for (double i = 0; i < samples; i++) {
double[] vector = generator.nextVector();
- Vector2D point = new Vector2D(vector);
+ Cartesian2D point = new Cartesian2D(vector);
points.add(point);
}
@@ -63,8 +62,8 @@ public class LowDiscrepancyGeneratorComparison {
points = normalize(points);
// now test if the sample is within the unit circle
- List<Vector2D> circlePoints = new ArrayList<Vector2D>();
- for (Vector2D p : points) {
+ List<Cartesian2D> circlePoints = new ArrayList<Cartesian2D>();
+ for (Cartesian2D p : points) {
double criteria = FastMath.pow(p.getX(), 2) + FastMath.pow(p.getY(), 2);
if (criteria < 1.0) {
circlePoints.add(p);
@@ -74,22 +73,22 @@ public class LowDiscrepancyGeneratorComparison {
return circlePoints;
}
- public static List<Vector2D> makeRandom(int samples, RandomVectorGenerator generator) {
- List<Vector2D> points = new ArrayList<Vector2D>();
+ public static List<Cartesian2D> makeRandom(int samples, RandomVectorGenerator generator) {
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
for (double i = 0; i < samples; i++) {
double[] vector = generator.nextVector();
- Vector2D point = new Vector2D(vector);
+ Cartesian2D point = new Cartesian2D(vector);
points.add(point);
}
return normalize(points);
}
- public static List<Vector2D> normalize(final List<Vector2D> input) {
+ public static List<Cartesian2D> normalize(final List<Cartesian2D> input) {
// find the mininum and maximum x value in the dataset
double minX = Double.MAX_VALUE;
double maxX = Double.MIN_VALUE;
- for (Vector2D p : input) {
+ for (Cartesian2D p : input) {
minX = FastMath.min(minX, p.getX());
maxX = FastMath.max(maxX, p.getX());
}
@@ -107,13 +106,13 @@ public class LowDiscrepancyGeneratorComparison {
double rangeX = maxX - minX;
double rangeY = maxY - minY;
- List<Vector2D> points = new ArrayList<Vector2D>();
- for (Vector2D p : input) {
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
+ for (Cartesian2D p : input) {
double[] arr = p.toArray();
// normalize to the range [-1, 1]
arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
arr[1] = (arr[1] - minY) / rangeY * 2 - 1;
- points.add(new Vector2D(arr));
+ points.add(new Cartesian2D(arr));
}
return points;
}
@@ -178,7 +177,7 @@ public class LowDiscrepancyGeneratorComparison {
c.gridx = 1;
for (Pair<String, RandomVectorGenerator> pair : generators) {
- List<Vector2D> points = null;
+ List<Cartesian2D> points = null;
int samples = datasets[type];
switch (type) {
case 0:
@@ -208,9 +207,9 @@ public class LowDiscrepancyGeneratorComparison {
private static double PAD = 10;
- private List<Vector2D> points;
+ private List<Cartesian2D> points;
- public Plot(final List<Vector2D> points) {
+ public Plot(final List<Cartesian2D> points) {
this.points = points;
}
@@ -229,8 +228,8 @@ public class LowDiscrepancyGeneratorComparison {
g2.setPaint(Color.black);
g2.drawRect(0, 0, w - 1, h - 1);
- for (Vector2D point : points) {
- Vector2D p = transform(point, w, h);
+ for (Cartesian2D point : points) {
+ Cartesian2D p = transform(point, w, h);
double[] arr = p.toArray();
g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
}
@@ -241,9 +240,9 @@ public class LowDiscrepancyGeneratorComparison {
return new Dimension(140, 140);
}
- private Vector2D transform(Vector2D point, int width, int height) {
+ private Cartesian2D transform(Cartesian2D point, int width, int height) {
double[] arr = point.toArray();
- return new Vector2D(new double[] { PAD + (arr[0] + 1) / 2.0 * (width - 2 * PAD),
+ return new Cartesian2D(new double[] { PAD + (arr[0] + 1) / 2.0 * (width - 2 * PAD),
height - PAD - (arr[1] + 1) / 2.0 * (height - 2 * PAD) });
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/c7d20472/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java b/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
index fb82522..4bbe7e6 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
@@ -40,7 +40,7 @@ import org.apache.commons.math4.geometry.enclosing.WelzlEncloser;
import org.apache.commons.math4.geometry.euclidean.twod.DiskGenerator;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
import org.apache.commons.math4.geometry.euclidean.twod.Segment;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHull2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.MonotoneChain;
@@ -65,39 +65,39 @@ import org.piccolo2d.nodes.PText;
*/
public class GeometryExample {
- public static List<Vector2D> createRandomPoints(int size) {
+ public static List<Cartesian2D> createRandomPoints(int size) {
final UniformRandomProvider random = RandomSource.create(RandomSource.MT);
// create the cloud container
- List<Vector2D> points = new ArrayList<Vector2D>(size);
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>(size);
// fill the cloud with a random distribution of points
for (int i = 0; i < size; i++) {
- points.add(new Vector2D(FastMath.round(random.nextDouble() * 400 + 100),
+ points.add(new Cartesian2D(FastMath.round(random.nextDouble() * 400 + 100),
FastMath.round(random.nextDouble() * 400 + 100)));
}
return points;
}
- public static List<Vector2D> createCircle(int samples) {
- List<Vector2D> points = new ArrayList<Vector2D>();
- final Vector2D center = new Vector2D(300, 300);
+ public static List<Cartesian2D> createCircle(int samples) {
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
+ final Cartesian2D center = new Cartesian2D(300, 300);
double range = 2.0 * FastMath.PI;
double step = range / (samples + 1);
for (double angle = 0; angle < range; angle += step) {
- Vector2D circle = new Vector2D(FastMath.cos(angle), FastMath.sin(angle));
+ Cartesian2D circle = new Cartesian2D(FastMath.cos(angle), FastMath.sin(angle));
points.add(circle.scalarMultiply(200).add(center));
}
return points;
}
- public static List<Vector2D> createCross() {
- List<Vector2D> points = new ArrayList<Vector2D>();
+ public static List<Cartesian2D> createCross() {
+ List<Cartesian2D> points = new ArrayList<Cartesian2D>();
for (int i = 100; i < 500; i += 10) {
- points.add(new Vector2D(300, i));
- points.add(new Vector2D(i, 300));
+ points.add(new Cartesian2D(300, i));
+ points.add(new Cartesian2D(i, 300));
}
return points;
@@ -150,7 +150,7 @@ public class GeometryExample {
@SuppressWarnings("serial")
public static class Display extends ExampleFrame {
- private List<Vector2D> points;
+ private List<Cartesian2D> points;
private PCanvas canvas;
private JComponent container;
private JComponent controlPanel;
@@ -223,7 +223,7 @@ public class GeometryExample {
public void paintConvexHull() {
PNode pointSet = new PNode();
- for (Vector2D point : points) {
+ for (Cartesian2D point : points) {
final PNode node = PPath.createEllipse(point.getX() - 1, point.getY() - 1, 2, 2);
node.addAttribute("tooltip", point);
node.setPaint(Color.gray);
@@ -236,7 +236,7 @@ public class GeometryExample {
ConvexHull2D hull = generator.generate(points); //AklToussaintHeuristic.reducePoints(points));
PNode hullNode = new PNode();
- for (Vector2D vertex : hull.getVertices()) {
+ for (Cartesian2D vertex : hull.getVertices()) {
final PPath node = PPath.createEllipse(vertex.getX() - 1, vertex.getY() - 1, 2, 2);
node.addAttribute("tooltip", vertex);
node.setPaint(Color.red);
@@ -255,9 +255,9 @@ public class GeometryExample {
canvas.getLayer().addChild(hullNode);
- Encloser<Euclidean2D, Vector2D> encloser =
- new WelzlEncloser<Euclidean2D, Vector2D>(1e-10, new DiskGenerator());
- EnclosingBall<Euclidean2D, Vector2D> ball = encloser.enclose(points);
+ Encloser<Euclidean2D, Cartesian2D> encloser =
+ new WelzlEncloser<Euclidean2D, Cartesian2D>(1e-10, new DiskGenerator());
+ EnclosingBall<Euclidean2D, Cartesian2D> ball = encloser.enclose(points);
final double radius = ball.getRadius();
PPath ballCenter =
[11/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
Posted by ra...@apache.org.
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<Euclidean?D> and Point<Euclidean?D>, add a disambiguating method accepting a Cartesian?D.
Eliminate casts where possible.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/e21d4d43
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/e21d4d43
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/e21d4d43
Branch: refs/heads/feature-MATH-1284
Commit: e21d4d436b51d88f9554751982cd7b8552854c49
Parents: b815d2a
Author: Ray DeCampo <ra...@decampo.org>
Authored: Sat Apr 29 20:29:29 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Sat Apr 29 20:29:29 2017 -0400
----------------------------------------------------------------------
.../geometry/euclidean/oned/Cartesian1D.java | 386 ++++++
.../geometry/euclidean/oned/Coordinates1D.java | 386 ------
.../geometry/euclidean/oned/IntervalsSet.java | 18 +-
.../geometry/euclidean/oned/OrientedPoint.java | 8 +-
.../geometry/euclidean/oned/Vector1DFormat.java | 12 +-
.../geometry/euclidean/threed/Cartesian3D.java | 621 +++++++++
.../euclidean/threed/Coordinates3D.java | 621 ---------
.../euclidean/threed/FieldRotation.java | 52 +-
.../euclidean/threed/FieldVector3D.java | 78 +-
.../math4/geometry/euclidean/threed/Line.java | 80 +-
.../euclidean/threed/OutlineExtractor.java | 46 +-
.../math4/geometry/euclidean/threed/Plane.java | 131 +-
.../euclidean/threed/PolyhedronsSet.java | 96 +-
.../geometry/euclidean/threed/Rotation.java | 136 +-
.../euclidean/threed/RotationOrder.java | 38 +-
.../geometry/euclidean/threed/Segment.java | 10 +-
.../euclidean/threed/SphereGenerator.java | 22 +-
.../euclidean/threed/SphericalCoordinates.java | 10 +-
.../geometry/euclidean/threed/SubLine.java | 14 +-
.../geometry/euclidean/threed/SubPlane.java | 14 +-
.../euclidean/threed/Vector3DFormat.java | 22 +-
.../geometry/euclidean/twod/Cartesian2D.java | 492 +++++++
.../geometry/euclidean/twod/Coordinates2D.java | 492 -------
.../geometry/euclidean/twod/DiskGenerator.java | 16 +-
.../math4/geometry/euclidean/twod/Line.java | 93 +-
.../geometry/euclidean/twod/NestedLoops.java | 12 +-
.../geometry/euclidean/twod/PolygonsSet.java | 78 +-
.../math4/geometry/euclidean/twod/Segment.java | 14 +-
.../math4/geometry/euclidean/twod/SubLine.java | 18 +-
.../geometry/euclidean/twod/Vector2DFormat.java | 12 +-
.../hull/AbstractConvexHullGenerator2D.java | 10 +-
.../twod/hull/AklToussaintHeuristic.java | 34 +-
.../euclidean/twod/hull/ConvexHull2D.java | 32 +-
.../twod/hull/ConvexHullGenerator2D.java | 6 +-
.../euclidean/twod/hull/MonotoneChain.java | 28 +-
.../math4/geometry/spherical/oned/S1Point.java | 14 +-
.../math4/geometry/spherical/twod/Circle.java | 34 +-
.../math4/geometry/spherical/twod/Edge.java | 4 +-
.../geometry/spherical/twod/EdgesBuilder.java | 10 +-
.../spherical/twod/PropertiesComputer.java | 30 +-
.../math4/geometry/spherical/twod/S2Point.java | 32 +-
.../spherical/twod/SphericalPolygonsSet.java | 26 +-
.../geometry/spherical/twod/SubCircle.java | 4 +-
.../commons/math4/complex/QuaternionTest.java | 30 +-
...stractLeastSquaresOptimizerAbstractTest.java | 6 +-
.../fitting/leastsquares/CircleVectorial.java | 18 +-
.../GaussNewtonOptimizerWithSVDTest.java | 6 +-
.../LevenbergMarquardtOptimizerTest.java | 6 +-
.../RandomCirclePointGenerator.java | 10 +-
.../geometry/enclosing/WelzlEncloser2DTest.java | 56 +-
.../geometry/enclosing/WelzlEncloser3DTest.java | 110 +-
.../euclidean/oned/IntervalsSetTest.java | 44 +-
.../oned/Vector1DFormatAbstractTest.java | 69 +-
.../geometry/euclidean/oned/Vector1DTest.java | 129 +-
.../euclidean/threed/FieldRotationDSTest.java | 20 +-
.../euclidean/threed/FieldRotationDfpTest.java | 6 +-
.../euclidean/threed/FieldVector3DTest.java | 70 +-
.../geometry/euclidean/threed/LineTest.java | 76 +-
.../geometry/euclidean/threed/PLYParser.java | 8 +-
.../geometry/euclidean/threed/PlaneTest.java | 88 +-
.../euclidean/threed/PolyhedronsSetTest.java | 146 +-
.../geometry/euclidean/threed/RotationTest.java | 250 ++--
.../euclidean/threed/SphereGeneratorTest.java | 114 +-
.../threed/SphericalCoordinatesTest.java | 30 +-
.../geometry/euclidean/threed/SubLineTest.java | 60 +-
.../threed/Vector3DFormatAbstractTest.java | 74 +-
.../geometry/euclidean/threed/Vector3DTest.java | 246 ++--
.../euclidean/twod/DiskGeneratorTest.java | 58 +-
.../math4/geometry/euclidean/twod/LineTest.java | 65 +-
.../euclidean/twod/NestedLoopsTest.java | 16 +-
.../euclidean/twod/PolygonsSetTest.java | 1260 +++++++++---------
.../geometry/euclidean/twod/SegmentTest.java | 14 +-
.../geometry/euclidean/twod/SubLineTest.java | 60 +-
.../twod/Vector2DFormatAbstractTest.java | 74 +-
.../geometry/euclidean/twod/Vector2DTest.java | 110 +-
.../twod/hull/AklToussaintHeuristicTest.java | 4 +-
.../hull/ConvexHullGenerator2DAbstractTest.java | 226 ++--
.../euclidean/twod/hull/MonotoneChainTest.java | 22 +-
.../geometry/partitioning/RegionDumper.java | 10 +-
.../geometry/partitioning/RegionParser.java | 16 +-
.../geometry/spherical/twod/CircleTest.java | 80 +-
.../twod/SphericalPolygonsSetTest.java | 152 +--
.../geometry/spherical/twod/SubCircleTest.java | 34 +-
.../MultiStartMultivariateOptimizerTest.java | 4 +-
.../nonlinear/scalar/gradient/CircleScalar.java | 18 +-
...NonLinearConjugateGradientOptimizerTest.java | 4 +-
86 files changed, 4118 insertions(+), 4073 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
new file mode 100644
index 0000000..0a248a1
--- /dev/null
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
@@ -0,0 +1,386 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.geometry.euclidean.oned;
+
+import java.text.NumberFormat;
+
+import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.exception.util.LocalizedFormats;
+import org.apache.commons.math4.geometry.Point;
+import org.apache.commons.math4.geometry.Space;
+import org.apache.commons.math4.geometry.Vector;
+import org.apache.commons.math4.util.FastMath;
+import org.apache.commons.math4.util.MathUtils;
+
+/** This class represents a 1D point or a 1D vector.
+ * <p>An instance of Cartesian1D represents the point with the corresponding
+ * Cartesian coordinates.</p>
+ * <p>An instance of Cartesian1D also represents the vector which begins at
+ * the origin and ends at the point corresponding to the coordinates.</p>
+ * <p>Instances of this class are guaranteed to be immutable.</p>
+ * @since 4.0
+ */
+public class Cartesian1D implements Point<Euclidean1D>, Vector<Euclidean1D> {
+
+ /** Origin (coordinates: 0). */
+ public static final Cartesian1D ZERO = new Cartesian1D(0.0);
+
+ /** Unit (coordinates: 1). */
+ public static final Cartesian1D ONE = new Cartesian1D(1.0);
+
+ // CHECKSTYLE: stop ConstantName
+ /** A vector with all coordinates set to NaN. */
+ public static final Cartesian1D NaN = new Cartesian1D(Double.NaN);
+ // CHECKSTYLE: resume ConstantName
+
+ /** A vector with all coordinates set to positive infinity. */
+ public static final Cartesian1D POSITIVE_INFINITY =
+ new Cartesian1D(Double.POSITIVE_INFINITY);
+
+ /** A vector with all coordinates set to negative infinity. */
+ public static final Cartesian1D NEGATIVE_INFINITY =
+ new Cartesian1D(Double.NEGATIVE_INFINITY);
+
+ /** Serializable UID. */
+ private static final long serialVersionUID = 7556674948671647925L;
+
+ /** Abscissa. */
+ private final double x;
+
+ /** Simple constructor.
+ * Build a vector from its coordinates
+ * @param x abscissa
+ * @see #getX()
+ */
+ public Cartesian1D(double x) {
+ this.x = x;
+ }
+
+ /** Multiplicative constructor
+ * Build a vector from another one and a scale factor.
+ * The vector built will be a * u
+ * @param a scale factor
+ * @param u base (unscaled) vector
+ */
+ public Cartesian1D(double a, Cartesian1D u) {
+ this.x = a * u.x;
+ }
+
+ /** Linear constructor
+ * Build a vector from two other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ */
+ public Cartesian1D(double a1, Cartesian1D u1, double a2, Cartesian1D u2) {
+ this.x = a1 * u1.x + a2 * u2.x;
+ }
+
+ /** Linear constructor
+ * Build a vector from three other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2 + a3 * u3
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ * @param a3 third scale factor
+ * @param u3 third base (unscaled) vector
+ */
+ public Cartesian1D(double a1, Cartesian1D u1, double a2, Cartesian1D u2,
+ double a3, Cartesian1D u3) {
+ this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x;
+ }
+
+ /** Linear constructor
+ * Build a vector from four other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ * @param a3 third scale factor
+ * @param u3 third base (unscaled) vector
+ * @param a4 fourth scale factor
+ * @param u4 fourth base (unscaled) vector
+ */
+ public Cartesian1D(double a1, Cartesian1D u1, double a2, Cartesian1D u2,
+ double a3, Cartesian1D u3, double a4, Cartesian1D u4) {
+ this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x + a4 * u4.x;
+ }
+
+ /** Get the abscissa of the vector.
+ * @return abscissa of the vector
+ * @see #Vector1D(double)
+ */
+ public double getX() {
+ return x;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Space getSpace() {
+ return Euclidean1D.getInstance();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D getZero() {
+ return ZERO;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNorm1() {
+ return FastMath.abs(x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNorm() {
+ return FastMath.abs(x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNormSq() {
+ return x * x;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNormInf() {
+ return FastMath.abs(x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D add(Vector<Euclidean1D> v) {
+ Cartesian1D v1 = (Cartesian1D) v;
+ return new Cartesian1D(x + v1.getX());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D add(double factor, Vector<Euclidean1D> v) {
+ Cartesian1D v1 = (Cartesian1D) v;
+ return new Cartesian1D(x + factor * v1.getX());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D subtract(Vector<Euclidean1D> p) {
+ Cartesian1D p3 = (Cartesian1D) p;
+ return new Cartesian1D(x - p3.x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D subtract(double factor, Vector<Euclidean1D> v) {
+ Cartesian1D v1 = (Cartesian1D) v;
+ return new Cartesian1D(x - factor * v1.getX());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D normalize() throws MathArithmeticException {
+ double s = getNorm();
+ if (s == 0) {
+ throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
+ }
+ return scalarMultiply(1 / s);
+ }
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D negate() {
+ return new Cartesian1D(-x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian1D scalarMultiply(double a) {
+ return new Cartesian1D(a * x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isNaN() {
+ return Double.isNaN(x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isInfinite() {
+ return !isNaN() && Double.isInfinite(x);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance1(Vector<Euclidean1D> p) {
+ Cartesian1D p1 = (Cartesian1D) p;
+ final double dx = FastMath.abs(p1.x - x);
+ return dx;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance(Point<Euclidean1D> p) {
+ return distance((Cartesian1D) p);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance(Vector<Euclidean1D> v) {
+ return distance((Cartesian1D) v);
+ }
+
+ /** Compute the distance between the instance and other coordinates.
+ * @param c other coordinates
+ * @return the distance between the instance and c
+ */
+ public double distance(Cartesian1D c) {
+ final double dx = c.x - x;
+ return FastMath.abs(dx);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distanceInf(Vector<Euclidean1D> p) {
+ Cartesian1D p1 = (Cartesian1D) p;
+ final double dx = FastMath.abs(p1.x - x);
+ return dx;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distanceSq(Vector<Euclidean1D> p) {
+ Cartesian1D p1 = (Cartesian1D) p;
+ final double dx = p1.x - x;
+ return dx * dx;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double dotProduct(final Vector<Euclidean1D> v) {
+ final Cartesian1D v1 = (Cartesian1D) v;
+ return x * v1.x;
+ }
+
+ /** Compute the distance between two points according to the L<sub>2</sub> norm.
+ * <p>Calling this method is equivalent to calling:
+ * <code>p1.subtract(p2).getNorm()</code> except that no intermediate
+ * vector is built</p>
+ * @param p1 first vector
+ * @param p2 second vector
+ * @return the distance between p1 and p2 according to the L<sub>2</sub> norm
+ */
+ public static double distance(Cartesian1D p1, Cartesian1D p2) {
+ return p1.distance(p2);
+ }
+
+ /** Compute the distance between two points according to the L<sub>∞</sub> norm.
+ * <p>Calling this method is equivalent to calling:
+ * <code>p1.subtract(p2).getNormInf()</code> except that no intermediate
+ * vector is built</p>
+ * @param p1 first vector
+ * @param p2 second vector
+ * @return the distance between p1 and p2 according to the L<sub>∞</sub> norm
+ */
+ public static double distanceInf(Cartesian1D p1, Cartesian1D p2) {
+ return p1.distanceInf(p2);
+ }
+
+ /** Compute the square of the distance between two points.
+ * <p>Calling this method is equivalent to calling:
+ * <code>p1.subtract(p2).getNormSq()</code> except that no intermediate
+ * vector is built</p>
+ * @param p1 first vector
+ * @param p2 second vector
+ * @return the square of the distance between p1 and p2
+ */
+ public static double distanceSq(Cartesian1D p1, Cartesian1D p2) {
+ return p1.distanceSq(p2);
+ }
+
+ /**
+ * Test for the equality of two 1D vectors.
+ * <p>
+ * If all coordinates of two 1D vectors are exactly the same, and none are
+ * <code>Double.NaN</code>, the two 1D vectors are considered to be equal.
+ * </p>
+ * <p>
+ * <code>NaN</code> coordinates are considered to affect globally the vector
+ * and be equals to each other - i.e, if either (or all) coordinates of the
+ * 1D vector are equal to <code>Double.NaN</code>, the 1D vector is equal to
+ * {@link #NaN}.
+ * </p>
+ *
+ * @param other Object to test for equality to this
+ * @return true if two 1D vector objects are equal, false if
+ * object is null, not an instance of Vector1D, or
+ * not equal to this Vector1D instance
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+
+ if (this == other) {
+ return true;
+ }
+
+ if (other instanceof Cartesian1D) {
+ final Cartesian1D rhs = (Cartesian1D)other;
+ if (rhs.isNaN()) {
+ return this.isNaN();
+ }
+
+ return x == rhs.x;
+ }
+ return false;
+ }
+
+ /**
+ * Get a hashCode for the 1D vector.
+ * <p>
+ * All NaN values have the same hash code.</p>
+ *
+ * @return a hash code value for this object
+ */
+ @Override
+ public int hashCode() {
+ if (isNaN()) {
+ return 7785;
+ }
+ return 997 * MathUtils.hash(x);
+ }
+
+ /** Get a string representation of this vector.
+ * @return a string representation of this vector
+ */
+ @Override
+ public String toString() {
+ return Vector1DFormat.getInstance().format(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString(final NumberFormat format) {
+ return new Vector1DFormat(format).format(this);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Coordinates1D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Coordinates1D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Coordinates1D.java
deleted file mode 100644
index 1f31594..0000000
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Coordinates1D.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.geometry.euclidean.oned;
-
-import java.text.NumberFormat;
-
-import org.apache.commons.math4.exception.MathArithmeticException;
-import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.geometry.Point;
-import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.Vector;
-import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.MathUtils;
-
-/** This class represents a 1D point or a 1D vector.
- * <p>An instance of Coordinates1D represents the point with the corresponding
- * coordinates.</p>
- * <p>An instance of Coordinates1D also represents the vector which begins at
- * the origin and ends at the point corresponding to the coordinates.</p>
- * <p>Instances of this class are guaranteed to be immutable.</p>
- * @since 4.0
- */
-public class Coordinates1D implements Point<Euclidean1D>, Vector<Euclidean1D> {
-
- /** Origin (coordinates: 0). */
- public static final Coordinates1D ZERO = new Coordinates1D(0.0);
-
- /** Unit (coordinates: 1). */
- public static final Coordinates1D ONE = new Coordinates1D(1.0);
-
- // CHECKSTYLE: stop ConstantName
- /** A vector with all coordinates set to NaN. */
- public static final Coordinates1D NaN = new Coordinates1D(Double.NaN);
- // CHECKSTYLE: resume ConstantName
-
- /** A vector with all coordinates set to positive infinity. */
- public static final Coordinates1D POSITIVE_INFINITY =
- new Coordinates1D(Double.POSITIVE_INFINITY);
-
- /** A vector with all coordinates set to negative infinity. */
- public static final Coordinates1D NEGATIVE_INFINITY =
- new Coordinates1D(Double.NEGATIVE_INFINITY);
-
- /** Serializable UID. */
- private static final long serialVersionUID = 7556674948671647925L;
-
- /** Abscissa. */
- private final double x;
-
- /** Simple constructor.
- * Build a vector from its coordinates
- * @param x abscissa
- * @see #getX()
- */
- public Coordinates1D(double x) {
- this.x = x;
- }
-
- /** Multiplicative constructor
- * Build a vector from another one and a scale factor.
- * The vector built will be a * u
- * @param a scale factor
- * @param u base (unscaled) vector
- */
- public Coordinates1D(double a, Coordinates1D u) {
- this.x = a * u.x;
- }
-
- /** Linear constructor
- * Build a vector from two other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- */
- public Coordinates1D(double a1, Coordinates1D u1, double a2, Coordinates1D u2) {
- this.x = a1 * u1.x + a2 * u2.x;
- }
-
- /** Linear constructor
- * Build a vector from three other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2 + a3 * u3
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- * @param a3 third scale factor
- * @param u3 third base (unscaled) vector
- */
- public Coordinates1D(double a1, Coordinates1D u1, double a2, Coordinates1D u2,
- double a3, Coordinates1D u3) {
- this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x;
- }
-
- /** Linear constructor
- * Build a vector from four other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- * @param a3 third scale factor
- * @param u3 third base (unscaled) vector
- * @param a4 fourth scale factor
- * @param u4 fourth base (unscaled) vector
- */
- public Coordinates1D(double a1, Coordinates1D u1, double a2, Coordinates1D u2,
- double a3, Coordinates1D u3, double a4, Coordinates1D u4) {
- this.x = a1 * u1.x + a2 * u2.x + a3 * u3.x + a4 * u4.x;
- }
-
- /** Get the abscissa of the vector.
- * @return abscissa of the vector
- * @see #Vector1D(double)
- */
- public double getX() {
- return x;
- }
-
- /** {@inheritDoc} */
- @Override
- public Space getSpace() {
- return Euclidean1D.getInstance();
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates1D getZero() {
- return ZERO;
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNorm1() {
- return FastMath.abs(x);
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNorm() {
- return FastMath.abs(x);
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNormSq() {
- return x * x;
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNormInf() {
- return FastMath.abs(x);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates1D add(Vector<Euclidean1D> v) {
- Coordinates1D v1 = (Coordinates1D) v;
- return new Coordinates1D(x + v1.getX());
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates1D add(double factor, Vector<Euclidean1D> v) {
- Coordinates1D v1 = (Coordinates1D) v;
- return new Coordinates1D(x + factor * v1.getX());
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates1D subtract(Vector<Euclidean1D> p) {
- Coordinates1D p3 = (Coordinates1D) p;
- return new Coordinates1D(x - p3.x);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates1D subtract(double factor, Vector<Euclidean1D> v) {
- Coordinates1D v1 = (Coordinates1D) v;
- return new Coordinates1D(x - factor * v1.getX());
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates1D normalize() throws MathArithmeticException {
- double s = getNorm();
- if (s == 0) {
- throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
- }
- return scalarMultiply(1 / s);
- }
- /** {@inheritDoc} */
- @Override
- public Coordinates1D negate() {
- return new Coordinates1D(-x);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates1D scalarMultiply(double a) {
- return new Coordinates1D(a * x);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isNaN() {
- return Double.isNaN(x);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isInfinite() {
- return !isNaN() && Double.isInfinite(x);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance1(Vector<Euclidean1D> p) {
- Coordinates1D p3 = (Coordinates1D) p;
- final double dx = FastMath.abs(p3.x - x);
- return dx;
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance(Point<Euclidean1D> p) {
- return distance((Coordinates1D) p);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance(Vector<Euclidean1D> v) {
- return distance((Coordinates1D) v);
- }
-
- /** Compute the distance between the instance and other coordinates.
- * @param c other coordinates
- * @return the distance between the instance and c
- */
- public double distance(Coordinates1D c) {
- final double dx = c.x - x;
- return FastMath.abs(dx);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distanceInf(Vector<Euclidean1D> p) {
- Coordinates1D p3 = (Coordinates1D) p;
- final double dx = FastMath.abs(p3.x - x);
- return dx;
- }
-
- /** {@inheritDoc} */
- @Override
- public double distanceSq(Vector<Euclidean1D> p) {
- Coordinates1D p3 = (Coordinates1D) p;
- final double dx = p3.x - x;
- return dx * dx;
- }
-
- /** {@inheritDoc} */
- @Override
- public double dotProduct(final Vector<Euclidean1D> v) {
- final Coordinates1D v1 = (Coordinates1D) v;
- return x * v1.x;
- }
-
- /** Compute the distance between two vectors according to the L<sub>2</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>p1.subtract(p2).getNorm()</code> except that no intermediate
- * vector is built</p>
- * @param p1 first vector
- * @param p2 second vector
- * @return the distance between p1 and p2 according to the L<sub>2</sub> norm
- */
- public static double distance(Coordinates1D p1, Coordinates1D p2) {
- return p1.distance(p2);
- }
-
- /** Compute the distance between two vectors according to the L<sub>∞</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>p1.subtract(p2).getNormInf()</code> except that no intermediate
- * vector is built</p>
- * @param p1 first vector
- * @param p2 second vector
- * @return the distance between p1 and p2 according to the L<sub>∞</sub> norm
- */
- public static double distanceInf(Coordinates1D p1, Coordinates1D p2) {
- return p1.distanceInf(p2);
- }
-
- /** Compute the square of the distance between two vectors.
- * <p>Calling this method is equivalent to calling:
- * <code>p1.subtract(p2).getNormSq()</code> except that no intermediate
- * vector is built</p>
- * @param p1 first vector
- * @param p2 second vector
- * @return the square of the distance between p1 and p2
- */
- public static double distanceSq(Coordinates1D p1, Coordinates1D p2) {
- return p1.distanceSq(p2);
- }
-
- /**
- * Test for the equality of two 1D vectors.
- * <p>
- * If all coordinates of two 1D vectors are exactly the same, and none are
- * <code>Double.NaN</code>, the two 1D vectors are considered to be equal.
- * </p>
- * <p>
- * <code>NaN</code> coordinates are considered to affect globally the vector
- * and be equals to each other - i.e, if either (or all) coordinates of the
- * 1D vector are equal to <code>Double.NaN</code>, the 1D vector is equal to
- * {@link #NaN}.
- * </p>
- *
- * @param other Object to test for equality to this
- * @return true if two 1D vector objects are equal, false if
- * object is null, not an instance of Vector1D, or
- * not equal to this Vector1D instance
- *
- */
- @Override
- public boolean equals(Object other) {
-
- if (this == other) {
- return true;
- }
-
- if (other instanceof Coordinates1D) {
- final Coordinates1D rhs = (Coordinates1D)other;
- if (rhs.isNaN()) {
- return this.isNaN();
- }
-
- return x == rhs.x;
- }
- return false;
- }
-
- /**
- * Get a hashCode for the 1D vector.
- * <p>
- * All NaN values have the same hash code.</p>
- *
- * @return a hash code value for this object
- */
- @Override
- public int hashCode() {
- if (isNaN()) {
- return 7785;
- }
- return 997 * MathUtils.hash(x);
- }
-
- /** Get a string representation of this vector.
- * @return a string representation of this vector
- */
- @Override
- public String toString() {
- return Vector1DFormat.getInstance().format(this);
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString(final NumberFormat format) {
- return new Vector1DFormat(format).format(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java
index 78c50c1..acab5a6 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java
@@ -112,14 +112,14 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
}
// the tree must be open on the negative infinity side
final SubHyperplane<Euclidean1D> upperCut =
- new OrientedPoint(new Coordinates1D(upper), true, tolerance).wholeHyperplane();
+ new OrientedPoint(new Cartesian1D(upper), true, tolerance).wholeHyperplane();
return new BSPTree<>(upperCut,
new BSPTree<Euclidean1D>(Boolean.FALSE),
new BSPTree<Euclidean1D>(Boolean.TRUE),
null);
}
final SubHyperplane<Euclidean1D> lowerCut =
- new OrientedPoint(new Coordinates1D(lower), false, tolerance).wholeHyperplane();
+ new OrientedPoint(new Cartesian1D(lower), false, tolerance).wholeHyperplane();
if (Double.isInfinite(upper) && (upper > 0)) {
// the tree must be open on the positive infinity side
return new BSPTree<>(lowerCut,
@@ -130,7 +130,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
// the tree must be bounded on the two sides
final SubHyperplane<Euclidean1D> upperCut =
- new OrientedPoint(new Coordinates1D(upper), true, tolerance).wholeHyperplane();
+ new OrientedPoint(new Cartesian1D(upper), true, tolerance).wholeHyperplane();
return new BSPTree<>(lowerCut,
new BSPTree<Euclidean1D>(Boolean.FALSE),
new BSPTree<>(upperCut,
@@ -151,7 +151,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
@Override
protected void computeGeometricalProperties() {
if (getTree(false).getCut() == null) {
- setBarycenter((Point<Euclidean1D>) Coordinates1D.NaN);
+ setBarycenter((Point<Euclidean1D>) Cartesian1D.NaN);
setSize(((Boolean) getTree(false).getAttribute()) ? Double.POSITIVE_INFINITY : 0);
} else {
double size = 0.0;
@@ -162,9 +162,9 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
}
setSize(size);
if (Double.isInfinite(size)) {
- setBarycenter((Point<Euclidean1D>) Coordinates1D.NaN);
+ setBarycenter((Point<Euclidean1D>) Cartesian1D.NaN);
} else if (size >= Precision.SAFE_MIN) {
- setBarycenter((Point<Euclidean1D>) new Coordinates1D(sum / size));
+ setBarycenter((Point<Euclidean1D>) new Cartesian1D(sum / size));
} else {
setBarycenter((Point<Euclidean1D>) ((OrientedPoint) getTree(false).getCut().getHyperplane()).getLocation());
}
@@ -212,7 +212,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
public BoundaryProjection<Euclidean1D> projectToBoundary(final Point<Euclidean1D> point) {
// get position of test point
- final double x = ((Coordinates1D) point).getX();
+ final double x = ((Cartesian1D) point).getX();
double previous = Double.NEGATIVE_INFINITY;
for (final double[] a : this) {
@@ -249,8 +249,8 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
* @param x abscissa of the point
* @return a new point for finite abscissa, null otherwise
*/
- private Coordinates1D finiteOrNullPoint(final double x) {
- return Double.isInfinite(x) ? null : new Coordinates1D(x);
+ private Cartesian1D finiteOrNullPoint(final double x) {
+ return Double.isInfinite(x) ? null : new Cartesian1D(x);
}
/** Build an ordered list of intervals representing the instance.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java
index 2f719a2..f917bcc 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java
@@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.partitioning.Hyperplane;
public class OrientedPoint implements Hyperplane<Euclidean1D> {
/** Vector location. */
- private final Coordinates1D location;
+ private final Cartesian1D location;
/** Orientation. */
private boolean direct;
@@ -44,7 +44,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
* @param tolerance tolerance below which points are considered to belong to the hyperplane
* @since 3.3
*/
- public OrientedPoint(final Coordinates1D location, final boolean direct, final double tolerance) {
+ public OrientedPoint(final Cartesian1D location, final boolean direct, final double tolerance) {
this.location = location;
this.direct = direct;
this.tolerance = tolerance;
@@ -71,7 +71,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
/** {@inheritDoc} */
@Override
public double getOffset(final Point<Euclidean1D> point) {
- final double delta = ((Coordinates1D) point).getX() - location.getX();
+ final double delta = ((Cartesian1D) point).getX() - location.getX();
return direct ? delta : -delta;
}
@@ -125,7 +125,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
/** Get the hyperplane location on the real line.
* @return the hyperplane location
*/
- public Coordinates1D getLocation() {
+ public Cartesian1D getLocation() {
return location;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
index 4b40bb3..c5cead3 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
@@ -105,31 +105,31 @@ public class Vector1DFormat extends VectorFormat<Euclidean1D> {
@Override
public StringBuffer format(final Vector<Euclidean1D> vector, final StringBuffer toAppendTo,
final FieldPosition pos) {
- final Coordinates1D p1 = (Coordinates1D) vector;
+ final Cartesian1D p1 = (Cartesian1D) vector;
return format(toAppendTo, pos, p1.getX());
}
/** {@inheritDoc} */
@Override
- public Coordinates1D parse(final String source) throws MathParseException {
+ public Cartesian1D parse(final String source) throws MathParseException {
ParsePosition parsePosition = new ParsePosition(0);
- Coordinates1D result = parse(source, parsePosition);
+ Cartesian1D result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw new MathParseException(source,
parsePosition.getErrorIndex(),
- Coordinates1D.class);
+ Cartesian1D.class);
}
return result;
}
/** {@inheritDoc} */
@Override
- public Coordinates1D parse(final String source, final ParsePosition pos) {
+ public Cartesian1D parse(final String source, final ParsePosition pos) {
final double[] coordinates = parseCoordinates(1, source, pos);
if (coordinates == null) {
return null;
}
- return new Coordinates1D(coordinates[0]);
+ return new Cartesian1D(coordinates[0]);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
new file mode 100644
index 0000000..85696f6
--- /dev/null
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Cartesian3D.java
@@ -0,0 +1,621 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math4.geometry.euclidean.threed;
+
+import java.io.Serializable;
+import java.text.NumberFormat;
+
+import org.apache.commons.math4.exception.DimensionMismatchException;
+import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.exception.util.LocalizedFormats;
+import org.apache.commons.math4.geometry.Point;
+import org.apache.commons.math4.geometry.Space;
+import org.apache.commons.math4.geometry.Vector;
+import org.apache.commons.math4.util.FastMath;
+import org.apache.commons.math4.util.MathArrays;
+import org.apache.commons.math4.util.MathUtils;
+
+/**
+ * This class represents points or vectors in a three-dimensional space.
+ * <p>An instance of Cartesian3D represents the point with the corresponding
+ * coordinates.</p>
+ * <p>An instance of Cartesian3D also represents the vector which begins at
+ * the origin and ends at the point corresponding to the coordinates.</p>
+ * <p>Instance of this class are guaranteed to be immutable.</p>
+ * @since 4.0
+ */
+public class Cartesian3D implements Serializable, Point<Euclidean3D>, Vector<Euclidean3D> {
+
+ /** Null vector (coordinates: 0, 0, 0). */
+ public static final Cartesian3D ZERO = new Cartesian3D(0, 0, 0);
+
+ /** First canonical vector (coordinates: 1, 0, 0). */
+ public static final Cartesian3D PLUS_I = new Cartesian3D(1, 0, 0);
+
+ /** Opposite of the first canonical vector (coordinates: -1, 0, 0). */
+ public static final Cartesian3D MINUS_I = new Cartesian3D(-1, 0, 0);
+
+ /** Second canonical vector (coordinates: 0, 1, 0). */
+ public static final Cartesian3D PLUS_J = new Cartesian3D(0, 1, 0);
+
+ /** Opposite of the second canonical vector (coordinates: 0, -1, 0). */
+ public static final Cartesian3D MINUS_J = new Cartesian3D(0, -1, 0);
+
+ /** Third canonical vector (coordinates: 0, 0, 1). */
+ public static final Cartesian3D PLUS_K = new Cartesian3D(0, 0, 1);
+
+ /** Opposite of the third canonical vector (coordinates: 0, 0, -1). */
+ public static final Cartesian3D MINUS_K = new Cartesian3D(0, 0, -1);
+
+ // CHECKSTYLE: stop ConstantName
+ /** A vector with all coordinates set to NaN. */
+ public static final Cartesian3D NaN = new Cartesian3D(Double.NaN, Double.NaN, Double.NaN);
+ // CHECKSTYLE: resume ConstantName
+
+ /** A vector with all coordinates set to positive infinity. */
+ public static final Cartesian3D POSITIVE_INFINITY =
+ new Cartesian3D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+
+ /** A vector with all coordinates set to negative infinity. */
+ public static final Cartesian3D NEGATIVE_INFINITY =
+ new Cartesian3D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+
+ /** Serializable version identifier. */
+ private static final long serialVersionUID = 1313493323784566947L;
+
+ /** Abscissa. */
+ private final double x;
+
+ /** Ordinate. */
+ private final double y;
+
+ /** Height. */
+ private final double z;
+
+ /** Simple constructor.
+ * Build a vector from its coordinates
+ * @param x abscissa
+ * @param y ordinate
+ * @param z height
+ * @see #getX()
+ * @see #getY()
+ * @see #getZ()
+ */
+ public Cartesian3D(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /** Simple constructor.
+ * Build a vector from its coordinates
+ * @param v coordinates array
+ * @exception DimensionMismatchException if array does not have 3 elements
+ * @see #toArray()
+ */
+ public Cartesian3D(double[] v) throws DimensionMismatchException {
+ if (v.length != 3) {
+ throw new DimensionMismatchException(v.length, 3);
+ }
+ this.x = v[0];
+ this.y = v[1];
+ this.z = v[2];
+ }
+
+ /** Simple constructor.
+ * Build a vector from its azimuthal coordinates
+ * @param alpha azimuth (α) around Z
+ * (0 is +X, π/2 is +Y, π is -X and 3π/2 is -Y)
+ * @param delta elevation (δ) above (XY) plane, from -π/2 to +π/2
+ * @see #getAlpha()
+ * @see #getDelta()
+ */
+ public Cartesian3D(double alpha, double delta) {
+ double cosDelta = FastMath.cos(delta);
+ this.x = FastMath.cos(alpha) * cosDelta;
+ this.y = FastMath.sin(alpha) * cosDelta;
+ this.z = FastMath.sin(delta);
+ }
+
+ /** Multiplicative constructor
+ * Build a vector from another one and a scale factor.
+ * The vector built will be a * u
+ * @param a scale factor
+ * @param u base (unscaled) vector
+ */
+ public Cartesian3D(double a, Cartesian3D u) {
+ this.x = a * u.x;
+ this.y = a * u.y;
+ this.z = a * u.z;
+ }
+
+ /** Linear constructor
+ * Build a vector from two other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ */
+ public Cartesian3D(double a1, Cartesian3D u1, double a2, Cartesian3D u2) {
+ this.x = MathArrays.linearCombination(a1, u1.x, a2, u2.x);
+ this.y = MathArrays.linearCombination(a1, u1.y, a2, u2.y);
+ this.z = MathArrays.linearCombination(a1, u1.z, a2, u2.z);
+ }
+
+ /** Linear constructor
+ * Build a vector from three other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2 + a3 * u3
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ * @param a3 third scale factor
+ * @param u3 third base (unscaled) vector
+ */
+ public Cartesian3D(double a1, Cartesian3D u1, double a2, Cartesian3D u2,
+ double a3, Cartesian3D u3) {
+ this.x = MathArrays.linearCombination(a1, u1.x, a2, u2.x, a3, u3.x);
+ this.y = MathArrays.linearCombination(a1, u1.y, a2, u2.y, a3, u3.y);
+ this.z = MathArrays.linearCombination(a1, u1.z, a2, u2.z, a3, u3.z);
+ }
+
+ /** Linear constructor
+ * Build a vector from four other ones and corresponding scale factors.
+ * The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
+ * @param a1 first scale factor
+ * @param u1 first base (unscaled) vector
+ * @param a2 second scale factor
+ * @param u2 second base (unscaled) vector
+ * @param a3 third scale factor
+ * @param u3 third base (unscaled) vector
+ * @param a4 fourth scale factor
+ * @param u4 fourth base (unscaled) vector
+ */
+ public Cartesian3D(double a1, Cartesian3D u1, double a2, Cartesian3D u2,
+ double a3, Cartesian3D u3, double a4, Cartesian3D u4) {
+ this.x = MathArrays.linearCombination(a1, u1.x, a2, u2.x, a3, u3.x, a4, u4.x);
+ this.y = MathArrays.linearCombination(a1, u1.y, a2, u2.y, a3, u3.y, a4, u4.y);
+ this.z = MathArrays.linearCombination(a1, u1.z, a2, u2.z, a3, u3.z, a4, u4.z);
+ }
+
+ /** Get the abscissa of the vector.
+ * @return abscissa of the vector
+ * @see #Vector3D(double, double, double)
+ */
+ public double getX() {
+ return x;
+ }
+
+ /** Get the ordinate of the vector.
+ * @return ordinate of the vector
+ * @see #Vector3D(double, double, double)
+ */
+ public double getY() {
+ return y;
+ }
+
+ /** Get the height of the vector.
+ * @return height of the vector
+ * @see #Vector3D(double, double, double)
+ */
+ public double getZ() {
+ return z;
+ }
+
+ /** Get the vector coordinates as a dimension 3 array.
+ * @return vector coordinates
+ * @see #Vector3D(double[])
+ */
+ public double[] toArray() {
+ return new double[] { x, y, z };
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Space getSpace() {
+ return Euclidean3D.getInstance();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D getZero() {
+ return ZERO;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNorm1() {
+ return FastMath.abs(x) + FastMath.abs(y) + FastMath.abs(z);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNorm() {
+ // there are no cancellation problems here, so we use the straightforward formula
+ return FastMath.sqrt (x * x + y * y + z * z);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNormSq() {
+ // there are no cancellation problems here, so we use the straightforward formula
+ return x * x + y * y + z * z;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getNormInf() {
+ return FastMath.max(FastMath.max(FastMath.abs(x), FastMath.abs(y)), FastMath.abs(z));
+ }
+
+ /** Get the azimuth of the vector.
+ * @return azimuth (α) of the vector, between -π and +π
+ * @see #Vector3D(double, double)
+ */
+ public double getAlpha() {
+ return FastMath.atan2(y, x);
+ }
+
+ /** Get the elevation of the vector.
+ * @return elevation (δ) of the vector, between -π/2 and +π/2
+ * @see #Vector3D(double, double)
+ */
+ public double getDelta() {
+ return FastMath.asin(z / getNorm());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D add(final Vector<Euclidean3D> v) {
+ final Cartesian3D v3 = (Cartesian3D) v;
+ return new Cartesian3D(x + v3.x, y + v3.y, z + v3.z);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D add(double factor, final Vector<Euclidean3D> v) {
+ return new Cartesian3D(1, this, factor, (Cartesian3D) v);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D subtract(final Vector<Euclidean3D> v) {
+ final Cartesian3D v3 = (Cartesian3D) v;
+ return new Cartesian3D(x - v3.x, y - v3.y, z - v3.z);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D subtract(final double factor, final Vector<Euclidean3D> v) {
+ return new Cartesian3D(1, this, -factor, (Cartesian3D) v);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D normalize() throws MathArithmeticException {
+ double s = getNorm();
+ if (s == 0) {
+ throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
+ }
+ return scalarMultiply(1 / s);
+ }
+
+ /** Get a vector orthogonal to the instance.
+ * <p>There are an infinite number of normalized vectors orthogonal
+ * to the instance. This method picks up one of them almost
+ * arbitrarily. It is useful when one needs to compute a reference
+ * frame with one of the axes in a predefined direction. The
+ * following example shows how to build a frame having the k axis
+ * aligned with the known vector u :
+ * <pre><code>
+ * Vector3D k = u.normalize();
+ * Vector3D i = k.orthogonal();
+ * Vector3D j = Vector3D.crossProduct(k, i);
+ * </code></pre></p>
+ * @return a new normalized vector orthogonal to the instance
+ * @exception MathArithmeticException if the norm of the instance is null
+ */
+ public Cartesian3D orthogonal() throws MathArithmeticException {
+
+ double threshold = 0.6 * getNorm();
+ if (threshold == 0) {
+ throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
+ }
+
+ if (FastMath.abs(x) <= threshold) {
+ double inverse = 1 / FastMath.sqrt(y * y + z * z);
+ return new Cartesian3D(0, inverse * z, -inverse * y);
+ } else if (FastMath.abs(y) <= threshold) {
+ double inverse = 1 / FastMath.sqrt(x * x + z * z);
+ return new Cartesian3D(-inverse * z, 0, inverse * x);
+ }
+ double inverse = 1 / FastMath.sqrt(x * x + y * y);
+ return new Cartesian3D(inverse * y, -inverse * x, 0);
+
+ }
+
+ /** Compute the angular separation between two vectors.
+ * <p>This method computes the angular separation between two
+ * vectors using the dot product for well separated vectors and the
+ * cross product for almost aligned vectors. This allows to have a
+ * good accuracy in all cases, even for vectors very close to each
+ * other.</p>
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return angular separation between v1 and v2
+ * @exception MathArithmeticException if either vector has a null norm
+ */
+ public static double angle(Cartesian3D v1, Cartesian3D v2) throws MathArithmeticException {
+
+ double normProduct = v1.getNorm() * v2.getNorm();
+ if (normProduct == 0) {
+ throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
+ }
+
+ double dot = v1.dotProduct(v2);
+ double threshold = normProduct * 0.9999;
+ if ((dot < -threshold) || (dot > threshold)) {
+ // the vectors are almost aligned, compute using the sine
+ Cartesian3D v3 = crossProduct(v1, v2);
+ if (dot >= 0) {
+ return FastMath.asin(v3.getNorm() / normProduct);
+ }
+ return FastMath.PI - FastMath.asin(v3.getNorm() / normProduct);
+ }
+
+ // the vectors are sufficiently separated to use the cosine
+ return FastMath.acos(dot / normProduct);
+
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D negate() {
+ return new Cartesian3D(-x, -y, -z);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Cartesian3D scalarMultiply(double a) {
+ return new Cartesian3D(a * x, a * y, a * z);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isNaN() {
+ return Double.isNaN(x) || Double.isNaN(y) || Double.isNaN(z);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isInfinite() {
+ return !isNaN() && (Double.isInfinite(x) || Double.isInfinite(y) || Double.isInfinite(z));
+ }
+
+ /**
+ * Test for the equality of two 3D vectors.
+ * <p>
+ * If all coordinates of two 3D vectors are exactly the same, and none are
+ * <code>Double.NaN</code>, the two 3D vectors are considered to be equal.
+ * </p>
+ * <p>
+ * <code>NaN</code> coordinates are considered to affect globally the vector
+ * and be equals to each other - i.e, if either (or all) coordinates of the
+ * 3D vector are equal to <code>Double.NaN</code>, the 3D vector is equal to
+ * {@link #NaN}.
+ * </p>
+ *
+ * @param other Object to test for equality to this
+ * @return true if two 3D vector objects are equal, false if
+ * object is null, not an instance of Vector3D, or
+ * not equal to this Vector3D instance
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+
+ if (this == other) {
+ return true;
+ }
+
+ if (other instanceof Cartesian3D) {
+ final Cartesian3D rhs = (Cartesian3D)other;
+ if (rhs.isNaN()) {
+ return this.isNaN();
+ }
+
+ return (x == rhs.x) && (y == rhs.y) && (z == rhs.z);
+ }
+ return false;
+ }
+
+ /**
+ * Get a hashCode for the 3D vector.
+ * <p>
+ * All NaN values have the same hash code.</p>
+ *
+ * @return a hash code value for this object
+ */
+ @Override
+ public int hashCode() {
+ if (isNaN()) {
+ return 642;
+ }
+ return 643 * (164 * MathUtils.hash(x) + 3 * MathUtils.hash(y) + MathUtils.hash(z));
+ }
+
+ /** {@inheritDoc}
+ * <p>
+ * The implementation uses specific multiplication and addition
+ * algorithms to preserve accuracy and reduce cancellation effects.
+ * It should be very accurate even for nearly orthogonal vectors.
+ * </p>
+ * @see MathArrays#linearCombination(double, double, double, double, double, double)
+ */
+ @Override
+ public double dotProduct(final Vector<Euclidean3D> v) {
+ final Cartesian3D v3 = (Cartesian3D) v;
+ return MathArrays.linearCombination(x, v3.x, y, v3.y, z, v3.z);
+ }
+
+ /** Compute the cross-product of the instance with another vector.
+ * @param v other vector
+ * @return the cross product this ^ v as a new Vector3D
+ */
+ public Cartesian3D crossProduct(final Vector<Euclidean3D> v) {
+ final Cartesian3D v3 = (Cartesian3D) v;
+ return new Cartesian3D(MathArrays.linearCombination(y, v3.z, -z, v3.y),
+ MathArrays.linearCombination(z, v3.x, -x, v3.z),
+ MathArrays.linearCombination(x, v3.y, -y, v3.x));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance1(Vector<Euclidean3D> v) {
+ final Cartesian3D v3 = (Cartesian3D) v;
+ final double dx = FastMath.abs(v3.x - x);
+ final double dy = FastMath.abs(v3.y - y);
+ final double dz = FastMath.abs(v3.z - z);
+ return dx + dy + dz;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance(Point<Euclidean3D> p) {
+ return distance((Cartesian3D) p);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distance(Vector<Euclidean3D> v) {
+ return distance((Cartesian3D) v);
+ }
+
+ /** Compute the distance between the instance and other coordinates.
+ * @param c other coordinates
+ * @return the distance between the instance and c
+ */
+ public double distance(Cartesian3D c) {
+ final double dx = c.x - x;
+ final double dy = c.y - y;
+ final double dz = c.z - z;
+ return FastMath.sqrt(dx * dx + dy * dy + dz * dz);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distanceInf(Vector<Euclidean3D> v) {
+ final Cartesian3D v3 = (Cartesian3D) v;
+ final double dx = FastMath.abs(v3.x - x);
+ final double dy = FastMath.abs(v3.y - y);
+ final double dz = FastMath.abs(v3.z - z);
+ return FastMath.max(FastMath.max(dx, dy), dz);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double distanceSq(Vector<Euclidean3D> v) {
+ final Cartesian3D v3 = (Cartesian3D) v;
+ final double dx = v3.x - x;
+ final double dy = v3.y - y;
+ final double dz = v3.z - z;
+ return dx * dx + dy * dy + dz * dz;
+ }
+
+ /** Compute the dot-product of two vectors.
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return the dot product v1.v2
+ */
+ public static double dotProduct(Cartesian3D v1, Cartesian3D v2) {
+ return v1.dotProduct(v2);
+ }
+
+ /** Compute the cross-product of two vectors.
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return the cross product v1 ^ v2 as a new Vector
+ */
+ public static Cartesian3D crossProduct(final Cartesian3D v1, final Cartesian3D v2) {
+ return v1.crossProduct(v2);
+ }
+
+ /** Compute the distance between two vectors according to the L<sub>1</sub> norm.
+ * <p>Calling this method is equivalent to calling:
+ * <code>v1.subtract(v2).getNorm1()</code> except that no intermediate
+ * vector is built</p>
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return the distance between v1 and v2 according to the L<sub>1</sub> norm
+ */
+ public static double distance1(Cartesian3D v1, Cartesian3D v2) {
+ return v1.distance1(v2);
+ }
+
+ /** Compute the distance between two vectors according to the L<sub>2</sub> norm.
+ * <p>Calling this method is equivalent to calling:
+ * <code>v1.subtract(v2).getNorm()</code> except that no intermediate
+ * vector is built</p>
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return the distance between v1 and v2 according to the L<sub>2</sub> norm
+ */
+ public static double distance(Cartesian3D v1, Cartesian3D v2) {
+ return v1.distance(v2);
+ }
+
+ /** Compute the distance between two vectors according to the L<sub>∞</sub> norm.
+ * <p>Calling this method is equivalent to calling:
+ * <code>v1.subtract(v2).getNormInf()</code> except that no intermediate
+ * vector is built</p>
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return the distance between v1 and v2 according to the L<sub>∞</sub> norm
+ */
+ public static double distanceInf(Cartesian3D v1, Cartesian3D v2) {
+ return v1.distanceInf(v2);
+ }
+
+ /** Compute the square of the distance between two vectors.
+ * <p>Calling this method is equivalent to calling:
+ * <code>v1.subtract(v2).getNormSq()</code> except that no intermediate
+ * vector is built</p>
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return the square of the distance between v1 and v2
+ */
+ public static double distanceSq(Cartesian3D v1, Cartesian3D v2) {
+ return v1.distanceSq(v2);
+ }
+
+ /** Get a string representation of this vector.
+ * @return a string representation of this vector
+ */
+ @Override
+ public String toString() {
+ return Vector3DFormat.getInstance().format(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString(final NumberFormat format) {
+ return new Vector3DFormat(format).format(this);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Coordinates3D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Coordinates3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Coordinates3D.java
deleted file mode 100644
index ee2376c..0000000
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Coordinates3D.java
+++ /dev/null
@@ -1,621 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.geometry.euclidean.threed;
-
-import java.io.Serializable;
-import java.text.NumberFormat;
-
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.MathArithmeticException;
-import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.geometry.Point;
-import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.Vector;
-import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.MathArrays;
-import org.apache.commons.math4.util.MathUtils;
-
-/**
- * This class represents points or vectors in a three-dimensional space.
- * <p>An instance of Coordinates3D represents the point with the corresponding
- * coordinates.</p>
- * <p>An instance of Coordinates3D also represents the vector which begins at
- * the origin and ends at the point corresponding to the coordinates.</p>
- * <p>Instance of this class are guaranteed to be immutable.</p>
- * @since 4.0
- */
-public class Coordinates3D implements Serializable, Point<Euclidean3D>, Vector<Euclidean3D> {
-
- /** Null vector (coordinates: 0, 0, 0). */
- public static final Coordinates3D ZERO = new Coordinates3D(0, 0, 0);
-
- /** First canonical vector (coordinates: 1, 0, 0). */
- public static final Coordinates3D PLUS_I = new Coordinates3D(1, 0, 0);
-
- /** Opposite of the first canonical vector (coordinates: -1, 0, 0). */
- public static final Coordinates3D MINUS_I = new Coordinates3D(-1, 0, 0);
-
- /** Second canonical vector (coordinates: 0, 1, 0). */
- public static final Coordinates3D PLUS_J = new Coordinates3D(0, 1, 0);
-
- /** Opposite of the second canonical vector (coordinates: 0, -1, 0). */
- public static final Coordinates3D MINUS_J = new Coordinates3D(0, -1, 0);
-
- /** Third canonical vector (coordinates: 0, 0, 1). */
- public static final Coordinates3D PLUS_K = new Coordinates3D(0, 0, 1);
-
- /** Opposite of the third canonical vector (coordinates: 0, 0, -1). */
- public static final Coordinates3D MINUS_K = new Coordinates3D(0, 0, -1);
-
- // CHECKSTYLE: stop ConstantName
- /** A vector with all coordinates set to NaN. */
- public static final Coordinates3D NaN = new Coordinates3D(Double.NaN, Double.NaN, Double.NaN);
- // CHECKSTYLE: resume ConstantName
-
- /** A vector with all coordinates set to positive infinity. */
- public static final Coordinates3D POSITIVE_INFINITY =
- new Coordinates3D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
-
- /** A vector with all coordinates set to negative infinity. */
- public static final Coordinates3D NEGATIVE_INFINITY =
- new Coordinates3D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
-
- /** Serializable version identifier. */
- private static final long serialVersionUID = 1313493323784566947L;
-
- /** Abscissa. */
- private final double x;
-
- /** Ordinate. */
- private final double y;
-
- /** Height. */
- private final double z;
-
- /** Simple constructor.
- * Build a vector from its coordinates
- * @param x abscissa
- * @param y ordinate
- * @param z height
- * @see #getX()
- * @see #getY()
- * @see #getZ()
- */
- public Coordinates3D(double x, double y, double z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- /** Simple constructor.
- * Build a vector from its coordinates
- * @param v coordinates array
- * @exception DimensionMismatchException if array does not have 3 elements
- * @see #toArray()
- */
- public Coordinates3D(double[] v) throws DimensionMismatchException {
- if (v.length != 3) {
- throw new DimensionMismatchException(v.length, 3);
- }
- this.x = v[0];
- this.y = v[1];
- this.z = v[2];
- }
-
- /** Simple constructor.
- * Build a vector from its azimuthal coordinates
- * @param alpha azimuth (α) around Z
- * (0 is +X, π/2 is +Y, π is -X and 3π/2 is -Y)
- * @param delta elevation (δ) above (XY) plane, from -π/2 to +π/2
- * @see #getAlpha()
- * @see #getDelta()
- */
- public Coordinates3D(double alpha, double delta) {
- double cosDelta = FastMath.cos(delta);
- this.x = FastMath.cos(alpha) * cosDelta;
- this.y = FastMath.sin(alpha) * cosDelta;
- this.z = FastMath.sin(delta);
- }
-
- /** Multiplicative constructor
- * Build a vector from another one and a scale factor.
- * The vector built will be a * u
- * @param a scale factor
- * @param u base (unscaled) vector
- */
- public Coordinates3D(double a, Coordinates3D u) {
- this.x = a * u.x;
- this.y = a * u.y;
- this.z = a * u.z;
- }
-
- /** Linear constructor
- * Build a vector from two other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- */
- public Coordinates3D(double a1, Coordinates3D u1, double a2, Coordinates3D u2) {
- this.x = MathArrays.linearCombination(a1, u1.x, a2, u2.x);
- this.y = MathArrays.linearCombination(a1, u1.y, a2, u2.y);
- this.z = MathArrays.linearCombination(a1, u1.z, a2, u2.z);
- }
-
- /** Linear constructor
- * Build a vector from three other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2 + a3 * u3
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- * @param a3 third scale factor
- * @param u3 third base (unscaled) vector
- */
- public Coordinates3D(double a1, Coordinates3D u1, double a2, Coordinates3D u2,
- double a3, Coordinates3D u3) {
- this.x = MathArrays.linearCombination(a1, u1.x, a2, u2.x, a3, u3.x);
- this.y = MathArrays.linearCombination(a1, u1.y, a2, u2.y, a3, u3.y);
- this.z = MathArrays.linearCombination(a1, u1.z, a2, u2.z, a3, u3.z);
- }
-
- /** Linear constructor
- * Build a vector from four other ones and corresponding scale factors.
- * The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
- * @param a1 first scale factor
- * @param u1 first base (unscaled) vector
- * @param a2 second scale factor
- * @param u2 second base (unscaled) vector
- * @param a3 third scale factor
- * @param u3 third base (unscaled) vector
- * @param a4 fourth scale factor
- * @param u4 fourth base (unscaled) vector
- */
- public Coordinates3D(double a1, Coordinates3D u1, double a2, Coordinates3D u2,
- double a3, Coordinates3D u3, double a4, Coordinates3D u4) {
- this.x = MathArrays.linearCombination(a1, u1.x, a2, u2.x, a3, u3.x, a4, u4.x);
- this.y = MathArrays.linearCombination(a1, u1.y, a2, u2.y, a3, u3.y, a4, u4.y);
- this.z = MathArrays.linearCombination(a1, u1.z, a2, u2.z, a3, u3.z, a4, u4.z);
- }
-
- /** Get the abscissa of the vector.
- * @return abscissa of the vector
- * @see #Vector3D(double, double, double)
- */
- public double getX() {
- return x;
- }
-
- /** Get the ordinate of the vector.
- * @return ordinate of the vector
- * @see #Vector3D(double, double, double)
- */
- public double getY() {
- return y;
- }
-
- /** Get the height of the vector.
- * @return height of the vector
- * @see #Vector3D(double, double, double)
- */
- public double getZ() {
- return z;
- }
-
- /** Get the vector coordinates as a dimension 3 array.
- * @return vector coordinates
- * @see #Vector3D(double[])
- */
- public double[] toArray() {
- return new double[] { x, y, z };
- }
-
- /** {@inheritDoc} */
- @Override
- public Space getSpace() {
- return Euclidean3D.getInstance();
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D getZero() {
- return ZERO;
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNorm1() {
- return FastMath.abs(x) + FastMath.abs(y) + FastMath.abs(z);
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNorm() {
- // there are no cancellation problems here, so we use the straightforward formula
- return FastMath.sqrt (x * x + y * y + z * z);
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNormSq() {
- // there are no cancellation problems here, so we use the straightforward formula
- return x * x + y * y + z * z;
- }
-
- /** {@inheritDoc} */
- @Override
- public double getNormInf() {
- return FastMath.max(FastMath.max(FastMath.abs(x), FastMath.abs(y)), FastMath.abs(z));
- }
-
- /** Get the azimuth of the vector.
- * @return azimuth (α) of the vector, between -π and +π
- * @see #Vector3D(double, double)
- */
- public double getAlpha() {
- return FastMath.atan2(y, x);
- }
-
- /** Get the elevation of the vector.
- * @return elevation (δ) of the vector, between -π/2 and +π/2
- * @see #Vector3D(double, double)
- */
- public double getDelta() {
- return FastMath.asin(z / getNorm());
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D add(final Vector<Euclidean3D> v) {
- final Coordinates3D v3 = (Coordinates3D) v;
- return new Coordinates3D(x + v3.x, y + v3.y, z + v3.z);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D add(double factor, final Vector<Euclidean3D> v) {
- return new Coordinates3D(1, this, factor, (Coordinates3D) v);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D subtract(final Vector<Euclidean3D> v) {
- final Coordinates3D v3 = (Coordinates3D) v;
- return new Coordinates3D(x - v3.x, y - v3.y, z - v3.z);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D subtract(final double factor, final Vector<Euclidean3D> v) {
- return new Coordinates3D(1, this, -factor, (Coordinates3D) v);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D normalize() throws MathArithmeticException {
- double s = getNorm();
- if (s == 0) {
- throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
- }
- return scalarMultiply(1 / s);
- }
-
- /** Get a vector orthogonal to the instance.
- * <p>There are an infinite number of normalized vectors orthogonal
- * to the instance. This method picks up one of them almost
- * arbitrarily. It is useful when one needs to compute a reference
- * frame with one of the axes in a predefined direction. The
- * following example shows how to build a frame having the k axis
- * aligned with the known vector u :
- * <pre><code>
- * Vector3D k = u.normalize();
- * Vector3D i = k.orthogonal();
- * Vector3D j = Vector3D.crossProduct(k, i);
- * </code></pre></p>
- * @return a new normalized vector orthogonal to the instance
- * @exception MathArithmeticException if the norm of the instance is null
- */
- public Coordinates3D orthogonal() throws MathArithmeticException {
-
- double threshold = 0.6 * getNorm();
- if (threshold == 0) {
- throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
- }
-
- if (FastMath.abs(x) <= threshold) {
- double inverse = 1 / FastMath.sqrt(y * y + z * z);
- return new Coordinates3D(0, inverse * z, -inverse * y);
- } else if (FastMath.abs(y) <= threshold) {
- double inverse = 1 / FastMath.sqrt(x * x + z * z);
- return new Coordinates3D(-inverse * z, 0, inverse * x);
- }
- double inverse = 1 / FastMath.sqrt(x * x + y * y);
- return new Coordinates3D(inverse * y, -inverse * x, 0);
-
- }
-
- /** Compute the angular separation between two vectors.
- * <p>This method computes the angular separation between two
- * vectors using the dot product for well separated vectors and the
- * cross product for almost aligned vectors. This allows to have a
- * good accuracy in all cases, even for vectors very close to each
- * other.</p>
- * @param v1 first vector
- * @param v2 second vector
- * @return angular separation between v1 and v2
- * @exception MathArithmeticException if either vector has a null norm
- */
- public static double angle(Coordinates3D v1, Coordinates3D v2) throws MathArithmeticException {
-
- double normProduct = v1.getNorm() * v2.getNorm();
- if (normProduct == 0) {
- throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
- }
-
- double dot = v1.dotProduct(v2);
- double threshold = normProduct * 0.9999;
- if ((dot < -threshold) || (dot > threshold)) {
- // the vectors are almost aligned, compute using the sine
- Coordinates3D v3 = crossProduct(v1, v2);
- if (dot >= 0) {
- return FastMath.asin(v3.getNorm() / normProduct);
- }
- return FastMath.PI - FastMath.asin(v3.getNorm() / normProduct);
- }
-
- // the vectors are sufficiently separated to use the cosine
- return FastMath.acos(dot / normProduct);
-
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D negate() {
- return new Coordinates3D(-x, -y, -z);
- }
-
- /** {@inheritDoc} */
- @Override
- public Coordinates3D scalarMultiply(double a) {
- return new Coordinates3D(a * x, a * y, a * z);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isNaN() {
- return Double.isNaN(x) || Double.isNaN(y) || Double.isNaN(z);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isInfinite() {
- return !isNaN() && (Double.isInfinite(x) || Double.isInfinite(y) || Double.isInfinite(z));
- }
-
- /**
- * Test for the equality of two 3D vectors.
- * <p>
- * If all coordinates of two 3D vectors are exactly the same, and none are
- * <code>Double.NaN</code>, the two 3D vectors are considered to be equal.
- * </p>
- * <p>
- * <code>NaN</code> coordinates are considered to affect globally the vector
- * and be equals to each other - i.e, if either (or all) coordinates of the
- * 3D vector are equal to <code>Double.NaN</code>, the 3D vector is equal to
- * {@link #NaN}.
- * </p>
- *
- * @param other Object to test for equality to this
- * @return true if two 3D vector objects are equal, false if
- * object is null, not an instance of Vector3D, or
- * not equal to this Vector3D instance
- *
- */
- @Override
- public boolean equals(Object other) {
-
- if (this == other) {
- return true;
- }
-
- if (other instanceof Coordinates3D) {
- final Coordinates3D rhs = (Coordinates3D)other;
- if (rhs.isNaN()) {
- return this.isNaN();
- }
-
- return (x == rhs.x) && (y == rhs.y) && (z == rhs.z);
- }
- return false;
- }
-
- /**
- * Get a hashCode for the 3D vector.
- * <p>
- * All NaN values have the same hash code.</p>
- *
- * @return a hash code value for this object
- */
- @Override
- public int hashCode() {
- if (isNaN()) {
- return 642;
- }
- return 643 * (164 * MathUtils.hash(x) + 3 * MathUtils.hash(y) + MathUtils.hash(z));
- }
-
- /** {@inheritDoc}
- * <p>
- * The implementation uses specific multiplication and addition
- * algorithms to preserve accuracy and reduce cancellation effects.
- * It should be very accurate even for nearly orthogonal vectors.
- * </p>
- * @see MathArrays#linearCombination(double, double, double, double, double, double)
- */
- @Override
- public double dotProduct(final Vector<Euclidean3D> v) {
- final Coordinates3D v3 = (Coordinates3D) v;
- return MathArrays.linearCombination(x, v3.x, y, v3.y, z, v3.z);
- }
-
- /** Compute the cross-product of the instance with another vector.
- * @param v other vector
- * @return the cross product this ^ v as a new Vector3D
- */
- public Coordinates3D crossProduct(final Vector<Euclidean3D> v) {
- final Coordinates3D v3 = (Coordinates3D) v;
- return new Coordinates3D(MathArrays.linearCombination(y, v3.z, -z, v3.y),
- MathArrays.linearCombination(z, v3.x, -x, v3.z),
- MathArrays.linearCombination(x, v3.y, -y, v3.x));
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance1(Vector<Euclidean3D> v) {
- final Coordinates3D v3 = (Coordinates3D) v;
- final double dx = FastMath.abs(v3.x - x);
- final double dy = FastMath.abs(v3.y - y);
- final double dz = FastMath.abs(v3.z - z);
- return dx + dy + dz;
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance(Point<Euclidean3D> p) {
- return distance((Coordinates3D) p);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distance(Vector<Euclidean3D> v) {
- return distance((Coordinates3D) v);
- }
-
- /** Compute the distance between the instance and other coordinates.
- * @param c other coordinates
- * @return the distance between the instance and c
- */
- public double distance(Coordinates3D c) {
- final double dx = c.x - x;
- final double dy = c.y - y;
- final double dz = c.z - z;
- return FastMath.sqrt(dx * dx + dy * dy + dz * dz);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distanceInf(Vector<Euclidean3D> v) {
- final Coordinates3D v3 = (Coordinates3D) v;
- final double dx = FastMath.abs(v3.x - x);
- final double dy = FastMath.abs(v3.y - y);
- final double dz = FastMath.abs(v3.z - z);
- return FastMath.max(FastMath.max(dx, dy), dz);
- }
-
- /** {@inheritDoc} */
- @Override
- public double distanceSq(Vector<Euclidean3D> v) {
- final Coordinates3D v3 = (Coordinates3D) v;
- final double dx = v3.x - x;
- final double dy = v3.y - y;
- final double dz = v3.z - z;
- return dx * dx + dy * dy + dz * dz;
- }
-
- /** Compute the dot-product of two vectors.
- * @param v1 first vector
- * @param v2 second vector
- * @return the dot product v1.v2
- */
- public static double dotProduct(Coordinates3D v1, Coordinates3D v2) {
- return v1.dotProduct(v2);
- }
-
- /** Compute the cross-product of two vectors.
- * @param v1 first vector
- * @param v2 second vector
- * @return the cross product v1 ^ v2 as a new Vector
- */
- public static Coordinates3D crossProduct(final Coordinates3D v1, final Coordinates3D v2) {
- return v1.crossProduct(v2);
- }
-
- /** Compute the distance between two vectors according to the L<sub>1</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>v1.subtract(v2).getNorm1()</code> except that no intermediate
- * vector is built</p>
- * @param v1 first vector
- * @param v2 second vector
- * @return the distance between v1 and v2 according to the L<sub>1</sub> norm
- */
- public static double distance1(Coordinates3D v1, Coordinates3D v2) {
- return v1.distance1(v2);
- }
-
- /** Compute the distance between two vectors according to the L<sub>2</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>v1.subtract(v2).getNorm()</code> except that no intermediate
- * vector is built</p>
- * @param v1 first vector
- * @param v2 second vector
- * @return the distance between v1 and v2 according to the L<sub>2</sub> norm
- */
- public static double distance(Coordinates3D v1, Coordinates3D v2) {
- return v1.distance(v2);
- }
-
- /** Compute the distance between two vectors according to the L<sub>∞</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>v1.subtract(v2).getNormInf()</code> except that no intermediate
- * vector is built</p>
- * @param v1 first vector
- * @param v2 second vector
- * @return the distance between v1 and v2 according to the L<sub>∞</sub> norm
- */
- public static double distanceInf(Coordinates3D v1, Coordinates3D v2) {
- return v1.distanceInf(v2);
- }
-
- /** Compute the square of the distance between two vectors.
- * <p>Calling this method is equivalent to calling:
- * <code>v1.subtract(v2).getNormSq()</code> except that no intermediate
- * vector is built</p>
- * @param v1 first vector
- * @param v2 second vector
- * @return the square of the distance between v1 and v2
- */
- public static double distanceSq(Coordinates3D v1, Coordinates3D v2) {
- return v1.distanceSq(v2);
- }
-
- /** Get a string representation of this vector.
- * @return a string representation of this vector
- */
- @Override
- public String toString() {
- return Vector3DFormat.getInstance().format(this);
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString(final NumberFormat format) {
- return new Vector3DFormat(format).format(this);
- }
-
-}
[08/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
Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
index 7df7277..36f0998 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
@@ -19,10 +19,11 @@ package org.apache.commons.math4.geometry.euclidean.twod;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
import org.apache.commons.math4.geometry.Point;
+import org.apache.commons.math4.geometry.Vector;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.Embedding;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
@@ -84,7 +85,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param tolerance tolerance below which points are considered identical
* @since 3.3
*/
- public Line(final Coordinates2D p1, final Coordinates2D p2, final double tolerance) {
+ public Line(final Cartesian2D p1, final Cartesian2D p2, final double tolerance) {
reset(p1, p2);
this.tolerance = tolerance;
}
@@ -95,7 +96,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param tolerance tolerance below which points are considered identical
* @since 3.3
*/
- public Line(final Coordinates2D p, final double angle, final double tolerance) {
+ public Line(final Cartesian2D p, final double angle, final double tolerance) {
reset(p, angle);
this.tolerance = tolerance;
}
@@ -143,7 +144,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param p1 first point
* @param p2 second point
*/
- public void reset(final Coordinates2D p1, final Coordinates2D p2) {
+ public void reset(final Cartesian2D p1, final Cartesian2D p2) {
unlinkReverse();
final double dx = p2.getX() - p1.getX();
final double dy = p2.getY() - p1.getY();
@@ -165,7 +166,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param p point belonging to the line
* @param alpha angle of the line with respect to abscissa axis
*/
- public void reset(final Coordinates2D p, final double alpha) {
+ public void reset(final Cartesian2D p, final double alpha) {
unlinkReverse();
this.angle = MathUtils.normalizeAngle(alpha, FastMath.PI);
cos = FastMath.cos(this.angle);
@@ -225,31 +226,48 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return (n-1)-dimension point of the sub-space corresponding to
* the specified space point
*/
-// public Coordinates1D toSubSpace(Vector<Euclidean2D> vector) {
-// return toSubSpace((Point<Euclidean2D>) vector);
-// }
+ public Cartesian1D toSubSpace(Vector<Euclidean2D> vector) {
+ return toSubSpace((Cartesian2D) vector);
+ }
/** Transform a sub-space point into a space point.
* @param vector (n-1)-dimension point of the sub-space
* @return n-dimension point of the space corresponding to the
* specified sub-space point
*/
-// public Coordinates2D toSpace(Vector<Euclidean1D> vector) {
-// return toSpace((Point<Euclidean1D>) vector);
-// }
+ public Cartesian2D toSpace(Vector<Euclidean1D> vector) {
+ return toSpace((Cartesian1D) vector);
+ }
/** {@inheritDoc} */
@Override
- public Coordinates1D toSubSpace(final Point<Euclidean2D> point) {
- Coordinates2D p2 = (Coordinates2D) point;
- return new Coordinates1D(MathArrays.linearCombination(cos, p2.getX(), sin, p2.getY()));
+ public Cartesian1D toSubSpace(final Point<Euclidean2D> point) {
+ return toSubSpace((Cartesian2D) point);
}
/** {@inheritDoc} */
@Override
- public Coordinates2D toSpace(final Point<Euclidean1D> point) {
- final double abscissa = ((Coordinates1D) point).getX();
- return new Coordinates2D(MathArrays.linearCombination(abscissa, cos, -originOffset, sin),
+ public Cartesian2D toSpace(final Point<Euclidean1D> point) {
+ return toSpace((Cartesian1D) point);
+ }
+
+ /** Transform a space point into a sub-space point.
+ * @param cartesian n-dimension point of the space
+ * @return (n-1)-dimension point of the sub-space corresponding to
+ * the specified space point
+ */
+ public Cartesian1D toSubSpace(final Cartesian2D cartesian) {
+ return new Cartesian1D(MathArrays.linearCombination(cos, cartesian.getX(), sin, cartesian.getY()));
+ }
+
+ /** Transform a sub-space point into a space point.
+ * @param cartesian (n-1)-dimension point of the sub-space
+ * @return n-dimension point of the space corresponding to the
+ * specified sub-space point
+ */
+ public Cartesian2D toSpace(Cartesian1D cartesian) {
+ final double abscissa = cartesian.getX();
+ return new Cartesian2D(MathArrays.linearCombination(abscissa, cos, -originOffset, sin),
MathArrays.linearCombination(abscissa, sin, originOffset, cos));
}
@@ -258,12 +276,12 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return intersection point of the instance and the other line
* or null if there are no intersection points
*/
- public Coordinates2D intersection(final Line other) {
+ public Cartesian2D intersection(final Line other) {
final double d = MathArrays.linearCombination(sin, other.cos, -other.sin, cos);
if (FastMath.abs(d) < tolerance) {
return null;
}
- return new Coordinates2D(MathArrays.linearCombination(cos, other.originOffset, -other.cos, originOffset) / d,
+ return new Cartesian2D(MathArrays.linearCombination(cos, other.originOffset, -other.cos, originOffset) / d,
MathArrays.linearCombination(sin, other.originOffset, -other.sin, originOffset) / d);
}
@@ -317,15 +335,22 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param vector vector to check
* @return offset of the vector
*/
-// public double getOffset(Vector<Euclidean2D> vector) {
-// return getOffset((Point<Euclidean2D>) vector);
-// }
+ public double getOffset(Vector<Euclidean2D> vector) {
+ return getOffset((Cartesian2D) vector);
+ }
/** {@inheritDoc} */
@Override
public double getOffset(final Point<Euclidean2D> point) {
- Coordinates2D p2 = (Coordinates2D) point;
- return MathArrays.linearCombination(sin, p2.getX(), -cos, p2.getY(), 1.0, originOffset);
+ return getOffset((Cartesian2D) point);
+ }
+
+ /** Get the offset (oriented distance) of a point.
+ * @param cartesian point to check
+ * @return offset of the point
+ */
+ public double getOffset(Cartesian2D cartesian) {
+ return MathArrays.linearCombination(sin, cartesian.getX(), -cos, cartesian.getY(), 1.0, originOffset);
}
/** {@inheritDoc} */
@@ -341,10 +366,10 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return one point in the plane, with given abscissa and offset
* relative to the line
*/
- public Coordinates2D getPointAt(final Coordinates1D abscissa, final double offset) {
+ public Cartesian2D getPointAt(final Cartesian1D abscissa, final double offset) {
final double x = abscissa.getX();
final double dOffset = offset - originOffset;
- return new Coordinates2D(MathArrays.linearCombination(x, cos, dOffset, sin),
+ return new Cartesian2D(MathArrays.linearCombination(x, cos, dOffset, sin),
MathArrays.linearCombination(x, sin, -dOffset, cos));
}
@@ -352,7 +377,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param p point to check
* @return true if p belongs to the line
*/
- public boolean contains(final Coordinates2D p) {
+ public boolean contains(final Cartesian2D p) {
return FastMath.abs(getOffset(p)) < tolerance;
}
@@ -365,7 +390,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return distance between the instance and the point
* @since 3.1
*/
- public double distance(final Coordinates2D p) {
+ public double distance(final Cartesian2D p) {
return FastMath.abs(getOffset(p));
}
@@ -381,7 +406,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
/** Translate the line to force it passing by a point.
* @param p point by which the line should pass
*/
- public void translateToPoint(final Coordinates2D p) {
+ public void translateToPoint(final Cartesian2D p) {
originOffset = MathArrays.linearCombination(cos, p.getY(), -sin, p.getX());
}
@@ -426,7 +451,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param cX1 transform addendum for output abscissa
* @param cY1 transform addendum for output ordinate
* @return a new transform that can be applied to either {@link
- * Coordinates2D Vector2D}, {@link Line Line} or {@link
+ * Cartesian2D}, {@link Line Line} or {@link
* org.apache.commons.math4.geometry.partitioning.SubHyperplane
* SubHyperplane} instances
* @exception MathIllegalArgumentException if the transform is non invertible
@@ -511,11 +536,11 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
/** {@inheritDoc} */
@Override
- public Coordinates2D apply(final Point<Euclidean2D> point) {
- final Coordinates2D p2D = (Coordinates2D) point;
+ public Cartesian2D apply(final Point<Euclidean2D> point) {
+ final Cartesian2D p2D = (Cartesian2D) point;
final double x = p2D.getX();
final double y = p2D.getY();
- return new Coordinates2D(MathArrays.linearCombination(cXX, x, cXY, y, cX1, 1),
+ return new Cartesian2D(MathArrays.linearCombination(cXX, x, cXY, y, cX1, 1),
MathArrays.linearCombination(cYX, x, cYY, y, cY1, 1));
}
@@ -540,7 +565,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
final OrientedPoint op = (OrientedPoint) sub.getHyperplane();
final Line originalLine = (Line) original;
final Line transformedLine = (Line) transformed;
- final Coordinates1D newLoc =
+ final Cartesian1D newLoc =
transformedLine.toSubSpace(apply(originalLine.toSpace(op.getLocation())));
return new OrientedPoint(newLoc, op.isDirect(), originalLine.tolerance).wholeHyperplane();
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
index 5affbfc..3a5038e 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
@@ -48,7 +48,7 @@ import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
class NestedLoops {
/** Boundary loop. */
- private Coordinates2D[] loop;
+ private Cartesian2D[] loop;
/** Surrounded loops. */
private List<NestedLoops> surrounded;
@@ -82,7 +82,7 @@ class NestedLoops {
* @exception MathIllegalArgumentException if an outline has an open boundary loop
* @since 3.3
*/
- private NestedLoops(final Coordinates2D[] loop, final double tolerance)
+ private NestedLoops(final Cartesian2D[] loop, final double tolerance)
throws MathIllegalArgumentException {
if (loop[0] == null) {
@@ -95,9 +95,9 @@ class NestedLoops {
// build the polygon defined by the loop
final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>();
- Coordinates2D current = loop[loop.length - 1];
+ Cartesian2D current = loop[loop.length - 1];
for (int i = 0; i < loop.length; ++i) {
- final Coordinates2D previous = current;
+ final Cartesian2D previous = current;
current = loop[i];
final Line line = new Line(previous, current, tolerance);
final IntervalsSet region =
@@ -123,7 +123,7 @@ class NestedLoops {
* @exception MathIllegalArgumentException if an outline has crossing
* boundary loops or open boundary loops
*/
- public void add(final Coordinates2D[] bLoop) throws MathIllegalArgumentException {
+ public void add(final Cartesian2D[] bLoop) throws MathIllegalArgumentException {
add(new NestedLoops(bLoop, tolerance));
}
@@ -185,7 +185,7 @@ class NestedLoops {
int min = -1;
int max = loop.length;
while (++min < --max) {
- final Coordinates2D tmp = loop[min];
+ final Cartesian2D tmp = loop[min];
loop[min] = loop[max];
loop[max] = tmp;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
index eb2d66a..87e81bc 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.Interval;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.AbstractRegion;
import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
@@ -42,7 +42,7 @@ import org.apache.commons.math4.util.Precision;
public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
/** Vertices organized as boundary loops. */
- private Coordinates2D[][] vertices;
+ private Cartesian2D[][] vertices;
/** Build a polygons set representing the whole plane.
* @param tolerance tolerance below which points are considered identical
@@ -147,7 +147,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* belong to the hyperplane (which is therefore more a slab)
* @param vertices vertices of the simple loop boundary
*/
- public PolygonsSet(final double hyperplaneThickness, final Coordinates2D ... vertices) {
+ public PolygonsSet(final double hyperplaneThickness, final Cartesian2D ... vertices) {
super(verticesToTree(hyperplaneThickness, vertices), hyperplaneThickness);
}
@@ -166,10 +166,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
// too thin box, build an empty polygons set
return null;
}
- final Coordinates2D minMin = new Coordinates2D(xMin, yMin);
- final Coordinates2D minMax = new Coordinates2D(xMin, yMax);
- final Coordinates2D maxMin = new Coordinates2D(xMax, yMin);
- final Coordinates2D maxMax = new Coordinates2D(xMax, yMax);
+ final Cartesian2D minMin = new Cartesian2D(xMin, yMin);
+ final Cartesian2D minMax = new Cartesian2D(xMin, yMax);
+ final Cartesian2D maxMin = new Cartesian2D(xMax, yMin);
+ final Cartesian2D maxMax = new Cartesian2D(xMax, yMax);
return new Line[] {
new Line(minMin, maxMin, tolerance),
new Line(maxMin, maxMax, tolerance),
@@ -194,7 +194,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* @return the BSP tree of the input vertices
*/
private static BSPTree<Euclidean2D> verticesToTree(final double hyperplaneThickness,
- final Coordinates2D ... vertices) {
+ final Cartesian2D ... vertices) {
final int n = vertices.length;
if (n == 0) {
@@ -347,7 +347,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
private static class Vertex {
/** Vertex location. */
- private final Coordinates2D location;
+ private final Cartesian2D location;
/** Incoming edge. */
private Edge incoming;
@@ -361,7 +361,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
/** Build a non-processed vertex not owned by any node yet.
* @param location vertex location
*/
- Vertex(final Coordinates2D location) {
+ Vertex(final Cartesian2D location) {
this.location = location;
this.incoming = null;
this.outgoing = null;
@@ -371,7 +371,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
/** Get Vertex location.
* @return vertex location
*/
- public Coordinates2D getLocation() {
+ public Cartesian2D getLocation() {
return location;
}
@@ -543,22 +543,22 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
@Override
protected void computeGeometricalProperties() {
- final Coordinates2D[][] v = getVertices();
+ final Cartesian2D[][] v = getVertices();
if (v.length == 0) {
final BSPTree<Euclidean2D> tree = getTree(false);
if (tree.getCut() == null && (Boolean) tree.getAttribute()) {
// the instance covers the whole space
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean2D>) Coordinates2D.NaN);
+ setBarycenter((Point<Euclidean2D>) Cartesian2D.NaN);
} else {
setSize(0);
- setBarycenter((Point<Euclidean2D>) new Coordinates2D(0, 0));
+ setBarycenter((Point<Euclidean2D>) new Cartesian2D(0, 0));
}
} else if (v[0][0] == null) {
// there is at least one open-loop: the polygon is infinite
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean2D>) Coordinates2D.NaN);
+ setBarycenter((Point<Euclidean2D>) Cartesian2D.NaN);
} else {
// all loops are closed, we compute some integrals around the shape
@@ -566,10 +566,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
double sumX = 0;
double sumY = 0;
- for (Coordinates2D[] loop : v) {
+ for (Cartesian2D[] loop : v) {
double x1 = loop[loop.length - 1].getX();
double y1 = loop[loop.length - 1].getY();
- for (final Coordinates2D point : loop) {
+ for (final Cartesian2D point : loop) {
final double x0 = x1;
final double y0 = y1;
x1 = point.getX();
@@ -584,10 +584,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
if (sum < 0) {
// the polygon as a finite outside surrounded by an infinite inside
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean2D>) Coordinates2D.NaN);
+ setBarycenter((Point<Euclidean2D>) Cartesian2D.NaN);
} else {
setSize(sum / 2);
- setBarycenter((Point<Euclidean2D>) new Coordinates2D(sumX / (3 * sum), sumY / (3 * sum)));
+ setBarycenter((Point<Euclidean2D>) new Cartesian2D(sumX / (3 * sum), sumY / (3 * sum)));
}
}
@@ -617,10 +617,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* loops with the open loops first (the returned value is guaranteed
* to be non-null)
*/
- public Coordinates2D[][] getVertices() {
+ public Cartesian2D[][] getVertices() {
if (vertices == null) {
if (getTree(false).getCut() == null) {
- vertices = new Coordinates2D[0][];
+ vertices = new Cartesian2D[0][];
} else {
// build the unconnected segments
@@ -655,7 +655,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
}
// transform the loops in an array of arrays of points
- vertices = new Coordinates2D[loops.size()][];
+ vertices = new Cartesian2D[loops.size()][];
int i = 0;
for (final List<Segment> loop : loops) {
@@ -663,23 +663,23 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
(loop.size() == 2 && loop.get(0).getStart() == null && loop.get(1).getEnd() == null)) {
// single infinite line
final Line line = loop.get(0).getLine();
- vertices[i++] = new Coordinates2D[] {
+ vertices[i++] = new Cartesian2D[] {
null,
- line.toSpace((Point<Euclidean1D>) new Coordinates1D(-Float.MAX_VALUE)),
- line.toSpace((Point<Euclidean1D>) new Coordinates1D(+Float.MAX_VALUE))
+ line.toSpace(new Cartesian1D(-Float.MAX_VALUE)),
+ line.toSpace(new Cartesian1D(+Float.MAX_VALUE))
};
} else if (loop.get(0).getStart() == null) {
// open loop with at least one real point
- final Coordinates2D[] array = new Coordinates2D[loop.size() + 2];
+ final Cartesian2D[] array = new Cartesian2D[loop.size() + 2];
int j = 0;
for (Segment segment : loop) {
if (j == 0) {
// null point and first dummy point
- double x = segment.getLine().toSubSpace((Point<Euclidean2D>) segment.getEnd()).getX();
+ double x = segment.getLine().toSubSpace(segment.getEnd()).getX();
x -= FastMath.max(1.0, FastMath.abs(x / 2));
array[j++] = null;
- array[j++] = segment.getLine().toSpace((Point<Euclidean1D>) new Coordinates1D(x));
+ array[j++] = segment.getLine().toSpace(new Cartesian1D(x));
}
if (j < (array.length - 1)) {
@@ -689,15 +689,15 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
if (j == (array.length - 1)) {
// last dummy point
- double x = segment.getLine().toSubSpace((Point<Euclidean2D>) segment.getStart()).getX();
+ double x = segment.getLine().toSubSpace(segment.getStart()).getX();
x += FastMath.max(1.0, FastMath.abs(x / 2));
- array[j++] = segment.getLine().toSpace((Point<Euclidean1D>) new Coordinates1D(x));
+ array[j++] = segment.getLine().toSpace(new Cartesian1D(x));
}
}
vertices[i++] = array;
} else {
- final Coordinates2D[] array = new Coordinates2D[loop.size()];
+ final Cartesian2D[] array = new Cartesian2D[loop.size()];
int j = 0;
for (Segment segment : loop) {
array[j++] = segment.getStart();
@@ -777,12 +777,12 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
int connected = 0;
for (final ConnectableSegment segment : segments) {
if (segment.getNext() == null && segment.getEnd() != null) {
- final Coordinates2D end = segment.getEnd();
+ final Cartesian2D end = segment.getEnd();
ConnectableSegment selectedNext = null;
double min = Double.POSITIVE_INFINITY;
for (final ConnectableSegment candidateNext : segments) {
if (candidateNext.getPrevious() == null && candidateNext.getStart() != null) {
- final double distance = Coordinates2D.distance(end, candidateNext.getStart());
+ final double distance = Cartesian2D.distance(end, candidateNext.getStart());
if (distance < min) {
selectedNext = candidateNext;
min = distance;
@@ -906,7 +906,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* @param startNode node whose intersection with current node defines start point
* @param endNode node whose intersection with current node defines end point
*/
- ConnectableSegment(final Coordinates2D start, final Coordinates2D end, final Line line,
+ ConnectableSegment(final Cartesian2D start, final Cartesian2D end, final Line line,
final BSPTree<Euclidean2D> node,
final BSPTree<Euclidean2D> startNode,
final BSPTree<Euclidean2D> endNode) {
@@ -1044,10 +1044,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
for (final Interval i : intervals) {
// find the 2D points
- final Coordinates2D startV = Double.isInfinite(i.getInf()) ?
- null : (Coordinates2D) line.toSpace((Point<Euclidean1D>) new Coordinates1D(i.getInf()));
- final Coordinates2D endV = Double.isInfinite(i.getSup()) ?
- null : (Coordinates2D) line.toSpace((Point<Euclidean1D>) new Coordinates1D(i.getSup()));
+ final Cartesian2D startV = Double.isInfinite(i.getInf()) ?
+ null : line.toSpace(new Cartesian1D(i.getInf()));
+ final Cartesian2D endV = Double.isInfinite(i.getSup()) ?
+ null : line.toSpace(new Cartesian1D(i.getSup()));
// recover the connectivity information
final BSPTree<Euclidean2D> startN = selectClosest(startV, splitters);
@@ -1069,7 +1069,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* @param candidates candidate nodes
* @return node closest to point, or null if no node is closer than tolerance
*/
- private BSPTree<Euclidean2D> selectClosest(final Coordinates2D point, final Iterable<BSPTree<Euclidean2D>> candidates) {
+ private BSPTree<Euclidean2D> selectClosest(final Cartesian2D point, final Iterable<BSPTree<Euclidean2D>> candidates) {
BSPTree<Euclidean2D> selected = null;
double min = Double.POSITIVE_INFINITY;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
index 2e48541..70ce579 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
@@ -25,10 +25,10 @@ import org.apache.commons.math4.util.FastMath;
public class Segment {
/** Start point of the segment. */
- private final Coordinates2D start;
+ private final Cartesian2D start;
/** End point of the segment. */
- private final Coordinates2D end;
+ private final Cartesian2D end;
/** Line containing the segment. */
private final Line line;
@@ -38,7 +38,7 @@ public class Segment {
* @param end end point of the segment
* @param line line containing the segment
*/
- public Segment(final Coordinates2D start, final Coordinates2D end, final Line line) {
+ public Segment(final Cartesian2D start, final Cartesian2D end, final Line line) {
this.start = start;
this.end = end;
this.line = line;
@@ -47,14 +47,14 @@ public class Segment {
/** Get the start point of the segment.
* @return start point of the segment
*/
- public Coordinates2D getStart() {
+ public Cartesian2D getStart() {
return start;
}
/** Get the end point of the segment.
* @return end point of the segment
*/
- public Coordinates2D getEnd() {
+ public Cartesian2D getEnd() {
return end;
}
@@ -80,7 +80,7 @@ public class Segment {
* @return distance between the instance and the point
* @since 3.1
*/
- public double distance(final Coordinates2D p) {
+ public double distance(final Cartesian2D p) {
final double deltaX = end.getX() - start.getX();
final double deltaY = end.getY() - start.getY();
@@ -105,7 +105,7 @@ public class Segment {
final double px = start.getX() + r * deltaX;
final double py = start.getY() + r * deltaY;
- final Coordinates2D interPt = new Coordinates2D(px, py);
+ final Cartesian2D interPt = new Cartesian2D(px, py);
return interPt.distance((Point<Euclidean2D>) p);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
index c7c0530..ae66659 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.Interval;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
@@ -53,7 +53,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
* @param tolerance tolerance below which points are considered identical
* @since 3.3
*/
- public SubLine(final Coordinates2D start, final Coordinates2D end, final double tolerance) {
+ public SubLine(final Cartesian2D start, final Cartesian2D end, final double tolerance) {
super(new Line(start, end, tolerance), buildIntervalSet(start, end, tolerance));
}
@@ -86,8 +86,8 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
final List<Segment> segments = new ArrayList<>(list.size());
for (final Interval interval : list) {
- final Coordinates2D start = line.toSpace((Point<Euclidean1D>) new Coordinates1D(interval.getInf()));
- final Coordinates2D end = line.toSpace((Point<Euclidean1D>) new Coordinates1D(interval.getSup()));
+ final Cartesian2D start = line.toSpace(new Cartesian1D(interval.getInf()));
+ final Cartesian2D end = line.toSpace(new Cartesian1D(interval.getSup()));
segments.add(new Segment(start, end, line));
}
@@ -109,14 +109,14 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
* occurring on endpoints lead to null being returned
* @return the intersection point if there is one, null if the sub-lines don't intersect
*/
- public Coordinates2D intersection(final SubLine subLine, final boolean includeEndPoints) {
+ public Cartesian2D intersection(final SubLine subLine, final boolean includeEndPoints) {
// retrieve the underlying lines
Line line1 = (Line) getHyperplane();
Line line2 = (Line) subLine.getHyperplane();
// compute the intersection on infinite line
- Coordinates2D v2D = line1.intersection(line2);
+ Cartesian2D v2D = line1.intersection(line2);
if (v2D == null) {
return null;
}
@@ -141,7 +141,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
* @param tolerance tolerance below which points are considered identical
* @return an interval set
*/
- private static IntervalsSet buildIntervalSet(final Coordinates2D start, final Coordinates2D end, final double tolerance) {
+ private static IntervalsSet buildIntervalSet(final Cartesian2D start, final Cartesian2D end, final double tolerance) {
final Line line = new Line(start, end, tolerance);
return new IntervalsSet(line.toSubSpace(start).getX(),
line.toSubSpace(end).getX(),
@@ -161,7 +161,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
final Line thisLine = (Line) getHyperplane();
final Line otherLine = (Line) hyperplane;
- final Coordinates2D crossing = thisLine.intersection(otherLine);
+ final Cartesian2D crossing = thisLine.intersection(otherLine);
final double tolerance = thisLine.getTolerance();
if (crossing == null) {
@@ -178,7 +178,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
// the lines do intersect
final boolean direct = FastMath.sin(thisLine.getAngle() - otherLine.getAngle()) < 0;
- final Coordinates1D x = thisLine.toSubSpace((Point<Euclidean2D>) crossing);
+ final Cartesian1D x = thisLine.toSubSpace(crossing);
final SubHyperplane<Euclidean1D> subPlus =
new OrientedPoint(x, !direct, tolerance).wholeHyperplane();
final SubHyperplane<Euclidean1D> subMinus =
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
index 04e825b..936450a 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
@@ -108,31 +108,31 @@ public class Vector2DFormat extends VectorFormat<Euclidean2D> {
@Override
public StringBuffer format(final Vector<Euclidean2D> vector, final StringBuffer toAppendTo,
final FieldPosition pos) {
- final Coordinates2D p2 = (Coordinates2D) vector;
+ final Cartesian2D p2 = (Cartesian2D) vector;
return format(toAppendTo, pos, p2.getX(), p2.getY());
}
/** {@inheritDoc} */
@Override
- public Coordinates2D parse(final String source) throws MathParseException {
+ public Cartesian2D parse(final String source) throws MathParseException {
ParsePosition parsePosition = new ParsePosition(0);
- Coordinates2D result = parse(source, parsePosition);
+ Cartesian2D result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw new MathParseException(source,
parsePosition.getErrorIndex(),
- Coordinates2D.class);
+ Cartesian2D.class);
}
return result;
}
/** {@inheritDoc} */
@Override
- public Coordinates2D parse(final String source, final ParsePosition pos) {
+ public Cartesian2D parse(final String source, final ParsePosition pos) {
final double[] coordinates = parseCoordinates(2, source, pos);
if (coordinates == null) {
return null;
}
- return new Coordinates2D(coordinates[0], coordinates[1]);
+ return new Cartesian2D(coordinates[0], coordinates[1]);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
index 38b5b4a..d3ecc64 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
@@ -21,7 +21,7 @@ import java.util.Collection;
import org.apache.commons.math4.exception.ConvergenceException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.MathUtils;
/**
@@ -86,12 +86,12 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
/** {@inheritDoc} */
@Override
- public ConvexHull2D generate(final Collection<Coordinates2D> points)
+ public ConvexHull2D generate(final Collection<Cartesian2D> points)
throws NullArgumentException, ConvergenceException {
// check for null points
MathUtils.checkNotNull(points);
- Collection<Coordinates2D> hullVertices = null;
+ Collection<Cartesian2D> hullVertices = null;
if (points.size() < 2) {
hullVertices = points;
} else {
@@ -99,7 +99,7 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
}
try {
- return new ConvexHull2D(hullVertices.toArray(new Coordinates2D[hullVertices.size()]),
+ return new ConvexHull2D(hullVertices.toArray(new Cartesian2D[hullVertices.size()]),
tolerance);
} catch (MathIllegalArgumentException e) {
// the hull vertices may not form a convex hull if the tolerance value is to large
@@ -112,6 +112,6 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
* @param points the set of input points
* @return the convex hull vertices in CCW winding
*/
- protected abstract Collection<Coordinates2D> findHullVertices(Collection<Coordinates2D> points);
+ protected abstract Collection<Cartesian2D> findHullVertices(Collection<Cartesian2D> points);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
index 49c399f..e1d5009 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
/**
* A simple heuristic to improve the performance of convex hull algorithms.
@@ -50,15 +50,15 @@ public final class AklToussaintHeuristic {
* @param points the original point set
* @return a reduced point set, useful as input for convex hull algorithms
*/
- public static Collection<Coordinates2D> reducePoints(final Collection<Coordinates2D> points) {
+ public static Collection<Cartesian2D> reducePoints(final Collection<Cartesian2D> points) {
// find the leftmost point
int size = 0;
- Coordinates2D minX = null;
- Coordinates2D maxX = null;
- Coordinates2D minY = null;
- Coordinates2D maxY = null;
- for (Coordinates2D p : points) {
+ Cartesian2D minX = null;
+ Cartesian2D maxX = null;
+ Cartesian2D minY = null;
+ Cartesian2D maxY = null;
+ for (Cartesian2D p : points) {
if (minX == null || p.getX() < minX.getX()) {
minX = p;
}
@@ -78,14 +78,14 @@ public final class AklToussaintHeuristic {
return points;
}
- final List<Coordinates2D> quadrilateral = buildQuadrilateral(minY, maxX, maxY, minX);
+ final List<Cartesian2D> quadrilateral = buildQuadrilateral(minY, maxX, maxY, minX);
// if the quadrilateral is not well formed, e.g. only 2 points, do not attempt to reduce
if (quadrilateral.size() < 3) {
return points;
}
- final List<Coordinates2D> reducedPoints = new ArrayList<>(quadrilateral);
- for (final Coordinates2D p : points) {
+ final List<Cartesian2D> reducedPoints = new ArrayList<>(quadrilateral);
+ for (final Cartesian2D p : points) {
// check all points if they are within the quadrilateral
// in which case they can not be part of the convex hull
if (!insideQuadrilateral(p, quadrilateral)) {
@@ -102,9 +102,9 @@ public final class AklToussaintHeuristic {
* @param points the respective points with min/max x/y coordinate
* @return the quadrilateral
*/
- private static List<Coordinates2D> buildQuadrilateral(final Coordinates2D... points) {
- List<Coordinates2D> quadrilateral = new ArrayList<>();
- for (Coordinates2D p : points) {
+ private static List<Cartesian2D> buildQuadrilateral(final Cartesian2D... points) {
+ List<Cartesian2D> quadrilateral = new ArrayList<>();
+ for (Cartesian2D p : points) {
if (!quadrilateral.contains(p)) {
quadrilateral.add(p);
}
@@ -118,11 +118,11 @@ public final class AklToussaintHeuristic {
* @param quadrilateralPoints the convex quadrilateral, represented by 4 points
* @return {@code true} if the point is inside the quadrilateral, {@code false} otherwise
*/
- private static boolean insideQuadrilateral(final Coordinates2D point,
- final List<Coordinates2D> quadrilateralPoints) {
+ private static boolean insideQuadrilateral(final Cartesian2D point,
+ final List<Cartesian2D> quadrilateralPoints) {
- Coordinates2D p1 = quadrilateralPoints.get(0);
- Coordinates2D p2 = quadrilateralPoints.get(1);
+ Cartesian2D p1 = quadrilateralPoints.get(0);
+ Cartesian2D p2 = quadrilateralPoints.get(1);
if (point.equals(p1) || point.equals(p2)) {
return true;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
index 801f4d7..425cd67 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
import org.apache.commons.math4.geometry.euclidean.twod.Line;
import org.apache.commons.math4.geometry.euclidean.twod.Segment;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.hull.ConvexHull;
import org.apache.commons.math4.geometry.partitioning.Region;
import org.apache.commons.math4.geometry.partitioning.RegionFactory;
@@ -36,13 +36,13 @@ import org.apache.commons.math4.util.Precision;
*
* @since 3.3
*/
-public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Serializable {
+public class ConvexHull2D implements ConvexHull<Euclidean2D, Cartesian2D>, Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20140129L;
/** Vertices of the hull. */
- private final Coordinates2D[] vertices;
+ private final Cartesian2D[] vertices;
/** Tolerance threshold used during creation of the hull vertices. */
private final double tolerance;
@@ -59,7 +59,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
* @param tolerance tolerance below which points are considered identical
* @throws MathIllegalArgumentException if the vertices do not form a convex hull
*/
- public ConvexHull2D(final Coordinates2D[] vertices, final double tolerance)
+ public ConvexHull2D(final Cartesian2D[] vertices, final double tolerance)
throws MathIllegalArgumentException {
// assign tolerance as it will be used by the isConvex method
@@ -77,19 +77,19 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
* @param hullVertices the hull vertices
* @return {@code true} if the vertices form a convex hull, {@code false} otherwise
*/
- private boolean isConvex(final Coordinates2D[] hullVertices) {
+ private boolean isConvex(final Cartesian2D[] hullVertices) {
if (hullVertices.length < 3) {
return true;
}
int sign = 0;
for (int i = 0; i < hullVertices.length; i++) {
- final Coordinates2D p1 = hullVertices[i == 0 ? hullVertices.length - 1 : i - 1];
- final Coordinates2D p2 = hullVertices[i];
- final Coordinates2D p3 = hullVertices[i == hullVertices.length - 1 ? 0 : i + 1];
+ final Cartesian2D p1 = hullVertices[i == 0 ? hullVertices.length - 1 : i - 1];
+ final Cartesian2D p2 = hullVertices[i];
+ final Cartesian2D p3 = hullVertices[i == hullVertices.length - 1 ? 0 : i + 1];
- final Coordinates2D d1 = p2.subtract(p1);
- final Coordinates2D d2 = p3.subtract(p2);
+ final Cartesian2D d1 = p2.subtract(p1);
+ final Cartesian2D d2 = p3.subtract(p2);
final double crossProduct = MathArrays.linearCombination(d1.getX(), d2.getY(), -d1.getY(), d2.getX());
final int cmp = Precision.compareTo(crossProduct, 0.0, tolerance);
@@ -107,7 +107,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
/** {@inheritDoc} */
@Override
- public Coordinates2D[] getVertices() {
+ public Cartesian2D[] getVertices() {
return vertices.clone();
}
@@ -132,15 +132,15 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
this.lineSegments = new Segment[0];
} else if (size == 2) {
this.lineSegments = new Segment[1];
- final Coordinates2D p1 = vertices[0];
- final Coordinates2D p2 = vertices[1];
+ final Cartesian2D p1 = vertices[0];
+ final Cartesian2D p2 = vertices[1];
this.lineSegments[0] = new Segment(p1, p2, new Line(p1, p2, tolerance));
} else {
this.lineSegments = new Segment[size];
- Coordinates2D firstPoint = null;
- Coordinates2D lastPoint = null;
+ Cartesian2D firstPoint = null;
+ Cartesian2D lastPoint = null;
int index = 0;
- for (Coordinates2D point : vertices) {
+ for (Cartesian2D point : vertices) {
if (lastPoint == null) {
firstPoint = point;
lastPoint = point;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
index 310cb0d..0c49b91 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
@@ -21,7 +21,7 @@ import java.util.Collection;
import org.apache.commons.math4.exception.ConvergenceException;
import org.apache.commons.math4.exception.NullArgumentException;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.hull.ConvexHullGenerator;
/**
@@ -29,10 +29,10 @@ import org.apache.commons.math4.geometry.hull.ConvexHullGenerator;
*
* @since 3.3
*/
-public interface ConvexHullGenerator2D extends ConvexHullGenerator<Euclidean2D, Coordinates2D> {
+public interface ConvexHullGenerator2D extends ConvexHullGenerator<Euclidean2D, Cartesian2D> {
/** {@inheritDoc} */
@Override
- ConvexHull2D generate(Collection<Coordinates2D> points) throws NullArgumentException, ConvergenceException;
+ ConvexHull2D generate(Collection<Cartesian2D> points) throws NullArgumentException, ConvergenceException;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
index 08d27f8..42cbc33 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
@@ -23,7 +23,7 @@ import java.util.Comparator;
import java.util.List;
import org.apache.commons.math4.geometry.euclidean.twod.Line;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
@@ -75,15 +75,15 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
/** {@inheritDoc} */
@Override
- public Collection<Coordinates2D> findHullVertices(final Collection<Coordinates2D> points) {
+ public Collection<Cartesian2D> findHullVertices(final Collection<Cartesian2D> points) {
- final List<Coordinates2D> pointsSortedByXAxis = new ArrayList<>(points);
+ final List<Cartesian2D> pointsSortedByXAxis = new ArrayList<>(points);
// sort the points in increasing order on the x-axis
- Collections.sort(pointsSortedByXAxis, new Comparator<Coordinates2D>() {
+ Collections.sort(pointsSortedByXAxis, new Comparator<Cartesian2D>() {
/** {@inheritDoc} */
@Override
- public int compare(final Coordinates2D o1, final Coordinates2D o2) {
+ public int compare(final Cartesian2D o1, final Cartesian2D o2) {
final double tolerance = getTolerance();
// need to take the tolerance value into account, otherwise collinear points
// will not be handled correctly when building the upper/lower hull
@@ -97,21 +97,21 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
});
// build lower hull
- final List<Coordinates2D> lowerHull = new ArrayList<>();
- for (Coordinates2D p : pointsSortedByXAxis) {
+ final List<Cartesian2D> lowerHull = new ArrayList<>();
+ for (Cartesian2D p : pointsSortedByXAxis) {
updateHull(p, lowerHull);
}
// build upper hull
- final List<Coordinates2D> upperHull = new ArrayList<>();
+ final List<Cartesian2D> upperHull = new ArrayList<>();
for (int idx = pointsSortedByXAxis.size() - 1; idx >= 0; idx--) {
- final Coordinates2D p = pointsSortedByXAxis.get(idx);
+ final Cartesian2D p = pointsSortedByXAxis.get(idx);
updateHull(p, upperHull);
}
// concatenate the lower and upper hulls
// the last point of each list is omitted as it is repeated at the beginning of the other list
- final List<Coordinates2D> hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2);
+ final List<Cartesian2D> hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2);
for (int idx = 0; idx < lowerHull.size() - 1; idx++) {
hullVertices.add(lowerHull.get(idx));
}
@@ -133,12 +133,12 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
* @param point the current point
* @param hull the partial hull
*/
- private void updateHull(final Coordinates2D point, final List<Coordinates2D> hull) {
+ private void updateHull(final Cartesian2D point, final List<Cartesian2D> hull) {
final double tolerance = getTolerance();
if (hull.size() == 1) {
// ensure that we do not add an identical point
- final Coordinates2D p1 = hull.get(0);
+ final Cartesian2D p1 = hull.get(0);
if (p1.distance(point) < tolerance) {
return;
}
@@ -146,8 +146,8 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
while (hull.size() >= 2) {
final int size = hull.size();
- final Coordinates2D p1 = hull.get(size - 2);
- final Coordinates2D p2 = hull.get(size - 1);
+ final Cartesian2D p1 = hull.get(size - 2);
+ final Cartesian2D p2 = hull.get(size - 1);
final double offset = new Line(p1, p2, tolerance).getOffset(point);
if (FastMath.abs(offset) < tolerance) {
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
index 841d1db..d57d02c 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.spherical.oned;
import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -30,7 +30,7 @@ public class S1Point implements Point<Sphere1D> {
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final S1Point NaN = new S1Point(Double.NaN, Coordinates2D.NaN);
+ public static final S1Point NaN = new S1Point(Double.NaN, Cartesian2D.NaN);
// CHECKSTYLE: resume ConstantName
/** Serializable UID. */
@@ -40,7 +40,7 @@ public class S1Point implements Point<Sphere1D> {
private final double alpha;
/** Corresponding 2D normalized vector. */
- private final Coordinates2D vector;
+ private final Cartesian2D vector;
/** Simple constructor.
* Build a vector from its coordinates
@@ -49,14 +49,14 @@ public class S1Point implements Point<Sphere1D> {
*/
public S1Point(final double alpha) {
this(MathUtils.normalizeAngle(alpha, FastMath.PI),
- new Coordinates2D(FastMath.cos(alpha), FastMath.sin(alpha)));
+ new Cartesian2D(FastMath.cos(alpha), FastMath.sin(alpha)));
}
/** Build a point from its internal components.
* @param alpha azimuthal angle \( \alpha \)
* @param vector corresponding vector
*/
- private S1Point(final double alpha, final Coordinates2D vector) {
+ private S1Point(final double alpha, final Cartesian2D vector) {
this.alpha = alpha;
this.vector = vector;
}
@@ -72,7 +72,7 @@ public class S1Point implements Point<Sphere1D> {
/** Get the corresponding normalized vector in the 2D euclidean space.
* @return normalized vector
*/
- public Coordinates2D getVector() {
+ public Cartesian2D getVector() {
return vector;
}
@@ -100,7 +100,7 @@ public class S1Point implements Point<Sphere1D> {
* @return the angular separation between p1 and p2
*/
public static double distance(S1Point p1, S1Point p2) {
- return Coordinates2D.angle(p1.vector, p2.vector);
+ return Cartesian2D.angle(p1.vector, p2.vector);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
index 871f729..ab8c2c5 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.spherical.twod;
import org.apache.commons.math4.geometry.Point;
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.Embedding;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
@@ -45,13 +45,13 @@ import org.apache.commons.math4.util.FastMath;
public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1D> {
/** Pole or circle center. */
- private Coordinates3D pole;
+ private Cartesian3D pole;
/** First axis in the equator plane, origin of the phase angles. */
- private Coordinates3D x;
+ private Cartesian3D x;
/** Second axis in the equator plane, in quadrature with respect to x. */
- private Coordinates3D y;
+ private Cartesian3D y;
/** Tolerance below which close sub-arcs are merged together. */
private final double tolerance;
@@ -61,7 +61,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @param pole circle pole
* @param tolerance tolerance below which close sub-arcs are merged together
*/
- public Circle(final Coordinates3D pole, final double tolerance) {
+ public Circle(final Cartesian3D pole, final double tolerance) {
reset(pole);
this.tolerance = tolerance;
}
@@ -84,7 +84,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @param y second axis in the equator plane
* @param tolerance tolerance below which close sub-arcs are merged together
*/
- private Circle(final Coordinates3D pole, final Coordinates3D x, final Coordinates3D y,
+ private Circle(final Cartesian3D pole, final Cartesian3D x, final Cartesian3D y,
final double tolerance) {
this.pole = pole;
this.x = x;
@@ -111,10 +111,10 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* <p>The circle is oriented in the trigonometric direction around pole.</p>
* @param newPole circle pole
*/
- public void reset(final Coordinates3D newPole) {
+ public void reset(final Cartesian3D newPole) {
this.pole = newPole.normalize();
this.x = newPole.orthogonal();
- this.y = Coordinates3D.crossProduct(newPole, x).normalize();
+ this.y = Cartesian3D.crossProduct(newPole, x).normalize();
}
/** Revert the instance.
@@ -164,7 +164,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @return phase angle of the direction around the circle
* @see #toSubSpace(Point)
*/
- public double getPhase(final Coordinates3D direction) {
+ public double getPhase(final Cartesian3D direction) {
return FastMath.PI + FastMath.atan2(-direction.dotProduct(y), -direction.dotProduct(x));
}
@@ -183,8 +183,8 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getXAxis()
* @see #getYAxis()
*/
- public Coordinates3D getPointAt(final double alpha) {
- return new Coordinates3D(FastMath.cos(alpha), x, FastMath.sin(alpha), y);
+ public Cartesian3D getPointAt(final double alpha) {
+ return new Cartesian3D(FastMath.cos(alpha), x, FastMath.sin(alpha), y);
}
/** Get the X axis of the circle.
@@ -198,7 +198,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getYAxis()
* @see #getPole()
*/
- public Coordinates3D getXAxis() {
+ public Cartesian3D getXAxis() {
return x;
}
@@ -213,7 +213,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getXAxis()
* @see #getPole()
*/
- public Coordinates3D getYAxis() {
+ public Cartesian3D getYAxis() {
return y;
}
@@ -226,7 +226,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getXAxis()
* @see #getYAxis()
*/
- public Coordinates3D getPole() {
+ public Cartesian3D getPole() {
return pole;
}
@@ -272,15 +272,15 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @return offset of the direction
* @see #getOffset(Point)
*/
- public double getOffset(final Coordinates3D direction) {
- return Coordinates3D.angle(pole, direction) - 0.5 * FastMath.PI;
+ public double getOffset(final Cartesian3D direction) {
+ return Cartesian3D.angle(pole, direction) - 0.5 * FastMath.PI;
}
/** {@inheritDoc} */
@Override
public boolean sameOrientationAs(final Hyperplane<Sphere2D> other) {
final Circle otherC = (Circle) other;
- return Coordinates3D.dotProduct(pole, otherC.pole) >= 0.0;
+ return Cartesian3D.dotProduct(pole, otherC.pole) >= 0.0;
}
/** Get a {@link org.apache.commons.math4.geometry.partitioning.Transform
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
index 6fe2635..975407d 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.spherical.twod;
import java.util.List;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.geometry.spherical.oned.Arc;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -99,7 +99,7 @@ public class Edge {
* @param alpha angle along the edge, counted from {@link #getStart()}
* @return an intermediate point
*/
- public Coordinates3D getPointAt(final double alpha) {
+ public Cartesian3D getPointAt(final double alpha) {
return circle.getPointAt(alpha + circle.getPhase(start.getLocation().getVector()));
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
index 5e3f918..0c5d40f 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
@@ -23,7 +23,7 @@ import java.util.Map;
import org.apache.commons.math4.exception.MathIllegalStateException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-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.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor;
import org.apache.commons.math4.geometry.partitioning.BoundaryAttribute;
@@ -128,8 +128,8 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
for (final BSPTree<Sphere2D> node : candidates) {
for (final Edge edge : nodeToEdgesList.get(node)) {
if (edge != previous && edge.getStart().getIncoming() == null) {
- final Coordinates3D edgeStart = edge.getStart().getLocation().getVector();
- final double gap = Coordinates3D.angle(point.getVector(), edgeStart);
+ final Cartesian3D edgeStart = edge.getStart().getLocation().getVector();
+ final double gap = Cartesian3D.angle(point.getVector(), edgeStart);
if (gap <= closest) {
closest = gap;
following = edge;
@@ -139,8 +139,8 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
}
if (following == null) {
- final Coordinates3D previousStart = previous.getStart().getLocation().getVector();
- if (Coordinates3D.angle(point.getVector(), previousStart) <= tolerance) {
+ final Cartesian3D previousStart = previous.getStart().getLocation().getVector();
+ if (Cartesian3D.angle(point.getVector(), previousStart) <= tolerance) {
// the edge connects back to itself
return previous;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
index 4d61de1..d6a4f27 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math4.exception.MathInternalError;
-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.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor;
import org.apache.commons.math4.util.FastMath;
@@ -38,10 +38,10 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
private double summedArea;
/** Summed barycenter. */
- private Coordinates3D summedBarycenter;
+ private Cartesian3D summedBarycenter;
/** List of points strictly inside convex cells. */
- private final List<Coordinates3D> convexCellsInsidePoints;
+ private final List<Cartesian3D> convexCellsInsidePoints;
/** Simple constructor.
* @param tolerance below which points are consider to be identical
@@ -49,7 +49,7 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
PropertiesComputer(final double tolerance) {
this.tolerance = tolerance;
this.summedArea = 0;
- this.summedBarycenter = Coordinates3D.ZERO;
+ this.summedBarycenter = Cartesian3D.ZERO;
this.convexCellsInsidePoints = new ArrayList<>();
}
@@ -86,12 +86,12 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
// compute the geometrical properties of the convex cell
final double area = convexCellArea(boundary.get(0));
- final Coordinates3D barycenter = convexCellBarycenter(boundary.get(0));
+ final Cartesian3D barycenter = convexCellBarycenter(boundary.get(0));
convexCellsInsidePoints.add(barycenter);
// add the cell contribution to the global properties
summedArea += area;
- summedBarycenter = new Coordinates3D(1, summedBarycenter, area, barycenter);
+ summedBarycenter = new Cartesian3D(1, summedBarycenter, area, barycenter);
}
}
@@ -109,11 +109,11 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {
// find path interior angle at vertex
- final Coordinates3D previousPole = e.getCircle().getPole();
- final Coordinates3D nextPole = e.getEnd().getOutgoing().getCircle().getPole();
- final Coordinates3D point = e.getEnd().getLocation().getVector();
- double alpha = FastMath.atan2(Coordinates3D.dotProduct(nextPole, Coordinates3D.crossProduct(point, previousPole)),
- -Coordinates3D.dotProduct(nextPole, previousPole));
+ final Cartesian3D previousPole = e.getCircle().getPole();
+ final Cartesian3D nextPole = e.getEnd().getOutgoing().getCircle().getPole();
+ final Cartesian3D point = e.getEnd().getLocation().getVector();
+ double alpha = FastMath.atan2(Cartesian3D.dotProduct(nextPole, Cartesian3D.crossProduct(point, previousPole)),
+ -Cartesian3D.dotProduct(nextPole, previousPole));
if (alpha < 0) {
alpha += MathUtils.TWO_PI;
}
@@ -133,14 +133,14 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
* @param start start vertex of the convex cell boundary
* @return barycenter
*/
- private Coordinates3D convexCellBarycenter(final Vertex start) {
+ private Cartesian3D convexCellBarycenter(final Vertex start) {
int n = 0;
- Coordinates3D sumB = Coordinates3D.ZERO;
+ Cartesian3D sumB = Cartesian3D.ZERO;
// loop around the cell
for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {
- sumB = new Coordinates3D(1, sumB, e.getLength(), e.getCircle().getPole());
+ sumB = new Cartesian3D(1, sumB, e.getLength(), e.getCircle().getPole());
n++;
}
@@ -169,7 +169,7 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
/** Get the points strictly inside convex cells.
* @return points strictly inside convex cells
*/
- public List<Coordinates3D> getConvexCellsInsidePoints() {
+ public List<Cartesian3D> getConvexCellsInsidePoints() {
return convexCellsInsidePoints;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
index 58aea47..6931ac0 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
@@ -20,7 +20,7 @@ import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.exception.OutOfRangeException;
import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.Space;
-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;
@@ -38,26 +38,26 @@ import org.apache.commons.math4.util.MathUtils;
public class S2Point implements Point<Sphere2D> {
/** +I (coordinates: \( \theta = 0, \varphi = \pi/2 \)). */
- public static final S2Point PLUS_I = new S2Point(0, 0.5 * FastMath.PI, Coordinates3D.PLUS_I);
+ public static final S2Point PLUS_I = new S2Point(0, 0.5 * FastMath.PI, Cartesian3D.PLUS_I);
/** +J (coordinates: \( \theta = \pi/2, \varphi = \pi/2 \))). */
- public static final S2Point PLUS_J = new S2Point(0.5 * FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.PLUS_J);
+ public static final S2Point PLUS_J = new S2Point(0.5 * FastMath.PI, 0.5 * FastMath.PI, Cartesian3D.PLUS_J);
/** +K (coordinates: \( \theta = any angle, \varphi = 0 \)). */
- public static final S2Point PLUS_K = new S2Point(0, 0, Coordinates3D.PLUS_K);
+ public static final S2Point PLUS_K = new S2Point(0, 0, Cartesian3D.PLUS_K);
/** -I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)). */
- public static final S2Point MINUS_I = new S2Point(FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.MINUS_I);
+ public static final S2Point MINUS_I = new S2Point(FastMath.PI, 0.5 * FastMath.PI, Cartesian3D.MINUS_I);
/** -J (coordinates: \( \theta = 3\pi/2, \varphi = \pi/2 \)). */
- public static final S2Point MINUS_J = new S2Point(1.5 * FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.MINUS_J);
+ public static final S2Point MINUS_J = new S2Point(1.5 * FastMath.PI, 0.5 * FastMath.PI, Cartesian3D.MINUS_J);
/** -K (coordinates: \( \theta = any angle, \varphi = \pi \)). */
- public static final S2Point MINUS_K = new S2Point(0, FastMath.PI, Coordinates3D.MINUS_K);
+ public static final S2Point MINUS_K = new S2Point(0, FastMath.PI, Cartesian3D.MINUS_K);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final S2Point NaN = new S2Point(Double.NaN, Double.NaN, Coordinates3D.NaN);
+ public static final S2Point NaN = new S2Point(Double.NaN, Double.NaN, Cartesian3D.NaN);
// CHECKSTYLE: resume ConstantName
/** Serializable UID. */
@@ -70,7 +70,7 @@ public class S2Point implements Point<Sphere2D> {
private final double phi;
/** Corresponding 3D normalized vector. */
- private final Coordinates3D vector;
+ private final Cartesian3D vector;
/** Simple constructor.
* Build a vector from its spherical coordinates
@@ -90,8 +90,8 @@ public class S2Point implements Point<Sphere2D> {
* @param vector 3D vector
* @exception MathArithmeticException if vector norm is zero
*/
- public S2Point(final Coordinates3D vector) throws MathArithmeticException {
- this(FastMath.atan2(vector.getY(), vector.getX()), Coordinates3D.angle(Coordinates3D.PLUS_K, vector),
+ public S2Point(final Cartesian3D vector) throws MathArithmeticException {
+ this(FastMath.atan2(vector.getY(), vector.getX()), Cartesian3D.angle(Cartesian3D.PLUS_K, vector),
vector.normalize());
}
@@ -100,7 +100,7 @@ public class S2Point implements Point<Sphere2D> {
* @param phi polar angle \( \varphi \)
* @param vector corresponding vector
*/
- private S2Point(final double theta, final double phi, final Coordinates3D vector) {
+ private S2Point(final double theta, final double phi, final Cartesian3D vector) {
this.theta = theta;
this.phi = phi;
this.vector = vector;
@@ -112,7 +112,7 @@ public class S2Point implements Point<Sphere2D> {
* @return normalized vector
* @exception OutOfRangeException if \( \varphi \) is not in the [\( 0; \pi \)] range
*/
- private static Coordinates3D vector(final double theta, final double phi)
+ private static Cartesian3D vector(final double theta, final double phi)
throws OutOfRangeException {
if (phi < 0 || phi > FastMath.PI) {
@@ -124,7 +124,7 @@ public class S2Point implements Point<Sphere2D> {
final double cosPhi = FastMath.cos(phi);
final double sinPhi = FastMath.sin(phi);
- return new Coordinates3D(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);
+ return new Cartesian3D(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);
}
@@ -147,7 +147,7 @@ public class S2Point implements Point<Sphere2D> {
/** Get the corresponding normalized vector in the 3D euclidean space.
* @return normalized vector
*/
- public Coordinates3D getVector() {
+ public Cartesian3D getVector() {
return vector;
}
@@ -182,7 +182,7 @@ public class S2Point implements Point<Sphere2D> {
* @return the angular separation between p1 and p2
*/
public static double distance(S2Point p1, S2Point p2) {
- return Coordinates3D.angle(p1.vector, p2.vector);
+ return Cartesian3D.angle(p1.vector, p2.vector);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
index cbdf2d6..0f5d115 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
@@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D;
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
import org.apache.commons.math4.geometry.euclidean.threed.RotationConvention;
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.geometry.partitioning.AbstractRegion;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BoundaryProjection;
@@ -58,7 +58,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
* @param pole pole of the hemisphere (the pole is in the inside half)
* @param tolerance below which points are consider to be identical
*/
- public SphericalPolygonsSet(final Coordinates3D pole, final double tolerance) {
+ public SphericalPolygonsSet(final Cartesian3D pole, final double tolerance) {
super(new BSPTree<>(new Circle(pole, tolerance).wholeHyperplane(),
new BSPTree<Sphere2D>(Boolean.FALSE),
new BSPTree<Sphere2D>(Boolean.TRUE),
@@ -73,7 +73,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
* @param n number of sides of the polygon
* @param tolerance below which points are consider to be identical
*/
- public SphericalPolygonsSet(final Coordinates3D center, final Coordinates3D meridian,
+ public SphericalPolygonsSet(final Cartesian3D center, final Cartesian3D meridian,
final double outsideRadius, final int n,
final double tolerance) {
this(tolerance, createRegularPolygonVertices(center, meridian, outsideRadius, n));
@@ -159,10 +159,10 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
* @param n number of sides of the polygon
* @return vertices array
*/
- private static S2Point[] createRegularPolygonVertices(final Coordinates3D center, final Coordinates3D meridian,
+ private static S2Point[] createRegularPolygonVertices(final Cartesian3D center, final Cartesian3D meridian,
final double outsideRadius, final int n) {
final S2Point[] array = new S2Point[n];
- final Rotation r0 = new Rotation(Coordinates3D.crossProduct(center, meridian),
+ final Rotation r0 = new Rotation(Cartesian3D.crossProduct(center, meridian),
outsideRadius, RotationConvention.VECTOR_OPERATOR);
array[0] = new S2Point(r0.applyTo(center));
@@ -226,7 +226,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
// create the edge and store it
edges.add(new Edge(start, end,
- Coordinates3D.angle(start.getLocation().getVector(),
+ Cartesian3D.angle(start.getLocation().getVector(),
end.getLocation().getVector()),
circle));
@@ -490,7 +490,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
}
// gather some inside points, to be used by the encloser
- final List<Coordinates3D> points = getInsidePoints();
+ final List<Cartesian3D> points = getInsidePoints();
// extract points from the boundary loops, to be used by the encloser as well
final List<Vertex> boundary = getBoundaryLoops();
@@ -504,10 +504,10 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
// find the smallest enclosing 3D sphere
final SphereGenerator generator = new SphereGenerator();
- final WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
+ final WelzlEncloser<Euclidean3D, Cartesian3D> encloser =
new WelzlEncloser<>(getTolerance(), generator);
- EnclosingBall<Euclidean3D, Coordinates3D> enclosing3D = encloser.enclose(points);
- final Coordinates3D[] support3D = enclosing3D.getSupport();
+ EnclosingBall<Euclidean3D, Cartesian3D> enclosing3D = encloser.enclose(points);
+ final Cartesian3D[] support3D = enclosing3D.getSupport();
// convert to 3D sphere to spherical cap
final double r = enclosing3D.getRadius();
@@ -517,7 +517,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
// fall back to a crude approximation, based only on outside convex cells
EnclosingBall<Sphere2D, S2Point> enclosingS2 =
new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY);
- for (Coordinates3D outsidePoint : getOutsidePoints()) {
+ for (Cartesian3D outsidePoint : getOutsidePoints()) {
final S2Point outsideS2 = new S2Point(outsidePoint);
final BoundaryProjection<Sphere2D> projection = projectToBoundary(outsideS2);
if (FastMath.PI - projection.getOffset() < enclosingS2.getRadius()) {
@@ -545,7 +545,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
/** Gather some inside points.
* @return list of points known to be strictly in all inside convex cells
*/
- private List<Coordinates3D> getInsidePoints() {
+ private List<Cartesian3D> getInsidePoints() {
final PropertiesComputer pc = new PropertiesComputer(getTolerance());
getTree(true).visit(pc);
return pc.getConvexCellsInsidePoints();
@@ -554,7 +554,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
/** Gather some outside points.
* @return list of points known to be strictly in all outside convex cells
*/
- private List<Coordinates3D> getOutsidePoints() {
+ private List<Cartesian3D> getOutsidePoints() {
final SphericalPolygonsSet complement =
(SphericalPolygonsSet) new RegionFactory<Sphere2D>().getComplement(this);
final PropertiesComputer pc = new PropertiesComputer(getTolerance());
[16/19] [math] MATH-1284: Restore Vector1D class as an abstract
implementation of Vector and now Cartesian1D extends Vector1D.
Restore the public interface of Vector1DFormat to act on Vector1D.
Posted by ra...@apache.org.
MATH-1284: Restore Vector1D class as an abstract implementation of Vector<Euclidean1D> and now Cartesian1D extends Vector1D.
Restore the public interface of Vector1DFormat to act on Vector1D.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/9be91f38
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/9be91f38
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/9be91f38
Branch: refs/heads/feature-MATH-1284
Commit: 9be91f380c209f895da36d13c40b99687bb4c8c1
Parents: a27ca51
Author: Ray DeCampo <ra...@decampo.org>
Authored: Sat May 6 10:45:00 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Sat May 6 10:45:00 2017 -0400
----------------------------------------------------------------------
.../geometry/euclidean/oned/Cartesian1D.java | 3 +-
.../math4/geometry/euclidean/oned/Vector1D.java | 33 +++++++++++++++
.../geometry/euclidean/oned/Vector1DFormat.java | 10 ++---
.../oned/Vector1DFormatAbstractTest.java | 44 ++++++++++----------
4 files changed, 62 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9be91f38/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
index f406125..de3f7d2 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Cartesian1D.java
@@ -34,7 +34,7 @@ import org.apache.commons.math4.util.MathUtils;
* <p>Instances of this class are guaranteed to be immutable.</p>
* @since 4.0
*/
-public class Cartesian1D implements Point<Euclidean1D>, Vector<Euclidean1D> {
+public class Cartesian1D extends Vector1D implements Point<Euclidean1D> {
/** Origin (coordinates: 0). */
public static final Cartesian1D ZERO = new Cartesian1D(0.0);
@@ -128,6 +128,7 @@ public class Cartesian1D implements Point<Euclidean1D>, Vector<Euclidean1D> {
* @return abscissa of the vector
* @see #Cartesian1D(double)
*/
+ @Override
public double getX() {
return x;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9be91f38/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java
new file mode 100644
index 0000000..f35c81f
--- /dev/null
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1D.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.geometry.euclidean.oned;
+
+import org.apache.commons.math4.geometry.Vector;
+
+/** This class represents a 1D vector.
+ *
+ * @since 3.0
+ */
+public abstract class Vector1D implements Vector<Euclidean1D> {
+
+ /** Get the abscissa of the vector.
+ * @return abscissa of the vector
+ * @see #Vector1D(double)
+ */
+ public abstract double getX();
+
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9be91f38/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
index c5cead3..911d6f4 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormat.java
@@ -105,26 +105,26 @@ public class Vector1DFormat extends VectorFormat<Euclidean1D> {
@Override
public StringBuffer format(final Vector<Euclidean1D> vector, final StringBuffer toAppendTo,
final FieldPosition pos) {
- final Cartesian1D p1 = (Cartesian1D) vector;
+ final Vector1D p1 = (Vector1D) vector;
return format(toAppendTo, pos, p1.getX());
}
/** {@inheritDoc} */
@Override
- public Cartesian1D parse(final String source) throws MathParseException {
+ public Vector1D parse(final String source) throws MathParseException {
ParsePosition parsePosition = new ParsePosition(0);
- Cartesian1D result = parse(source, parsePosition);
+ Vector1D result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw new MathParseException(source,
parsePosition.getErrorIndex(),
- Cartesian1D.class);
+ Vector1D.class);
}
return result;
}
/** {@inheritDoc} */
@Override
- public Cartesian1D parse(final String source, final ParsePosition pos) {
+ public Vector1D parse(final String source, final ParsePosition pos) {
final double[] coordinates = parseCoordinates(1, source, pos);
if (coordinates == null) {
return null;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9be91f38/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
index 2cb5ae2..e73cdc5 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
@@ -130,14 +130,14 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testParseSimpleNoDecimals() throws MathParseException {
String source = "{1}";
- Cartesian1D expected = new Cartesian1D(1);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(1);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseIgnoredWhitespace() {
- Cartesian1D expected = new Cartesian1D(1);
+ Vector1D expected = new Cartesian1D(1);
ParsePosition pos1 = new ParsePosition(0);
String source1 = "{1}";
Assert.assertEquals(expected, vector1DFormat.parse(source1, pos1));
@@ -153,8 +153,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"23}";
- Cartesian1D expected = new Cartesian1D(1.23);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(1.23);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -163,8 +163,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Cartesian1D expected = new Cartesian1D(1.2323);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(1.2323);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -173,8 +173,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{-1" + getDecimalCharacter() +
"2323}";
- Cartesian1D expected = new Cartesian1D(-1.2323);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(-1.2323);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -183,8 +183,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Cartesian1D expected = new Cartesian1D(1.2323);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(1.2323);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -193,8 +193,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Cartesian1D expected = new Cartesian1D(1.2323);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(1.2323);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -203,8 +203,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{-1" + getDecimalCharacter() +
"2323}";
- Cartesian1D expected = new Cartesian1D(-1.2323);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(-1.2323);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -213,8 +213,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{0" + getDecimalCharacter() +
"0}";
- Cartesian1D expected = new Cartesian1D(0.0);
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D expected = new Cartesian1D(0.0);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -223,29 +223,29 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"[1" + getDecimalCharacter() +
"2323]";
- Cartesian1D expected = new Cartesian1D(1.2323);
- Cartesian1D actual = vector1DFormatSquare.parse(source);
+ Vector1D expected = new Cartesian1D(1.2323);
+ Vector1D actual = vector1DFormatSquare.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseNan() throws MathParseException {
String source = "{(NaN)}";
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(Cartesian1D.NaN, actual);
}
@Test
public void testParsePositiveInfinity() throws MathParseException {
String source = "{(Infinity)}";
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(Cartesian1D.POSITIVE_INFINITY, actual);
}
@Test
public void testParseNegativeInfinity() throws MathParseException {
String source = "{(-Infinity)}";
- Cartesian1D actual = vector1DFormat.parse(source);
+ Vector1D actual = vector1DFormat.parse(source);
Assert.assertEquals(Cartesian1D.NEGATIVE_INFINITY, actual);
}
[04/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
Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java
index 296ade8..a0e9f59 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.geometry.Space;
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.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.util.FastMath;
@@ -39,27 +39,27 @@ public class Vector3DTest {
@Test
public void testConstructors() throws DimensionMismatchException {
double r = FastMath.sqrt(2) /2;
- checkVector(new Coordinates3D(2, new Coordinates3D(FastMath.PI / 3, -FastMath.PI / 4)),
+ checkVector(new Cartesian3D(2, new Cartesian3D(FastMath.PI / 3, -FastMath.PI / 4)),
r, r * FastMath.sqrt(3), -2 * r);
- checkVector(new Coordinates3D(2, Coordinates3D.PLUS_I,
- -3, Coordinates3D.MINUS_K),
+ checkVector(new Cartesian3D(2, Cartesian3D.PLUS_I,
+ -3, Cartesian3D.MINUS_K),
2, 0, 3);
- checkVector(new Coordinates3D(2, Coordinates3D.PLUS_I,
- 5, Coordinates3D.PLUS_J,
- -3, Coordinates3D.MINUS_K),
+ checkVector(new Cartesian3D(2, Cartesian3D.PLUS_I,
+ 5, Cartesian3D.PLUS_J,
+ -3, Cartesian3D.MINUS_K),
2, 5, 3);
- checkVector(new Coordinates3D(2, Coordinates3D.PLUS_I,
- 5, Coordinates3D.PLUS_J,
- 5, Coordinates3D.MINUS_J,
- -3, Coordinates3D.MINUS_K),
+ checkVector(new Cartesian3D(2, Cartesian3D.PLUS_I,
+ 5, Cartesian3D.PLUS_J,
+ 5, Cartesian3D.MINUS_J,
+ -3, Cartesian3D.MINUS_K),
2, 0, 3);
- checkVector(new Coordinates3D(new double[] { 2, 5, -3 }),
+ checkVector(new Cartesian3D(new double[] { 2, 5, -3 }),
2, 5, -3);
}
@Test
public void testSpace() {
- Space space = new Coordinates3D(1, 2, 2).getSpace();
+ Space space = new Cartesian3D(1, 2, 2).getSpace();
Assert.assertEquals(3, space.getDimension());
Assert.assertEquals(2, space.getSubSpace().getDimension());
Space deserialized = (Space) TestUtils.serializeAndRecover(space);
@@ -68,63 +68,63 @@ public class Vector3DTest {
@Test
public void testZero() {
- Assert.assertEquals(0, new Coordinates3D(1, 2, 2).getZero().getNorm(), 1.0e-15);
+ Assert.assertEquals(0, new Cartesian3D(1, 2, 2).getZero().getNorm(), 1.0e-15);
}
@Test
public void testEquals() {
- Coordinates3D u1 = new Coordinates3D(1, 2, 3);
- Coordinates3D u2 = new Coordinates3D(1, 2, 3);
+ Cartesian3D u1 = new Cartesian3D(1, 2, 3);
+ Cartesian3D u2 = new Cartesian3D(1, 2, 3);
Assert.assertTrue(u1.equals(u1));
Assert.assertTrue(u1.equals(u2));
Assert.assertFalse(u1.equals(new Rotation(1, 0, 0, 0, false)));
- Assert.assertFalse(u1.equals(new Coordinates3D(1, 2, 3 + 10 * Precision.EPSILON)));
- Assert.assertFalse(u1.equals(new Coordinates3D(1, 2 + 10 * Precision.EPSILON, 3)));
- Assert.assertFalse(u1.equals(new Coordinates3D(1 + 10 * Precision.EPSILON, 2, 3)));
- Assert.assertTrue(new Coordinates3D(0, Double.NaN, 0).equals(new Coordinates3D(0, 0, Double.NaN)));
+ Assert.assertFalse(u1.equals(new Cartesian3D(1, 2, 3 + 10 * Precision.EPSILON)));
+ Assert.assertFalse(u1.equals(new Cartesian3D(1, 2 + 10 * Precision.EPSILON, 3)));
+ Assert.assertFalse(u1.equals(new Cartesian3D(1 + 10 * Precision.EPSILON, 2, 3)));
+ Assert.assertTrue(new Cartesian3D(0, Double.NaN, 0).equals(new Cartesian3D(0, 0, Double.NaN)));
}
@Test
public void testHash() {
- Assert.assertEquals(new Coordinates3D(0, Double.NaN, 0).hashCode(), new Coordinates3D(0, 0, Double.NaN).hashCode());
- Coordinates3D u = new Coordinates3D(1, 2, 3);
- Coordinates3D v = new Coordinates3D(1, 2, 3 + 10 * Precision.EPSILON);
+ Assert.assertEquals(new Cartesian3D(0, Double.NaN, 0).hashCode(), new Cartesian3D(0, 0, Double.NaN).hashCode());
+ Cartesian3D u = new Cartesian3D(1, 2, 3);
+ Cartesian3D v = new Cartesian3D(1, 2, 3 + 10 * Precision.EPSILON);
Assert.assertTrue(u.hashCode() != v.hashCode());
}
@Test
public void testInfinite() {
- Assert.assertTrue(new Coordinates3D(1, 1, Double.NEGATIVE_INFINITY).isInfinite());
- Assert.assertTrue(new Coordinates3D(1, Double.NEGATIVE_INFINITY, 1).isInfinite());
- Assert.assertTrue(new Coordinates3D(Double.NEGATIVE_INFINITY, 1, 1).isInfinite());
- Assert.assertFalse(new Coordinates3D(1, 1, 2).isInfinite());
- Assert.assertFalse(new Coordinates3D(1, Double.NaN, Double.NEGATIVE_INFINITY).isInfinite());
+ Assert.assertTrue(new Cartesian3D(1, 1, Double.NEGATIVE_INFINITY).isInfinite());
+ Assert.assertTrue(new Cartesian3D(1, Double.NEGATIVE_INFINITY, 1).isInfinite());
+ Assert.assertTrue(new Cartesian3D(Double.NEGATIVE_INFINITY, 1, 1).isInfinite());
+ Assert.assertFalse(new Cartesian3D(1, 1, 2).isInfinite());
+ Assert.assertFalse(new Cartesian3D(1, Double.NaN, Double.NEGATIVE_INFINITY).isInfinite());
}
@Test
public void testNaN() {
- Assert.assertTrue(new Coordinates3D(1, 1, Double.NaN).isNaN());
- Assert.assertTrue(new Coordinates3D(1, Double.NaN, 1).isNaN());
- Assert.assertTrue(new Coordinates3D(Double.NaN, 1, 1).isNaN());
- Assert.assertFalse(new Coordinates3D(1, 1, 2).isNaN());
- Assert.assertFalse(new Coordinates3D(1, 1, Double.NEGATIVE_INFINITY).isNaN());
+ Assert.assertTrue(new Cartesian3D(1, 1, Double.NaN).isNaN());
+ Assert.assertTrue(new Cartesian3D(1, Double.NaN, 1).isNaN());
+ Assert.assertTrue(new Cartesian3D(Double.NaN, 1, 1).isNaN());
+ Assert.assertFalse(new Cartesian3D(1, 1, 2).isNaN());
+ Assert.assertFalse(new Cartesian3D(1, 1, Double.NEGATIVE_INFINITY).isNaN());
}
@Test
public void testToString() {
- Assert.assertEquals("{3; 2; 1}", new Coordinates3D(3, 2, 1).toString());
+ Assert.assertEquals("{3; 2; 1}", new Cartesian3D(3, 2, 1).toString());
NumberFormat format = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
- Assert.assertEquals("{3.000; 2.000; 1.000}", new Coordinates3D(3, 2, 1).toString(format));
+ Assert.assertEquals("{3.000; 2.000; 1.000}", new Cartesian3D(3, 2, 1).toString(format));
}
@Test(expected=DimensionMismatchException.class)
public void testWrongDimension() throws DimensionMismatchException {
- new Coordinates3D(new double[] { 2, 5 });
+ new Cartesian3D(new double[] { 2, 5 });
}
@Test
public void testCoordinates() {
- Coordinates3D v = new Coordinates3D(1, 2, 3);
+ Cartesian3D v = new Cartesian3D(1, 2, 3);
Assert.assertTrue(FastMath.abs(v.getX() - 1) < 1.0e-12);
Assert.assertTrue(FastMath.abs(v.getY() - 2) < 1.0e-12);
Assert.assertTrue(FastMath.abs(v.getZ() - 3) < 1.0e-12);
@@ -136,69 +136,69 @@ public class Vector3DTest {
@Test
public void testNorm1() {
- Assert.assertEquals(0.0, Coordinates3D.ZERO.getNorm1(), 0);
- Assert.assertEquals(6.0, new Coordinates3D(1, -2, 3).getNorm1(), 0);
+ Assert.assertEquals(0.0, Cartesian3D.ZERO.getNorm1(), 0);
+ Assert.assertEquals(6.0, new Cartesian3D(1, -2, 3).getNorm1(), 0);
}
@Test
public void testNorm() {
- Assert.assertEquals(0.0, Coordinates3D.ZERO.getNorm(), 0);
- Assert.assertEquals(FastMath.sqrt(14), new Coordinates3D(1, 2, 3).getNorm(), 1.0e-12);
+ Assert.assertEquals(0.0, Cartesian3D.ZERO.getNorm(), 0);
+ Assert.assertEquals(FastMath.sqrt(14), new Cartesian3D(1, 2, 3).getNorm(), 1.0e-12);
}
@Test
public void testNormSq() {
- Assert.assertEquals(0.0, new Coordinates3D(0, 0, 0).getNormSq(), 0);
- Assert.assertEquals(14, new Coordinates3D(1, 2, 3).getNormSq(), 1.0e-12);
+ Assert.assertEquals(0.0, new Cartesian3D(0, 0, 0).getNormSq(), 0);
+ Assert.assertEquals(14, new Cartesian3D(1, 2, 3).getNormSq(), 1.0e-12);
}
@Test
public void testNormInf() {
- Assert.assertEquals(0.0, Coordinates3D.ZERO.getNormInf(), 0);
- Assert.assertEquals(3.0, new Coordinates3D(1, -2, 3).getNormInf(), 0);
+ Assert.assertEquals(0.0, Cartesian3D.ZERO.getNormInf(), 0);
+ Assert.assertEquals(3.0, new Cartesian3D(1, -2, 3).getNormInf(), 0);
}
@Test
public void testDistance1() {
- Coordinates3D v1 = new Coordinates3D(1, -2, 3);
- Coordinates3D v2 = new Coordinates3D(-4, 2, 0);
- Assert.assertEquals(0.0, Coordinates3D.distance1(Coordinates3D.MINUS_I, Coordinates3D.MINUS_I), 0);
- Assert.assertEquals(12.0, Coordinates3D.distance1(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNorm1(), Coordinates3D.distance1(v1, v2), 1.0e-12);
+ Cartesian3D v1 = new Cartesian3D(1, -2, 3);
+ Cartesian3D v2 = new Cartesian3D(-4, 2, 0);
+ Assert.assertEquals(0.0, Cartesian3D.distance1(Cartesian3D.MINUS_I, Cartesian3D.MINUS_I), 0);
+ Assert.assertEquals(12.0, Cartesian3D.distance1(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNorm1(), Cartesian3D.distance1(v1, v2), 1.0e-12);
}
@Test
public void testDistance() {
- Coordinates3D v1 = new Coordinates3D(1, -2, 3);
- Coordinates3D v2 = new Coordinates3D(-4, 2, 0);
- Assert.assertEquals(0.0, Coordinates3D.distance(Coordinates3D.MINUS_I, Coordinates3D.MINUS_I), 0);
- Assert.assertEquals(FastMath.sqrt(50), Coordinates3D.distance(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNorm(), Coordinates3D.distance(v1, v2), 1.0e-12);
+ Cartesian3D v1 = new Cartesian3D(1, -2, 3);
+ Cartesian3D v2 = new Cartesian3D(-4, 2, 0);
+ Assert.assertEquals(0.0, Cartesian3D.distance(Cartesian3D.MINUS_I, Cartesian3D.MINUS_I), 0);
+ Assert.assertEquals(FastMath.sqrt(50), Cartesian3D.distance(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNorm(), Cartesian3D.distance(v1, v2), 1.0e-12);
}
@Test
public void testDistanceSq() {
- Coordinates3D v1 = new Coordinates3D(1, -2, 3);
- Coordinates3D v2 = new Coordinates3D(-4, 2, 0);
- Assert.assertEquals(0.0, Coordinates3D.distanceSq(Coordinates3D.MINUS_I, Coordinates3D.MINUS_I), 0);
- Assert.assertEquals(50.0, Coordinates3D.distanceSq(v1, v2), 1.0e-12);
- Assert.assertEquals(Coordinates3D.distance(v1, v2) * Coordinates3D.distance(v1, v2),
- Coordinates3D.distanceSq(v1, v2), 1.0e-12);
+ Cartesian3D v1 = new Cartesian3D(1, -2, 3);
+ Cartesian3D v2 = new Cartesian3D(-4, 2, 0);
+ Assert.assertEquals(0.0, Cartesian3D.distanceSq(Cartesian3D.MINUS_I, Cartesian3D.MINUS_I), 0);
+ Assert.assertEquals(50.0, Cartesian3D.distanceSq(v1, v2), 1.0e-12);
+ Assert.assertEquals(Cartesian3D.distance(v1, v2) * Cartesian3D.distance(v1, v2),
+ Cartesian3D.distanceSq(v1, v2), 1.0e-12);
}
@Test
public void testDistanceInf() {
- Coordinates3D v1 = new Coordinates3D(1, -2, 3);
- Coordinates3D v2 = new Coordinates3D(-4, 2, 0);
- Assert.assertEquals(0.0, Coordinates3D.distanceInf(Coordinates3D.MINUS_I, Coordinates3D.MINUS_I), 0);
- Assert.assertEquals(5.0, Coordinates3D.distanceInf(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNormInf(), Coordinates3D.distanceInf(v1, v2), 1.0e-12);
+ Cartesian3D v1 = new Cartesian3D(1, -2, 3);
+ Cartesian3D v2 = new Cartesian3D(-4, 2, 0);
+ Assert.assertEquals(0.0, Cartesian3D.distanceInf(Cartesian3D.MINUS_I, Cartesian3D.MINUS_I), 0);
+ Assert.assertEquals(5.0, Cartesian3D.distanceInf(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNormInf(), Cartesian3D.distanceInf(v1, v2), 1.0e-12);
}
@Test
public void testSubtract() {
- Coordinates3D v1 = new Coordinates3D(1, 2, 3);
- Coordinates3D v2 = new Coordinates3D(-3, -2, -1);
+ Cartesian3D v1 = new Cartesian3D(1, 2, 3);
+ Cartesian3D v2 = new Cartesian3D(-3, -2, -1);
v1 = v1.subtract(v2);
checkVector(v1, 4, 4, 4);
@@ -208,8 +208,8 @@ public class Vector3DTest {
@Test
public void testAdd() {
- Coordinates3D v1 = new Coordinates3D(1, 2, 3);
- Coordinates3D v2 = new Coordinates3D(-3, -2, -1);
+ Cartesian3D v1 = new Cartesian3D(1, 2, 3);
+ Cartesian3D v2 = new Cartesian3D(-3, -2, -1);
v1 = v1.add(v2);
checkVector(v1, -2, 0, 2);
@@ -219,7 +219,7 @@ public class Vector3DTest {
@Test
public void testScalarProduct() {
- Coordinates3D v = new Coordinates3D(1, 2, 3);
+ Cartesian3D v = new Cartesian3D(1, 2, 3);
v = v.scalarMultiply(3);
checkVector(v, 3, 6, 9);
@@ -228,61 +228,61 @@ public class Vector3DTest {
@Test
public void testVectorialProducts() {
- Coordinates3D v1 = new Coordinates3D(2, 1, -4);
- Coordinates3D v2 = new Coordinates3D(3, 1, -1);
+ Cartesian3D v1 = new Cartesian3D(2, 1, -4);
+ Cartesian3D v2 = new Cartesian3D(3, 1, -1);
- Assert.assertTrue(FastMath.abs(Coordinates3D.dotProduct(v1, v2) - 11) < 1.0e-12);
+ Assert.assertTrue(FastMath.abs(Cartesian3D.dotProduct(v1, v2) - 11) < 1.0e-12);
- Coordinates3D v3 = Coordinates3D.crossProduct(v1, v2);
+ Cartesian3D v3 = Cartesian3D.crossProduct(v1, v2);
checkVector(v3, 3, -10, -1);
- Assert.assertTrue(FastMath.abs(Coordinates3D.dotProduct(v1, v3)) < 1.0e-12);
- Assert.assertTrue(FastMath.abs(Coordinates3D.dotProduct(v2, v3)) < 1.0e-12);
+ Assert.assertTrue(FastMath.abs(Cartesian3D.dotProduct(v1, v3)) < 1.0e-12);
+ Assert.assertTrue(FastMath.abs(Cartesian3D.dotProduct(v2, v3)) < 1.0e-12);
}
@Test
public void testCrossProductCancellation() {
- Coordinates3D v1 = new Coordinates3D(9070467121.0, 4535233560.0, 1);
- Coordinates3D v2 = new Coordinates3D(9070467123.0, 4535233561.0, 1);
- checkVector(Coordinates3D.crossProduct(v1, v2), -1, 2, 1);
+ Cartesian3D v1 = new Cartesian3D(9070467121.0, 4535233560.0, 1);
+ Cartesian3D v2 = new Cartesian3D(9070467123.0, 4535233561.0, 1);
+ checkVector(Cartesian3D.crossProduct(v1, v2), -1, 2, 1);
double scale = FastMath.scalb(1.0, 100);
- Coordinates3D big1 = new Coordinates3D(scale, v1);
- Coordinates3D small2 = new Coordinates3D(1 / scale, v2);
- checkVector(Coordinates3D.crossProduct(big1, small2), -1, 2, 1);
+ Cartesian3D big1 = new Cartesian3D(scale, v1);
+ Cartesian3D small2 = new Cartesian3D(1 / scale, v2);
+ checkVector(Cartesian3D.crossProduct(big1, small2), -1, 2, 1);
}
@Test
public void testAngular() {
- Assert.assertEquals(0, Coordinates3D.PLUS_I.getAlpha(), 1.0e-10);
- Assert.assertEquals(0, Coordinates3D.PLUS_I.getDelta(), 1.0e-10);
- Assert.assertEquals(FastMath.PI / 2, Coordinates3D.PLUS_J.getAlpha(), 1.0e-10);
- Assert.assertEquals(0, Coordinates3D.PLUS_J.getDelta(), 1.0e-10);
- Assert.assertEquals(0, Coordinates3D.PLUS_K.getAlpha(), 1.0e-10);
- Assert.assertEquals(FastMath.PI / 2, Coordinates3D.PLUS_K.getDelta(), 1.0e-10);
-
- Coordinates3D u = new Coordinates3D(-1, 1, -1);
+ Assert.assertEquals(0, Cartesian3D.PLUS_I.getAlpha(), 1.0e-10);
+ Assert.assertEquals(0, Cartesian3D.PLUS_I.getDelta(), 1.0e-10);
+ Assert.assertEquals(FastMath.PI / 2, Cartesian3D.PLUS_J.getAlpha(), 1.0e-10);
+ Assert.assertEquals(0, Cartesian3D.PLUS_J.getDelta(), 1.0e-10);
+ Assert.assertEquals(0, Cartesian3D.PLUS_K.getAlpha(), 1.0e-10);
+ Assert.assertEquals(FastMath.PI / 2, Cartesian3D.PLUS_K.getDelta(), 1.0e-10);
+
+ Cartesian3D u = new Cartesian3D(-1, 1, -1);
Assert.assertEquals(3 * FastMath.PI /4, u.getAlpha(), 1.0e-10);
Assert.assertEquals(-1.0 / FastMath.sqrt(3), FastMath.sin(u.getDelta()), 1.0e-10);
}
@Test
public void testAngularSeparation() throws MathArithmeticException {
- Coordinates3D v1 = new Coordinates3D(2, -1, 4);
+ Cartesian3D v1 = new Cartesian3D(2, -1, 4);
- Coordinates3D k = v1.normalize();
- Coordinates3D i = k.orthogonal();
- Coordinates3D v2 = k.scalarMultiply(FastMath.cos(1.2)).add(i.scalarMultiply(FastMath.sin(1.2)));
+ Cartesian3D k = v1.normalize();
+ Cartesian3D i = k.orthogonal();
+ Cartesian3D v2 = k.scalarMultiply(FastMath.cos(1.2)).add(i.scalarMultiply(FastMath.sin(1.2)));
- Assert.assertTrue(FastMath.abs(Coordinates3D.angle(v1, v2) - 1.2) < 1.0e-12);
+ Assert.assertTrue(FastMath.abs(Cartesian3D.angle(v1, v2) - 1.2) < 1.0e-12);
}
@Test
public void testNormalize() throws MathArithmeticException {
- Assert.assertEquals(1.0, new Coordinates3D(5, -4, 2).normalize().getNorm(), 1.0e-12);
+ Assert.assertEquals(1.0, new Cartesian3D(5, -4, 2).normalize().getNorm(), 1.0e-12);
try {
- Coordinates3D.ZERO.normalize();
+ Cartesian3D.ZERO.normalize();
Assert.fail("an exception should have been thrown");
} catch (MathArithmeticException ae) {
// expected behavior
@@ -291,21 +291,21 @@ public class Vector3DTest {
@Test
public void testNegate() {
- checkVector(new Coordinates3D(0.1, 2.5, 1.3).negate(), -0.1, -2.5, -1.3);
+ checkVector(new Cartesian3D(0.1, 2.5, 1.3).negate(), -0.1, -2.5, -1.3);
}
@Test
public void testOrthogonal() throws MathArithmeticException {
- Coordinates3D v1 = new Coordinates3D(0.1, 2.5, 1.3);
- Assert.assertEquals(0.0, Coordinates3D.dotProduct(v1, v1.orthogonal()), 1.0e-12);
- Coordinates3D v2 = new Coordinates3D(2.3, -0.003, 7.6);
- Assert.assertEquals(0.0, Coordinates3D.dotProduct(v2, v2.orthogonal()), 1.0e-12);
- Coordinates3D v3 = new Coordinates3D(-1.7, 1.4, 0.2);
- Assert.assertEquals(0.0, Coordinates3D.dotProduct(v3, v3.orthogonal()), 1.0e-12);
- Coordinates3D v4 = new Coordinates3D(4.2, 0.1, -1.8);
- Assert.assertEquals(0.0, Coordinates3D.dotProduct(v4, v4.orthogonal()), 1.0e-12);
+ Cartesian3D v1 = new Cartesian3D(0.1, 2.5, 1.3);
+ Assert.assertEquals(0.0, Cartesian3D.dotProduct(v1, v1.orthogonal()), 1.0e-12);
+ Cartesian3D v2 = new Cartesian3D(2.3, -0.003, 7.6);
+ Assert.assertEquals(0.0, Cartesian3D.dotProduct(v2, v2.orthogonal()), 1.0e-12);
+ Cartesian3D v3 = new Cartesian3D(-1.7, 1.4, 0.2);
+ Assert.assertEquals(0.0, Cartesian3D.dotProduct(v3, v3.orthogonal()), 1.0e-12);
+ Cartesian3D v4 = new Cartesian3D(4.2, 0.1, -1.8);
+ Assert.assertEquals(0.0, Cartesian3D.dotProduct(v4, v4.orthogonal()), 1.0e-12);
try {
- new Coordinates3D(0, 0, 0).orthogonal();
+ new Cartesian3D(0, 0, 0).orthogonal();
Assert.fail("an exception should have been thrown");
} catch (MathArithmeticException ae) {
// expected behavior
@@ -314,16 +314,16 @@ public class Vector3DTest {
@Test
public void testAngle() throws MathArithmeticException {
Assert.assertEquals(0.22572612855273393616,
- Coordinates3D.angle(new Coordinates3D(1, 2, 3), new Coordinates3D(4, 5, 6)),
+ Cartesian3D.angle(new Cartesian3D(1, 2, 3), new Cartesian3D(4, 5, 6)),
1.0e-12);
Assert.assertEquals(7.98595620686106654517199e-8,
- Coordinates3D.angle(new Coordinates3D(1, 2, 3), new Coordinates3D(2, 4, 6.000001)),
+ Cartesian3D.angle(new Cartesian3D(1, 2, 3), new Cartesian3D(2, 4, 6.000001)),
1.0e-12);
Assert.assertEquals(3.14159257373023116985197793156,
- Coordinates3D.angle(new Coordinates3D(1, 2, 3), new Coordinates3D(-2, -4, -6.000001)),
+ Cartesian3D.angle(new Cartesian3D(1, 2, 3), new Cartesian3D(-2, -4, -6.000001)),
1.0e-12);
try {
- Coordinates3D.angle(Coordinates3D.ZERO, Coordinates3D.PLUS_I);
+ Cartesian3D.angle(Cartesian3D.ZERO, Cartesian3D.PLUS_I);
Assert.fail("an exception should have been thrown");
} catch (MathArithmeticException ae) {
// expected behavior
@@ -335,10 +335,10 @@ public class Vector3DTest {
// the following two vectors are nearly but not exactly orthogonal
// naive dot product (i.e. computing u1.x * u2.x + u1.y * u2.y + u1.z * u2.z
// leads to a result of 0.0, instead of the correct -1.855129...
- Coordinates3D u1 = new Coordinates3D(-1321008684645961.0 / 268435456.0,
+ Cartesian3D u1 = new Cartesian3D(-1321008684645961.0 / 268435456.0,
-5774608829631843.0 / 268435456.0,
-7645843051051357.0 / 8589934592.0);
- Coordinates3D u2 = new Coordinates3D(-5712344449280879.0 / 2097152.0,
+ Cartesian3D u2 = new Cartesian3D(-5712344449280879.0 / 2097152.0,
-4550117129121957.0 / 2097152.0,
8846951984510141.0 / 131072.0);
double sNaive = u1.getX() * u2.getX() + u1.getY() * u2.getY() + u1.getZ() * u2.getZ();
@@ -360,7 +360,7 @@ public class Vector3DTest {
double vy = 10000 * random.nextDouble();
double vz = 10000 * random.nextDouble();
double sNaive = ux * vx + uy * vy + uz * vz;
- double sAccurate = new Coordinates3D(ux, uy, uz).dotProduct(new Coordinates3D(vx, vy, vz));
+ double sAccurate = new Cartesian3D(ux, uy, uz).dotProduct(new Cartesian3D(vx, vy, vz));
Assert.assertEquals(sNaive, sAccurate, 2.5e-16 * sAccurate);
}
}
@@ -372,19 +372,19 @@ public class Vector3DTest {
// computing u1.x * u2.x + u1.y * u2.y + u1.z * u2.z
// leads to a result of [0.0009765, -0.0001220, -0.0039062],
// instead of the correct [0.0006913, -0.0001254, -0.0007909]
- final Coordinates3D u1 = new Coordinates3D(-1321008684645961.0 / 268435456.0,
+ final Cartesian3D u1 = new Cartesian3D(-1321008684645961.0 / 268435456.0,
-5774608829631843.0 / 268435456.0,
-7645843051051357.0 / 8589934592.0);
- final Coordinates3D u2 = new Coordinates3D( 1796571811118507.0 / 2147483648.0,
+ final Cartesian3D u2 = new Cartesian3D( 1796571811118507.0 / 2147483648.0,
7853468008299307.0 / 2147483648.0,
2599586637357461.0 / 17179869184.0);
- final Coordinates3D u3 = new Coordinates3D(12753243807587107.0 / 18446744073709551616.0,
+ final Cartesian3D u3 = new Cartesian3D(12753243807587107.0 / 18446744073709551616.0,
-2313766922703915.0 / 18446744073709551616.0,
-227970081415313.0 / 288230376151711744.0);
- Coordinates3D cNaive = new Coordinates3D(u1.getY() * u2.getZ() - u1.getZ() * u2.getY(),
+ Cartesian3D cNaive = new Cartesian3D(u1.getY() * u2.getZ() - u1.getZ() * u2.getY(),
u1.getZ() * u2.getX() - u1.getX() * u2.getZ(),
u1.getX() * u2.getY() - u1.getY() * u2.getX());
- Coordinates3D cAccurate = u1.crossProduct(u2);
+ Cartesian3D cAccurate = u1.crossProduct(u2);
Assert.assertTrue(u3.distance(cNaive) > 2.9 * u3.getNorm());
Assert.assertEquals(0.0, u3.distance(cAccurate), 1.0e-30 * cAccurate.getNorm());
}
@@ -401,13 +401,13 @@ public class Vector3DTest {
double vx = 10000 * random.nextDouble();
double vy = 10000 * random.nextDouble();
double vz = 10000 * random.nextDouble();
- Coordinates3D cNaive = new Coordinates3D(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx);
- Coordinates3D cAccurate = new Coordinates3D(ux, uy, uz).crossProduct(new Coordinates3D(vx, vy, vz));
+ Cartesian3D cNaive = new Cartesian3D(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx);
+ Cartesian3D cAccurate = new Cartesian3D(ux, uy, uz).crossProduct(new Cartesian3D(vx, vy, vz));
Assert.assertEquals(0.0, cAccurate.distance(cNaive), 6.0e-15 * cAccurate.getNorm());
}
}
- private void checkVector(Coordinates3D v, double x, double y, double z) {
+ private void checkVector(Cartesian3D v, double x, double y, double z) {
Assert.assertEquals(x, v.getX(), 1.0e-12);
Assert.assertEquals(y, v.getY(), 1.0e-12);
Assert.assertEquals(z, v.getZ(), 1.0e-12);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java
index 841a87c..727bdfa 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGeneratorTest.java
@@ -23,7 +23,7 @@ import java.util.List;
import org.apache.commons.math4.geometry.enclosing.EnclosingBall;
import org.apache.commons.math4.geometry.euclidean.twod.DiskGenerator;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
@@ -35,8 +35,8 @@ public class DiskGeneratorTest {
@Test
public void testSupport0Point() {
- List<Coordinates2D> support = Arrays.asList(new Coordinates2D[0]);
- EnclosingBall<Euclidean2D, Coordinates2D> disk = new DiskGenerator().ballOnSupport(support);
+ List<Cartesian2D> support = Arrays.asList(new Cartesian2D[0]);
+ EnclosingBall<Euclidean2D, Cartesian2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertTrue(disk.getRadius() < 0);
Assert.assertEquals(0, disk.getSupportSize());
Assert.assertEquals(0, disk.getSupport().length);
@@ -44,15 +44,15 @@ public class DiskGeneratorTest {
@Test
public void testSupport1Point() {
- List<Coordinates2D> support = Arrays.asList(new Coordinates2D(1, 2));
- EnclosingBall<Euclidean2D, Coordinates2D> disk = new DiskGenerator().ballOnSupport(support);
+ List<Cartesian2D> support = Arrays.asList(new Cartesian2D(1, 2));
+ EnclosingBall<Euclidean2D, Cartesian2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertEquals(0.0, disk.getRadius(), 1.0e-10);
Assert.assertTrue(disk.contains(support.get(0)));
Assert.assertTrue(disk.contains(support.get(0), 0.5));
- Assert.assertFalse(disk.contains(new Coordinates2D(support.get(0).getX() + 0.1,
+ Assert.assertFalse(disk.contains(new Cartesian2D(support.get(0).getX() + 0.1,
support.get(0).getY() - 0.1),
0.001));
- Assert.assertTrue(disk.contains(new Coordinates2D(support.get(0).getX() + 0.1,
+ Assert.assertTrue(disk.contains(new Cartesian2D(support.get(0).getX() + 0.1,
support.get(0).getY() - 0.1),
0.5));
Assert.assertEquals(0, support.get(0).distance(disk.getCenter()), 1.0e-10);
@@ -62,41 +62,41 @@ public class DiskGeneratorTest {
@Test
public void testSupport2Points() {
- List<Coordinates2D> support = Arrays.asList(new Coordinates2D(1, 0),
- new Coordinates2D(3, 0));
- EnclosingBall<Euclidean2D, Coordinates2D> disk = new DiskGenerator().ballOnSupport(support);
+ List<Cartesian2D> support = Arrays.asList(new Cartesian2D(1, 0),
+ new Cartesian2D(3, 0));
+ EnclosingBall<Euclidean2D, Cartesian2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertEquals(1.0, disk.getRadius(), 1.0e-10);
int i = 0;
- for (Coordinates2D v : support) {
+ for (Cartesian2D v : support) {
Assert.assertTrue(disk.contains(v));
Assert.assertEquals(1.0, v.distance(disk.getCenter()), 1.0e-10);
Assert.assertTrue(v == disk.getSupport()[i++]);
}
- Assert.assertTrue(disk.contains(new Coordinates2D(2, 0.9)));
- Assert.assertFalse(disk.contains(Coordinates2D.ZERO));
- Assert.assertEquals(0.0, new Coordinates2D(2, 0).distance(disk.getCenter()), 1.0e-10);
+ Assert.assertTrue(disk.contains(new Cartesian2D(2, 0.9)));
+ Assert.assertFalse(disk.contains(Cartesian2D.ZERO));
+ Assert.assertEquals(0.0, new Cartesian2D(2, 0).distance(disk.getCenter()), 1.0e-10);
Assert.assertEquals(2, disk.getSupportSize());
}
@Test
public void testSupport3Points() {
- List<Coordinates2D> support = Arrays.asList(new Coordinates2D(1, 0),
- new Coordinates2D(3, 0),
- new Coordinates2D(2, 2));
- EnclosingBall<Euclidean2D, Coordinates2D> disk = new DiskGenerator().ballOnSupport(support);
+ List<Cartesian2D> support = Arrays.asList(new Cartesian2D(1, 0),
+ new Cartesian2D(3, 0),
+ new Cartesian2D(2, 2));
+ EnclosingBall<Euclidean2D, Cartesian2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertEquals(5.0 / 4.0, disk.getRadius(), 1.0e-10);
int i = 0;
- for (Coordinates2D v : support) {
+ for (Cartesian2D v : support) {
Assert.assertTrue(disk.contains(v));
Assert.assertEquals(5.0 / 4.0, v.distance(disk.getCenter()), 1.0e-10);
Assert.assertTrue(v == disk.getSupport()[i++]);
}
- Assert.assertTrue(disk.contains(new Coordinates2D(2, 0.9)));
- Assert.assertFalse(disk.contains(new Coordinates2D(0.9, 0)));
- Assert.assertFalse(disk.contains(new Coordinates2D(3.1, 0)));
- Assert.assertTrue(disk.contains(new Coordinates2D(2.0, -0.499)));
- Assert.assertFalse(disk.contains(new Coordinates2D(2.0, -0.501)));
- Assert.assertEquals(0.0, new Coordinates2D(2.0, 3.0 / 4.0).distance(disk.getCenter()), 1.0e-10);
+ Assert.assertTrue(disk.contains(new Cartesian2D(2, 0.9)));
+ Assert.assertFalse(disk.contains(new Cartesian2D(0.9, 0)));
+ Assert.assertFalse(disk.contains(new Cartesian2D(3.1, 0)));
+ Assert.assertTrue(disk.contains(new Cartesian2D(2.0, -0.499)));
+ Assert.assertFalse(disk.contains(new Cartesian2D(2.0, -0.501)));
+ Assert.assertEquals(0.0, new Cartesian2D(2.0, 3.0 / 4.0).distance(disk.getCenter()), 1.0e-10);
Assert.assertEquals(3, disk.getSupportSize());
}
@@ -108,12 +108,12 @@ public class DiskGeneratorTest {
for (int i = 0; i < 500; ++i) {
double d = 25 * random.nextDouble();
double refRadius = 10 * random.nextDouble();
- Coordinates2D refCenter = new Coordinates2D(d, new Coordinates2D(sr.nextVector()));
- List<Coordinates2D> support = new ArrayList<>();
+ Cartesian2D refCenter = new Cartesian2D(d, new Cartesian2D(sr.nextVector()));
+ List<Cartesian2D> support = new ArrayList<>();
for (int j = 0; j < 3; ++j) {
- support.add(new Coordinates2D(1.0, refCenter, refRadius, new Coordinates2D(sr.nextVector())));
+ support.add(new Cartesian2D(1.0, refCenter, refRadius, new Cartesian2D(sr.nextVector())));
}
- EnclosingBall<Euclidean2D, Coordinates2D> disk = new DiskGenerator().ballOnSupport(support);
+ EnclosingBall<Euclidean2D, Cartesian2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertEquals(0.0, refCenter.distance(disk.getCenter()), 3e-9 * refRadius);
Assert.assertEquals(refRadius, disk.getRadius(), 7e-10 * refRadius);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/LineTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/LineTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/LineTest.java
index 79e9fa4..9f1beef 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/LineTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/LineTest.java
@@ -19,10 +19,7 @@ package org.apache.commons.math4.geometry.euclidean.twod;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
-import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Line;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.Transform;
import org.apache.commons.math4.util.FastMath;
import org.junit.Assert;
@@ -32,54 +29,54 @@ public class LineTest {
@Test
public void testContains() {
- Line l = new Line(new Coordinates2D(0, 1), new Coordinates2D(1, 2), 1.0e-10);
- Assert.assertTrue(l.contains(new Coordinates2D(0, 1)));
- Assert.assertTrue(l.contains(new Coordinates2D(1, 2)));
- Assert.assertTrue(l.contains(new Coordinates2D(7, 8)));
- Assert.assertTrue(! l.contains(new Coordinates2D(8, 7)));
+ Line l = new Line(new Cartesian2D(0, 1), new Cartesian2D(1, 2), 1.0e-10);
+ Assert.assertTrue(l.contains(new Cartesian2D(0, 1)));
+ Assert.assertTrue(l.contains(new Cartesian2D(1, 2)));
+ Assert.assertTrue(l.contains(new Cartesian2D(7, 8)));
+ Assert.assertTrue(! l.contains(new Cartesian2D(8, 7)));
}
@Test
public void testAbscissa() {
- Line l = new Line(new Coordinates2D(2, 1), new Coordinates2D(-2, -2), 1.0e-10);
+ Line l = new Line(new Cartesian2D(2, 1), new Cartesian2D(-2, -2), 1.0e-10);
Assert.assertEquals(0.0,
- (l.toSubSpace(new Coordinates2D(-3, 4))).getX(),
+ (l.toSubSpace(new Cartesian2D(-3, 4))).getX(),
1.0e-10);
Assert.assertEquals(0.0,
- (l.toSubSpace(new Coordinates2D( 3, -4))).getX(),
+ (l.toSubSpace(new Cartesian2D( 3, -4))).getX(),
1.0e-10);
Assert.assertEquals(-5.0,
- (l.toSubSpace(new Coordinates2D( 7, -1))).getX(),
+ (l.toSubSpace(new Cartesian2D( 7, -1))).getX(),
1.0e-10);
Assert.assertEquals(5.0,
- (l.toSubSpace(new Coordinates2D(-1, -7))).getX(),
+ (l.toSubSpace(new Cartesian2D(-1, -7))).getX(),
1.0e-10);
}
@Test
public void testOffset() {
- Line l = new Line(new Coordinates2D(2, 1), new Coordinates2D(-2, -2), 1.0e-10);
- Assert.assertEquals(-5.0, l.getOffset(new Coordinates2D(5, -3)), 1.0e-10);
- Assert.assertEquals(+5.0, l.getOffset(new Coordinates2D(-5, 2)), 1.0e-10);
+ Line l = new Line(new Cartesian2D(2, 1), new Cartesian2D(-2, -2), 1.0e-10);
+ Assert.assertEquals(-5.0, l.getOffset(new Cartesian2D(5, -3)), 1.0e-10);
+ Assert.assertEquals(+5.0, l.getOffset(new Cartesian2D(-5, 2)), 1.0e-10);
}
@Test
public void testDistance() {
- Line l = new Line(new Coordinates2D(2, 1), new Coordinates2D(-2, -2), 1.0e-10);
- Assert.assertEquals(+5.0, l.distance(new Coordinates2D(5, -3)), 1.0e-10);
- Assert.assertEquals(+5.0, l.distance(new Coordinates2D(-5, 2)), 1.0e-10);
+ Line l = new Line(new Cartesian2D(2, 1), new Cartesian2D(-2, -2), 1.0e-10);
+ Assert.assertEquals(+5.0, l.distance(new Cartesian2D(5, -3)), 1.0e-10);
+ Assert.assertEquals(+5.0, l.distance(new Cartesian2D(-5, 2)), 1.0e-10);
}
@Test
public void testPointAt() {
- Line l = new Line(new Coordinates2D(2, 1), new Coordinates2D(-2, -2), 1.0e-10);
+ Line l = new Line(new Cartesian2D(2, 1), new Cartesian2D(-2, -2), 1.0e-10);
for (double a = -2.0; a < 2.0; a += 0.2) {
- Point<Euclidean1D> pA = new Coordinates1D(a);
+ Point<Euclidean1D> pA = new Cartesian1D(a);
Point<Euclidean2D> point = l.toSpace(pA);
Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10);
Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10);
for (double o = -2.0; o < 2.0; o += 0.2) {
- point = l.getPointAt((Coordinates1D) pA, o);
+ point = l.getPointAt((Cartesian1D) pA, o);
Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10);
Assert.assertEquals(o, l.getOffset(point), 1.0e-10);
}
@@ -88,34 +85,34 @@ public class LineTest {
@Test
public void testOriginOffset() {
- Line l1 = new Line(new Coordinates2D(0, 1), new Coordinates2D(1, 2), 1.0e-10);
+ Line l1 = new Line(new Cartesian2D(0, 1), new Cartesian2D(1, 2), 1.0e-10);
Assert.assertEquals(FastMath.sqrt(0.5), l1.getOriginOffset(), 1.0e-10);
- Line l2 = new Line(new Coordinates2D(1, 2), new Coordinates2D(0, 1), 1.0e-10);
+ Line l2 = new Line(new Cartesian2D(1, 2), new Cartesian2D(0, 1), 1.0e-10);
Assert.assertEquals(-FastMath.sqrt(0.5), l2.getOriginOffset(), 1.0e-10);
}
@Test
public void testParallel() {
- Line l1 = new Line(new Coordinates2D(0, 1), new Coordinates2D(1, 2), 1.0e-10);
- Line l2 = new Line(new Coordinates2D(2, 2), new Coordinates2D(3, 3), 1.0e-10);
+ Line l1 = new Line(new Cartesian2D(0, 1), new Cartesian2D(1, 2), 1.0e-10);
+ Line l2 = new Line(new Cartesian2D(2, 2), new Cartesian2D(3, 3), 1.0e-10);
Assert.assertTrue(l1.isParallelTo(l2));
- Line l3 = new Line(new Coordinates2D(1, 0), new Coordinates2D(0.5, -0.5), 1.0e-10);
+ Line l3 = new Line(new Cartesian2D(1, 0), new Cartesian2D(0.5, -0.5), 1.0e-10);
Assert.assertTrue(l1.isParallelTo(l3));
- Line l4 = new Line(new Coordinates2D(1, 0), new Coordinates2D(0.5, -0.51), 1.0e-10);
+ Line l4 = new Line(new Cartesian2D(1, 0), new Cartesian2D(0.5, -0.51), 1.0e-10);
Assert.assertTrue(! l1.isParallelTo(l4));
}
@Test
public void testTransform() throws MathIllegalArgumentException {
- Line l1 = new Line(new Coordinates2D(1.0 ,1.0), new Coordinates2D(4.0 ,1.0), 1.0e-10);
+ Line l1 = new Line(new Cartesian2D(1.0 ,1.0), new Cartesian2D(4.0 ,1.0), 1.0e-10);
Transform<Euclidean2D, Euclidean1D> t1 =
Line.getTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5);
Assert.assertEquals(0.5 * FastMath.PI,
((Line) t1.apply(l1)).getAngle(),
1.0e-10);
- Line l2 = new Line(new Coordinates2D(0.0, 0.0), new Coordinates2D(1.0, 1.0), 1.0e-10);
+ Line l2 = new Line(new Cartesian2D(0.0, 0.0), new Cartesian2D(1.0, 1.0), 1.0e-10);
Transform<Euclidean2D, Euclidean1D> t2 =
Line.getTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5);
Assert.assertEquals(FastMath.atan2(1.0, -2.0),
@@ -126,9 +123,9 @@ public class LineTest {
@Test
public void testIntersection() {
- Line l1 = new Line(new Coordinates2D( 0, 1), new Coordinates2D(1, 2), 1.0e-10);
- Line l2 = new Line(new Coordinates2D(-1, 2), new Coordinates2D(2, 1), 1.0e-10);
- Coordinates2D p = l1.intersection(l2);
+ Line l1 = new Line(new Cartesian2D( 0, 1), new Cartesian2D(1, 2), 1.0e-10);
+ Line l2 = new Line(new Cartesian2D(-1, 2), new Cartesian2D(2, 1), 1.0e-10);
+ Cartesian2D p = l1.intersection(l2);
Assert.assertEquals(0.5, p.getX(), 1.0e-10);
Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoopsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoopsTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoopsTest.java
index 822cea7..912c4a5 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoopsTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoopsTest.java
@@ -32,13 +32,13 @@ public class NestedLoopsTest {
@Test
public void testNestedLoops() throws Exception {
- Coordinates2D oneOne = new Coordinates2D(1.0, 1.0);
- Coordinates2D oneNegativeOne = new Coordinates2D(1.0, -1.0);
- Coordinates2D negativeOneNegativeOne = new Coordinates2D(-1.0, -1.0);
- Coordinates2D negativeOneOne = new Coordinates2D(-1.0, 1.0);
- Coordinates2D origin = new Coordinates2D(0, 0);
+ Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
+ Cartesian2D oneNegativeOne = new Cartesian2D(1.0, -1.0);
+ Cartesian2D negativeOneNegativeOne = new Cartesian2D(-1.0, -1.0);
+ Cartesian2D negativeOneOne = new Cartesian2D(-1.0, 1.0);
+ Cartesian2D origin = new Cartesian2D(0, 0);
- Coordinates2D [] vertices = new Coordinates2D[]{
+ Cartesian2D [] vertices = new Cartesian2D[]{
oneOne,
oneNegativeOne,
negativeOneNegativeOne,
@@ -55,8 +55,8 @@ public class NestedLoopsTest {
surroundedField.setAccessible(Boolean.TRUE);
loopField.setAccessible(Boolean.TRUE);
List<NestedLoops> surrounded = (List<NestedLoops>) surroundedField.get(nestedLoops);
- Coordinates2D[] loop = (Coordinates2D []) loopField.get(surrounded.get(0));
- Set<Coordinates2D> vertexSet = new HashSet<>(Arrays.asList(loop));
+ Cartesian2D[] loop = (Cartesian2D []) loopField.get(surrounded.get(0));
+ Set<Cartesian2D> vertexSet = new HashSet<>(Arrays.asList(loop));
Assert.assertTrue(vertexSet.contains(oneOne));
Assert.assertTrue(vertexSet.contains(oneNegativeOne));
Assert.assertTrue(vertexSet.contains(negativeOneNegativeOne));
[10/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
Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
index a05ab8e..6392e3f 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java
@@ -820,8 +820,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusK) coordinates are :
// sin (theta), -sin (phi) cos (theta), cos (phi) cos (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_I);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getX().getReal() < -0.9999999999) || (v2.getX().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -836,8 +836,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusJ) coordinates are :
// -sin (psi), cos (phi) cos (psi), sin (phi) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_I);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getX().getReal() < -0.9999999999) || (v2.getX().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -852,8 +852,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusK) coordinates are :
// sin (theta) cos (phi), -sin (phi), cos (theta) cos (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_J);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getY().getReal() < -0.9999999999) || (v2.getY().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -868,8 +868,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusI) coordinates are :
// cos (theta) cos (psi), sin (psi), -sin (theta) cos (psi)
// and we can choose to have psi in the interval [-PI/2 ; +PI/2]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_J);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getY().getReal() < -0.9999999999) || (v2.getY().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -884,8 +884,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusJ) coordinates are :
// -sin (psi) cos (phi), cos (psi) cos (phi), sin (phi)
// and we can choose to have phi in the interval [-PI/2 ; +PI/2]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_K);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getZ().getReal() < -0.9999999999) || (v2.getZ().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -900,8 +900,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusI) coordinates are :
// cos (psi) cos (theta), sin (psi) cos (theta), -sin (theta)
// and we can choose to have theta in the interval [-PI/2 ; +PI/2]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_K);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getZ().getReal() < -0.9999999999) || (v2.getZ().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(true);
}
@@ -916,8 +916,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusI) coordinates are :
// cos (theta), sin (theta) sin (phi1), -sin (theta) cos (phi1)
// and we can choose to have theta in the interval [0 ; PI]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_I);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getX().getReal() < -0.9999999999) || (v2.getX().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -932,8 +932,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusI) coordinates are :
// cos (psi), sin (psi) cos (phi1), sin (psi) sin (phi1)
// and we can choose to have psi in the interval [0 ; PI]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_I);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_I);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_I);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_I);
if ((v2.getX().getReal() < -0.9999999999) || (v2.getX().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -948,8 +948,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusJ) coordinates are :
// sin (theta1) sin (phi), cos (phi), cos (theta1) sin (phi)
// and we can choose to have phi in the interval [0 ; PI]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_J);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getY().getReal() < -0.9999999999) || (v2.getY().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -964,8 +964,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusJ) coordinates are :
// -cos (theta1) sin (psi), cos (psi), sin (theta1) sin (psi)
// and we can choose to have psi in the interval [0 ; PI]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_J);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_J);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_J);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_J);
if ((v2.getY().getReal() < -0.9999999999) || (v2.getY().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -980,8 +980,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusK) coordinates are :
// sin (psi1) sin (phi), -cos (psi1) sin (phi), cos (phi)
// and we can choose to have phi in the interval [0 ; PI]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_K);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getZ().getReal() < -0.9999999999) || (v2.getZ().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -996,8 +996,8 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
// (-r) (Vector3D.plusK) coordinates are :
// cos (psi1) sin (theta), sin (psi1) sin (theta), cos (theta)
// and we can choose to have theta in the interval [0 ; PI]
- FieldVector3D<T> v1 = applyTo(Coordinates3D.PLUS_K);
- FieldVector3D<T> v2 = applyInverseTo(Coordinates3D.PLUS_K);
+ FieldVector3D<T> v1 = applyTo(Cartesian3D.PLUS_K);
+ FieldVector3D<T> v2 = applyInverseTo(Cartesian3D.PLUS_K);
if ((v2.getZ().getReal() < -0.9999999999) || (v2.getZ().getReal() > 0.9999999999)) {
throw new CardanEulerSingularityException(false);
}
@@ -1100,7 +1100,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
* @param u vector to apply the rotation to
* @return a new vector which is the image of u by the rotation
*/
- public FieldVector3D<T> applyTo(final Coordinates3D u) {
+ public FieldVector3D<T> applyTo(final Cartesian3D u) {
final double x = u.getX();
final double y = u.getY();
@@ -1194,7 +1194,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl
* @param u vector to apply the inverse of the rotation to
* @return a new vector which such that u is its image by the rotation
*/
- public FieldVector3D<T> applyInverseTo(final Coordinates3D u) {
+ public FieldVector3D<T> applyInverseTo(final Cartesian3D u) {
final double x = u.getX();
final double y = u.getY();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
index dc538a5..ac31622 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathArrays;
/**
- * This class is a re-implementation of {@link Coordinates3D} using {@link RealFieldElement}.
+ * This class is a re-implementation of {@link Cartesian3D} using {@link RealFieldElement}.
* <p>Instance of this class are guaranteed to be immutable.</p>
* @param <T> the type of the field elements
* @since 3.2
@@ -110,7 +110,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param a scale factor
* @param u base (unscaled) vector
*/
- public FieldVector3D(final T a, final Coordinates3D u) {
+ public FieldVector3D(final T a, final Cartesian3D u) {
this.x = a.multiply(u.getX());
this.y = a.multiply(u.getY());
this.z = a.multiply(u.getZ());
@@ -152,8 +152,8 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param a2 second scale factor
* @param u2 second base (unscaled) vector
*/
- public FieldVector3D(final T a1, final Coordinates3D u1,
- final T a2, final Coordinates3D u2) {
+ public FieldVector3D(final T a1, final Cartesian3D u1,
+ final T a2, final Cartesian3D u2) {
final T prototype = a1;
this.x = prototype.linearCombination(u1.getX(), a1, u2.getX(), a2);
this.y = prototype.linearCombination(u1.getY(), a1, u2.getY(), a2);
@@ -205,9 +205,9 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param a3 third scale factor
* @param u3 third base (unscaled) vector
*/
- public FieldVector3D(final T a1, final Coordinates3D u1,
- final T a2, final Coordinates3D u2,
- final T a3, final Coordinates3D u3) {
+ public FieldVector3D(final T a1, final Cartesian3D u1,
+ final T a2, final Cartesian3D u2,
+ final T a3, final Cartesian3D u3) {
final T prototype = a1;
this.x = prototype.linearCombination(u1.getX(), a1, u2.getX(), a2, u3.getX(), a3);
this.y = prototype.linearCombination(u1.getY(), a1, u2.getY(), a2, u3.getY(), a3);
@@ -267,10 +267,10 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param a4 fourth scale factor
* @param u4 fourth base (unscaled) vector
*/
- public FieldVector3D(final T a1, final Coordinates3D u1,
- final T a2, final Coordinates3D u2,
- final T a3, final Coordinates3D u3,
- final T a4, final Coordinates3D u4) {
+ public FieldVector3D(final T a1, final Cartesian3D u1,
+ final T a2, final Cartesian3D u2,
+ final T a3, final Cartesian3D u3,
+ final T a4, final Cartesian3D u4) {
final T prototype = a1;
this.x = prototype.linearCombination(u1.getX(), a1, u2.getX(), a2, u3.getX(), a3, u4.getX(), a4);
this.y = prototype.linearCombination(u1.getY(), a1, u2.getY(), a2, u3.getY(), a3, u4.getY(), a4);
@@ -338,8 +338,8 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
/** Convert to a constant vector without derivatives.
* @return a constant vector
*/
- public Coordinates3D toVector3D() {
- return new Coordinates3D(x.getReal(), y.getReal(), z.getReal());
+ public Cartesian3D toVector3D() {
+ return new Cartesian3D(x.getReal(), y.getReal(), z.getReal());
}
/** Get the L<sub>1</sub> norm for the vector.
@@ -415,7 +415,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v vector to add
* @return a new vector
*/
- public FieldVector3D<T> add(final Coordinates3D v) {
+ public FieldVector3D<T> add(final Cartesian3D v) {
return new FieldVector3D<>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ()));
}
@@ -433,7 +433,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v vector to add
* @return a new vector
*/
- public FieldVector3D<T> add(final T factor, final Coordinates3D v) {
+ public FieldVector3D<T> add(final T factor, final Cartesian3D v) {
return new FieldVector3D<>(x.add(factor.multiply(v.getX())),
y.add(factor.multiply(v.getY())),
z.add(factor.multiply(v.getZ())));
@@ -453,7 +453,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v vector to add
* @return a new vector
*/
- public FieldVector3D<T> add(final double factor, final Coordinates3D v) {
+ public FieldVector3D<T> add(final double factor, final Cartesian3D v) {
return new FieldVector3D<>(x.add(factor * v.getX()),
y.add(factor * v.getY()),
z.add(factor * v.getZ()));
@@ -471,7 +471,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v vector to subtract
* @return a new vector
*/
- public FieldVector3D<T> subtract(final Coordinates3D v) {
+ public FieldVector3D<T> subtract(final Cartesian3D v) {
return new FieldVector3D<>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ()));
}
@@ -489,7 +489,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v vector to subtract
* @return a new vector
*/
- public FieldVector3D<T> subtract(final T factor, final Coordinates3D v) {
+ public FieldVector3D<T> subtract(final T factor, final Cartesian3D v) {
return new FieldVector3D<>(x.subtract(factor.multiply(v.getX())),
y.subtract(factor.multiply(v.getY())),
z.subtract(factor.multiply(v.getZ())));
@@ -509,7 +509,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v vector to subtract
* @return a new vector
*/
- public FieldVector3D<T> subtract(final double factor, final Coordinates3D v) {
+ public FieldVector3D<T> subtract(final double factor, final Cartesian3D v) {
return new FieldVector3D<>(x.subtract(factor * v.getX()),
y.subtract(factor * v.getY()),
z.subtract(factor * v.getZ()));
@@ -610,7 +610,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return angular separation between v1 and v2
* @exception MathArithmeticException if either vector has a null norm
*/
- public static <T extends RealFieldElement<T>> T angle(final FieldVector3D<T> v1, final Coordinates3D v2)
+ public static <T extends RealFieldElement<T>> T angle(final FieldVector3D<T> v1, final Cartesian3D v2)
throws MathArithmeticException {
final T normProduct = v1.getNorm().multiply(v2.getNorm());
@@ -646,7 +646,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return angular separation between v1 and v2
* @exception MathArithmeticException if either vector has a null norm
*/
- public static <T extends RealFieldElement<T>> T angle(final Coordinates3D v1, final FieldVector3D<T> v2)
+ public static <T extends RealFieldElement<T>> T angle(final Cartesian3D v1, final FieldVector3D<T> v2)
throws MathArithmeticException {
return angle(v2, v1);
}
@@ -770,7 +770,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v second vector
* @return the dot product this.v
*/
- public T dotProduct(final Coordinates3D v) {
+ public T dotProduct(final Cartesian3D v) {
return x.linearCombination(v.getX(), x, v.getY(), y, v.getZ(), z);
}
@@ -788,7 +788,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v other vector
* @return the cross product this ^ v as a new Vector3D
*/
- public FieldVector3D<T> crossProduct(final Coordinates3D v) {
+ public FieldVector3D<T> crossProduct(final Cartesian3D v) {
return new FieldVector3D<>(x.linearCombination(v.getZ(), y, -v.getY(), z),
y.linearCombination(v.getX(), z, -v.getZ(), x),
z.linearCombination(v.getY(), x, -v.getX(), y));
@@ -815,7 +815,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v second vector
* @return the distance between the instance and p according to the L<sub>1</sub> norm
*/
- public T distance1(final Coordinates3D v) {
+ public T distance1(final Cartesian3D v) {
final T dx = x.subtract(v.getX()).abs();
final T dy = y.subtract(v.getY()).abs();
final T dz = z.subtract(v.getZ()).abs();
@@ -843,7 +843,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v second vector
* @return the distance between the instance and p according to the L<sub>2</sub> norm
*/
- public T distance(final Coordinates3D v) {
+ public T distance(final Cartesian3D v) {
final T dx = x.subtract(v.getX());
final T dy = y.subtract(v.getY());
final T dz = z.subtract(v.getZ());
@@ -883,7 +883,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v second vector
* @return the distance between the instance and p according to the L<sub>∞</sub> norm
*/
- public T distanceInf(final Coordinates3D v) {
+ public T distanceInf(final Cartesian3D v) {
final T dx = x.subtract(v.getX()).abs();
final T dy = y.subtract(v.getY()).abs();
final T dz = z.subtract(v.getZ()).abs();
@@ -923,7 +923,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param v second vector
* @return the square of the distance between the instance and p
*/
- public T distanceSq(final Coordinates3D v) {
+ public T distanceSq(final Cartesian3D v) {
final T dx = x.subtract(v.getX());
final T dy = y.subtract(v.getY());
final T dz = z.subtract(v.getZ());
@@ -948,7 +948,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return the dot product v1.v2
*/
public static <T extends RealFieldElement<T>> T dotProduct(final FieldVector3D<T> v1,
- final Coordinates3D v2) {
+ final Cartesian3D v2) {
return v1.dotProduct(v2);
}
@@ -958,7 +958,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param <T> the type of the field elements
* @return the dot product v1.v2
*/
- public static <T extends RealFieldElement<T>> T dotProduct(final Coordinates3D v1,
+ public static <T extends RealFieldElement<T>> T dotProduct(final Cartesian3D v1,
final FieldVector3D<T> v2) {
return v2.dotProduct(v1);
}
@@ -981,7 +981,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return the cross product v1 ^ v2 as a new Vector
*/
public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
- final Coordinates3D v2) {
+ final Cartesian3D v2) {
return v1.crossProduct(v2);
}
@@ -991,7 +991,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param <T> the type of the field elements
* @return the cross product v1 ^ v2 as a new Vector
*/
- public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final Coordinates3D v1,
+ public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final Cartesian3D v1,
final FieldVector3D<T> v2) {
return new FieldVector3D<>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y),
v2.y.linearCombination(v1.getZ(), v2.x, -v1.getX(), v2.z),
@@ -1022,7 +1022,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return the distance between v1 and v2 according to the L<sub>1</sub> norm
*/
public static <T extends RealFieldElement<T>> T distance1(final FieldVector3D<T> v1,
- final Coordinates3D v2) {
+ final Cartesian3D v2) {
return v1.distance1(v2);
}
@@ -1035,7 +1035,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>1</sub> norm
*/
- public static <T extends RealFieldElement<T>> T distance1(final Coordinates3D v1,
+ public static <T extends RealFieldElement<T>> T distance1(final Cartesian3D v1,
final FieldVector3D<T> v2) {
return v2.distance1(v1);
}
@@ -1064,7 +1064,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return the distance between v1 and v2 according to the L<sub>2</sub> norm
*/
public static <T extends RealFieldElement<T>> T distance(final FieldVector3D<T> v1,
- final Coordinates3D v2) {
+ final Cartesian3D v2) {
return v1.distance(v2);
}
@@ -1077,7 +1077,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>2</sub> norm
*/
- public static <T extends RealFieldElement<T>> T distance(final Coordinates3D v1,
+ public static <T extends RealFieldElement<T>> T distance(final Cartesian3D v1,
final FieldVector3D<T> v2) {
return v2.distance(v1);
}
@@ -1106,7 +1106,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return the distance between v1 and v2 according to the L<sub>∞</sub> norm
*/
public static <T extends RealFieldElement<T>> T distanceInf(final FieldVector3D<T> v1,
- final Coordinates3D v2) {
+ final Cartesian3D v2) {
return v1.distanceInf(v2);
}
@@ -1119,7 +1119,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>∞</sub> norm
*/
- public static <T extends RealFieldElement<T>> T distanceInf(final Coordinates3D v1,
+ public static <T extends RealFieldElement<T>> T distanceInf(final Cartesian3D v1,
final FieldVector3D<T> v2) {
return v2.distanceInf(v1);
}
@@ -1148,7 +1148,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @return the square of the distance between v1 and v2
*/
public static <T extends RealFieldElement<T>> T distanceSq(final FieldVector3D<T> v1,
- final Coordinates3D v2) {
+ final Cartesian3D v2) {
return v1.distanceSq(v2);
}
@@ -1161,7 +1161,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl
* @param <T> the type of the field elements
* @return the square of the distance between v1 and v2
*/
- public static <T extends RealFieldElement<T>> T distanceSq(final Coordinates3D v1,
+ public static <T extends RealFieldElement<T>> T distanceSq(final Cartesian3D v1,
final FieldVector3D<T> v2) {
return v2.distanceSq(v1);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java
index d68bb94..4ec55a3 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.Vector;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.Embedding;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
@@ -41,10 +41,10 @@ import org.apache.commons.math4.util.Precision;
public class Line implements Embedding<Euclidean3D, Euclidean1D> {
/** Line direction. */
- private Coordinates3D direction;
+ private Cartesian3D direction;
/** Line point closest to the origin. */
- private Coordinates3D zero;
+ private Cartesian3D zero;
/** Tolerance below which points are considered identical. */
private final double tolerance;
@@ -56,7 +56,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @exception MathIllegalArgumentException if the points are equal
* @since 3.3
*/
- public Line(final Coordinates3D p1, final Coordinates3D p2, final double tolerance)
+ public Line(final Cartesian3D p1, final Cartesian3D p2, final double tolerance)
throws MathIllegalArgumentException {
reset(p1, p2);
this.tolerance = tolerance;
@@ -78,14 +78,14 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @param p2 second point belonging to the line (this can be any point, different from p1)
* @exception MathIllegalArgumentException if the points are equal
*/
- public void reset(final Coordinates3D p1, final Coordinates3D p2) throws MathIllegalArgumentException {
- final Coordinates3D delta = p2.subtract(p1);
+ public void reset(final Cartesian3D p1, final Cartesian3D p2) throws MathIllegalArgumentException {
+ final Cartesian3D delta = p2.subtract(p1);
final double norm2 = delta.getNormSq();
if (norm2 == 0.0) {
throw new MathIllegalArgumentException(LocalizedFormats.ZERO_NORM);
}
- this.direction = new Coordinates3D(1.0 / FastMath.sqrt(norm2), delta);
- zero = new Coordinates3D(1.0, p1, -p1.dotProduct(delta) / norm2, delta);
+ this.direction = new Cartesian3D(1.0 / FastMath.sqrt(norm2), delta);
+ zero = new Cartesian3D(1.0, p1, -p1.dotProduct(delta) / norm2, delta);
}
/** Get the tolerance below which points are considered identical.
@@ -108,14 +108,14 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
/** Get the normalized direction vector.
* @return normalized direction vector
*/
- public Coordinates3D getDirection() {
+ public Cartesian3D getDirection() {
return direction;
}
/** Get the line point closest to the origin.
* @return line point closest to the origin
*/
- public Coordinates3D getOrigin() {
+ public Cartesian3D getOrigin() {
return zero;
}
@@ -126,7 +126,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @param point point to check
* @return abscissa of the point
*/
- public double getAbscissa(final Coordinates3D point) {
+ public double getAbscissa(final Cartesian3D point) {
return point.subtract(zero).dotProduct(direction);
}
@@ -134,8 +134,8 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @param abscissa desired abscissa for the point
* @return one point belonging to the line, at specified abscissa
*/
- public Coordinates3D pointAt(final double abscissa) {
- return new Coordinates3D(1.0, zero, abscissa, direction);
+ public Cartesian3D pointAt(final double abscissa) {
+ return new Cartesian3D(1.0, zero, abscissa, direction);
}
/** Transform a space point into a sub-space point.
@@ -143,7 +143,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @return (n-1)-dimension point of the sub-space corresponding to
* the specified space point
*/
- public Coordinates1D toSubSpace(Vector<Euclidean3D> vector) {
+ public Cartesian1D toSubSpace(Vector<Euclidean3D> vector) {
return toSubSpace((Point<Euclidean3D>) vector);
}
@@ -152,24 +152,42 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @return n-dimension point of the space corresponding to the
* specified sub-space point
*/
- public Coordinates3D toSpace(Vector<Euclidean1D> vector) {
+ public Cartesian3D toSpace(Vector<Euclidean1D> vector) {
return toSpace((Point<Euclidean1D>) vector);
}
/** {@inheritDoc}
- * @see #getAbscissa(Vector3D)
+ * @see #getAbscissa(Cartesian3D)
*/
@Override
- public Coordinates1D toSubSpace(final Point<Euclidean3D> point) {
- return new Coordinates1D(getAbscissa((Coordinates3D) point));
+ public Cartesian1D toSubSpace(final Point<Euclidean3D> point) {
+ return toSubSpace((Cartesian3D) point);
}
/** {@inheritDoc}
* @see #pointAt(double)
*/
@Override
- public Coordinates3D toSpace(final Point<Euclidean1D> point) {
- return pointAt(((Coordinates1D) point).getX());
+ public Cartesian3D toSpace(final Point<Euclidean1D> point) {
+ return toSpace((Cartesian1D) point);
+ }
+
+ /** Transform a space point into a sub-space point.
+ * @param point n-dimension point of the space
+ * @return (n-1)-dimension point of the sub-space corresponding to
+ * the specified space point
+ */
+ public Cartesian1D toSubSpace(final Cartesian3D point) {
+ return new Cartesian1D(getAbscissa(point));
+ }
+
+ /** Transform a sub-space point into a space point.
+ * @param point (n-1)-dimension point of the sub-space
+ * @return n-dimension point of the space corresponding to the
+ * specified sub-space point
+ */
+ public Cartesian3D toSpace(final Cartesian1D point) {
+ return pointAt(point.getX());
}
/** Check if the instance is similar to another line.
@@ -180,7 +198,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @return true if the lines are similar
*/
public boolean isSimilarTo(final Line line) {
- final double angle = Coordinates3D.angle(direction, line.direction);
+ final double angle = Cartesian3D.angle(direction, line.direction);
return ((angle < tolerance) || (angle > (FastMath.PI - tolerance))) && contains(line.zero);
}
@@ -188,7 +206,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @param p point to check
* @return true if p belongs to the line
*/
- public boolean contains(final Coordinates3D p) {
+ public boolean contains(final Cartesian3D p) {
return distance(p) < tolerance;
}
@@ -196,9 +214,9 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @param p to check
* @return distance between the instance and the point
*/
- public double distance(final Coordinates3D p) {
- final Coordinates3D d = p.subtract(zero);
- final Coordinates3D n = new Coordinates3D(1.0, d, -d.dotProduct(direction), direction);
+ public double distance(final Cartesian3D p) {
+ final Cartesian3D d = p.subtract(zero);
+ final Cartesian3D n = new Cartesian3D(1.0, d, -d.dotProduct(direction), direction);
return n.getNorm();
}
@@ -208,7 +226,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
*/
public double distance(final Line line) {
- final Coordinates3D normal = Coordinates3D.crossProduct(direction, line.direction);
+ final Cartesian3D normal = Cartesian3D.crossProduct(direction, line.direction);
final double n = normal.getNorm();
if (n < Precision.SAFE_MIN) {
// lines are parallel
@@ -226,7 +244,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @param line line to check against the instance
* @return point of the instance closest to another line
*/
- public Coordinates3D closestPoint(final Line line) {
+ public Cartesian3D closestPoint(final Line line) {
final double cos = direction.dotProduct(line.direction);
final double n = 1 - cos * cos;
@@ -235,11 +253,11 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
return zero;
}
- final Coordinates3D delta0 = line.zero.subtract(zero);
+ final Cartesian3D delta0 = line.zero.subtract(zero);
final double a = delta0.dotProduct(direction);
final double b = delta0.dotProduct(line.direction);
- return new Coordinates3D(1, zero, (a - b * cos) / n, direction);
+ return new Cartesian3D(1, zero, (a - b * cos) / n, direction);
}
@@ -248,8 +266,8 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
* @return intersection point of the instance and the other line
* or null if there are no intersection points
*/
- public Coordinates3D intersection(final Line line) {
- final Coordinates3D closest = closestPoint(line);
+ public Cartesian3D intersection(final Line line) {
+ final Cartesian3D closest = closestPoint(line);
return line.contains(closest) ? closest : null;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java
index 90eeef7..71657e2 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java
@@ -21,7 +21,7 @@ import java.util.ArrayList;
import org.apache.commons.math4.geometry.Point;
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.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor;
@@ -38,29 +38,29 @@ import org.apache.commons.math4.util.FastMath;
public class OutlineExtractor {
/** Abscissa axis of the projection plane. */
- private final Coordinates3D u;
+ private final Cartesian3D u;
/** Ordinate axis of the projection plane. */
- private final Coordinates3D v;
+ private final Cartesian3D v;
/** Normal of the projection plane (viewing direction). */
- private final Coordinates3D w;
+ private final Cartesian3D w;
/** Build an extractor for a specific projection plane.
* @param u abscissa axis of the projection point
* @param v ordinate axis of the projection point
*/
- public OutlineExtractor(final Coordinates3D u, final Coordinates3D v) {
+ public OutlineExtractor(final Cartesian3D u, final Cartesian3D v) {
this.u = u;
this.v = v;
- w = Coordinates3D.crossProduct(u, v);
+ w = Cartesian3D.crossProduct(u, v);
}
/** Extract the outline of a polyhedrons set.
* @param polyhedronsSet polyhedrons set whose outline must be extracted
* @return an outline, as an array of loops.
*/
- public Coordinates2D[][] getOutline(final PolyhedronsSet polyhedronsSet) {
+ public Cartesian2D[][] getOutline(final PolyhedronsSet polyhedronsSet) {
// project all boundary facets into one polygons set
final BoundaryProjector projector = new BoundaryProjector(polyhedronsSet.getTolerance());
@@ -68,9 +68,9 @@ public class OutlineExtractor {
final PolygonsSet projected = projector.getProjected();
// Remove the spurious intermediate vertices from the outline
- final Coordinates2D[][] outline = projected.getVertices();
+ final Cartesian2D[][] outline = projected.getVertices();
for (int i = 0; i < outline.length; ++i) {
- final Coordinates2D[] rawLoop = outline[i];
+ final Cartesian2D[] rawLoop = outline[i];
int end = rawLoop.length;
int j = 0;
while (j < end) {
@@ -87,7 +87,7 @@ public class OutlineExtractor {
}
if (end != rawLoop.length) {
// resize the array
- outline[i] = new Coordinates2D[end];
+ outline[i] = new Cartesian2D[end];
System.arraycopy(rawLoop, 0, outline[i], 0, end);
}
}
@@ -104,10 +104,10 @@ public class OutlineExtractor {
* @param i index of the point to check (must be between 0 and n-1)
* @return true if the point is exactly between its neighbors
*/
- private boolean pointIsBetween(final Coordinates2D[] loop, final int n, final int i) {
- final Coordinates2D previous = loop[(i + n - 1) % n];
- final Coordinates2D current = loop[i];
- final Coordinates2D next = loop[(i + 1) % n];
+ private boolean pointIsBetween(final Cartesian2D[] loop, final int n, final int i) {
+ final Cartesian2D previous = loop[(i + n - 1) % n];
+ final Cartesian2D current = loop[i];
+ final Cartesian2D next = loop[(i + 1) % n];
final double dx1 = current.getX() - previous.getX();
final double dy1 = current.getY() - previous.getY();
final double dx2 = next.getX() - current.getX();
@@ -174,16 +174,16 @@ public class OutlineExtractor {
final double scal = plane.getNormal().dotProduct(w);
if (FastMath.abs(scal) > 1.0e-3) {
- Coordinates2D[][] vertices =
+ Cartesian2D[][] vertices =
((PolygonsSet) absFacet.getRemainingRegion()).getVertices();
if ((scal < 0) ^ reversed) {
// the facet is seen from the inside,
// we need to invert its boundary orientation
- final Coordinates2D[][] newVertices = new Coordinates2D[vertices.length][];
+ final Cartesian2D[][] newVertices = new Cartesian2D[vertices.length][];
for (int i = 0; i < vertices.length; ++i) {
- final Coordinates2D[] loop = vertices[i];
- final Coordinates2D[] newLoop = new Coordinates2D[loop.length];
+ final Cartesian2D[] loop = vertices[i];
+ final Cartesian2D[] newLoop = new Cartesian2D[loop.length];
if (loop[0] == null) {
newLoop[0] = null;
for (int j = 1; j < loop.length; ++j) {
@@ -204,17 +204,17 @@ public class OutlineExtractor {
// compute the projection of the facet in the outline plane
final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>();
- for (Coordinates2D[] loop : vertices) {
+ for (Cartesian2D[] loop : vertices) {
final boolean closed = loop[0] != null;
int previous = closed ? (loop.length - 1) : 1;
- Coordinates3D previous3D = plane.toSpace((Point<Euclidean2D>) loop[previous]);
+ Cartesian3D previous3D = plane.toSpace(loop[previous]);
int current = (previous + 1) % loop.length;
- Coordinates2D pPoint = new Coordinates2D(previous3D.dotProduct(u),
+ Cartesian2D pPoint = new Cartesian2D(previous3D.dotProduct(u),
previous3D.dotProduct(v));
while (current < loop.length) {
- final Coordinates3D current3D = plane.toSpace((Point<Euclidean2D>) loop[current]);
- final Coordinates2D cPoint = new Coordinates2D(current3D.dotProduct(u),
+ final Cartesian3D current3D = plane.toSpace((Point<Euclidean2D>) loop[current]);
+ final Cartesian2D cPoint = new Cartesian2D(current3D.dotProduct(u),
current3D.dotProduct(v));
final org.apache.commons.math4.geometry.euclidean.twod.Line line =
new org.apache.commons.math4.geometry.euclidean.twod.Line(pPoint, cPoint, tolerance);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java
index 0038194..6ecd727 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java
@@ -19,11 +19,11 @@ package org.apache.commons.math4.geometry.euclidean.threed;
import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
import org.apache.commons.math4.geometry.Point;
-import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.Vector;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
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.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.partitioning.Embedding;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
import org.apache.commons.math4.util.FastMath;
@@ -37,16 +37,16 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
private double originOffset;
/** Origin of the plane frame. */
- private Coordinates3D origin;
+ private Cartesian3D origin;
/** First vector of the plane frame (in plane). */
- private Coordinates3D u;
+ private Cartesian3D u;
/** Second vector of the plane frame (in plane). */
- private Coordinates3D v;
+ private Cartesian3D v;
/** Third vector of the plane frame (plane normal). */
- private Coordinates3D w;
+ private Cartesian3D w;
/** Tolerance below which points are considered identical. */
private final double tolerance;
@@ -57,7 +57,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @exception MathArithmeticException if the normal norm is too small
* @since 3.3
*/
- public Plane(final Coordinates3D normal, final double tolerance)
+ public Plane(final Cartesian3D normal, final double tolerance)
throws MathArithmeticException {
setNormal(normal);
this.tolerance = tolerance;
@@ -72,7 +72,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @exception MathArithmeticException if the normal norm is too small
* @since 3.3
*/
- public Plane(final Coordinates3D p, final Coordinates3D normal, final double tolerance)
+ public Plane(final Cartesian3D p, final Cartesian3D normal, final double tolerance)
throws MathArithmeticException {
setNormal(normal);
this.tolerance = tolerance;
@@ -90,7 +90,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @exception MathArithmeticException if the points do not constitute a plane
* @since 3.3
*/
- public Plane(final Coordinates3D p1, final Coordinates3D p2, final Coordinates3D p3, final double tolerance)
+ public Plane(final Cartesian3D p1, final Cartesian3D p2, final Cartesian3D p3, final double tolerance)
throws MathArithmeticException {
this(p1, p2.subtract(p1).crossProduct(p3.subtract(p1)), tolerance);
}
@@ -126,7 +126,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @param normal normal direction to the plane
* @exception MathArithmeticException if the normal norm is too small
*/
- public void reset(final Coordinates3D p, final Coordinates3D normal) throws MathArithmeticException {
+ public void reset(final Cartesian3D p, final Cartesian3D normal) throws MathArithmeticException {
setNormal(normal);
originOffset = -p.dotProduct(w);
setFrame();
@@ -150,20 +150,20 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @param normal normal direction to the plane (will be copied)
* @exception MathArithmeticException if the normal norm is too small
*/
- private void setNormal(final Coordinates3D normal) throws MathArithmeticException {
+ private void setNormal(final Cartesian3D normal) throws MathArithmeticException {
final double norm = normal.getNorm();
if (norm < 1.0e-10) {
throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
}
- w = new Coordinates3D(1.0 / norm, normal);
+ w = new Cartesian3D(1.0 / norm, normal);
}
/** Reset the plane frame.
*/
private void setFrame() {
- origin = new Coordinates3D(-originOffset, w);
+ origin = new Cartesian3D(-originOffset, w);
u = w.orthogonal();
- v = Coordinates3D.crossProduct(w, u);
+ v = Cartesian3D.crossProduct(w, u);
}
/** Get the origin point of the plane frame.
@@ -172,7 +172,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @return the origin point of the plane frame (point closest to the
* 3D-space origin)
*/
- public Coordinates3D getOrigin() {
+ public Cartesian3D getOrigin() {
return origin;
}
@@ -184,7 +184,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @see #getU
* @see #getV
*/
- public Coordinates3D getNormal() {
+ public Cartesian3D getNormal() {
return w;
}
@@ -196,7 +196,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @see #getV
* @see #getNormal
*/
- public Coordinates3D getU() {
+ public Cartesian3D getU() {
return u;
}
@@ -208,7 +208,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @see #getU
* @see #getNormal
*/
- public Coordinates3D getV() {
+ public Cartesian3D getV() {
return v;
}
@@ -240,54 +240,67 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* reversed.</p>
*/
public void revertSelf() {
- final Coordinates3D tmp = u;
+ final Cartesian3D tmp = u;
u = v;
v = tmp;
w = w.negate();
originOffset = -originOffset;
}
- /** Transform a space point into a sub-space point.
- * @param vector n-dimension point of the space
- * @return (n-1)-dimension point of the sub-space corresponding to
- * the specified space point
+ /** Transform a space vector into a sub-space vector.
+ * @param vector n-dimension vector of the space
+ * @return (n-1)-dimension vector of the sub-space corresponding to
+ * the specified space vector
*/
-// public Coordinates2D toSubSpace(Vector<Euclidean3D> vector) {
-// return toSubSpace((Point<Euclidean3D>) vector);
-// }
+ public Cartesian2D toSubSpace(Vector<Euclidean3D> vector) {
+ return toSubSpace((Cartesian3D) vector);
+ }
/** Transform a sub-space point into a space point.
* @param vector (n-1)-dimension point of the sub-space
* @return n-dimension point of the space corresponding to the
* specified sub-space point
*/
-// public Coordinates3D toSpace(Vector<Euclidean2D> vector) {
-// return toSpace((Point<Euclidean2D>) vector);
-// }
+ public Cartesian3D toSpace(Vector<Euclidean2D> vector) {
+ return toSpace((Cartesian2D) vector);
+ }
/** Transform a 3D space point into an in-plane point.
- * @param point point of the space (must be a {@link Coordinates3D
- * Vector3D} instance)
- * @return in-plane point (really a {@link
- * org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D Vector2D} instance)
+ * @param point point of the space (must be a {@link Cartesian3D} instance)
+ * @return in-plane point
* @see #toSpace
*/
@Override
- public Coordinates2D toSubSpace(final Point<Euclidean3D> point) {
- final Coordinates3D p3D = (Coordinates3D) point;
- return new Coordinates2D(p3D.dotProduct(u), p3D.dotProduct(v));
+ public Cartesian2D toSubSpace(final Point<Euclidean3D> point) {
+ return toSubSpace((Cartesian3D) point);
}
/** Transform an in-plane point into a 3D space point.
- * @param point in-plane point (must be a {@link
- * org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D Vector2D} instance)
- * @return 3D space point (really a {@link Coordinates3D Vector3D} instance)
+ * @param point in-plane point (must be a {@link Cartesian2D} instance)
+ * @return 3D space point
* @see #toSubSpace
*/
@Override
- public Coordinates3D toSpace(final Point<Euclidean2D> point) {
- final Coordinates2D p2D = (Coordinates2D) point;
- return new Coordinates3D(p2D.getX(), u, p2D.getY(), v, -originOffset, w);
+ public Cartesian3D toSpace(final Point<Euclidean2D> point) {
+ return toSpace((Cartesian2D) point);
+ }
+
+ /** Transform a 3D space point into an in-plane point.
+ * @param point point of the space
+ * @return in-plane point
+ * @see #toSpace
+ */
+ public Cartesian2D toSubSpace(final Cartesian3D point) {
+ return new Cartesian2D(point.dotProduct(u), point.dotProduct(v));
+ }
+
+ /** Transform an in-plane point into a 3D space point.
+ * @param point in-plane point
+ * @return 3D space point
+ * @see #toSubSpace
+ */
+ public Cartesian3D toSpace(final Cartesian2D point) {
+ return new Cartesian3D(point.getX(), u, point.getY(), v, -originOffset, w);
}
/** Get one point from the 3D-space.
@@ -297,8 +310,8 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @return one point in the 3D-space, with given coordinates and offset
* relative to the plane
*/
- public Coordinates3D getPointAt(final Coordinates2D inPlane, final double offset) {
- return new Coordinates3D(inPlane.getX(), u, inPlane.getY(), v, offset - originOffset, w);
+ public Cartesian3D getPointAt(final Cartesian2D inPlane, final double offset) {
+ return new Cartesian3D(inPlane.getX(), u, inPlane.getY(), v, offset - originOffset, w);
}
/** Check if the instance is similar to another plane.
@@ -309,7 +322,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @return true if the planes are similar
*/
public boolean isSimilarTo(final Plane plane) {
- final double angle = Coordinates3D.angle(w, plane.w);
+ final double angle = Cartesian3D.angle(w, plane.w);
return ((angle < 1.0e-10) && (FastMath.abs(originOffset - plane.originOffset) < tolerance)) ||
((angle > (FastMath.PI - 1.0e-10)) && (FastMath.abs(originOffset + plane.originOffset) < tolerance));
}
@@ -320,9 +333,9 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @param rotation vectorial rotation operator
* @return a new plane
*/
- public Plane rotate(final Coordinates3D center, final Rotation rotation) {
+ public Plane rotate(final Cartesian3D center, final Rotation rotation) {
- final Coordinates3D delta = origin.subtract(center);
+ final Cartesian3D delta = origin.subtract(center);
final Plane plane = new Plane(center.add(rotation.applyTo(delta)),
rotation.applyTo(w), tolerance);
@@ -339,7 +352,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @param translation translation to apply
* @return a new plane
*/
- public Plane translate(final Coordinates3D translation) {
+ public Plane translate(final Cartesian3D translation) {
final Plane plane = new Plane(origin.add(translation), w, tolerance);
@@ -356,15 +369,15 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @return intersection point between between the line and the
* instance (null if the line is parallel to the instance)
*/
- public Coordinates3D intersection(final Line line) {
- final Coordinates3D direction = line.getDirection();
+ public Cartesian3D intersection(final Line line) {
+ final Cartesian3D direction = line.getDirection();
final double dot = w.dotProduct(direction);
if (FastMath.abs(dot) < 1.0e-10) {
return null;
}
- final Coordinates3D point = line.toSpace((Point<Euclidean1D>) Coordinates1D.ZERO);
+ final Cartesian3D point = line.toSpace(Cartesian1D.ZERO);
final double k = -(originOffset + w.dotProduct(point)) / dot;
- return new Coordinates3D(1.0, point, k, direction);
+ return new Cartesian3D(1.0, point, k, direction);
}
/** Build the line shared by the instance and another plane.
@@ -373,11 +386,11 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* other plane (really a {@link Line Line} instance)
*/
public Line intersection(final Plane other) {
- final Coordinates3D direction = Coordinates3D.crossProduct(w, other.w);
+ final Cartesian3D direction = Cartesian3D.crossProduct(w, other.w);
if (direction.getNorm() < tolerance) {
return null;
}
- final Coordinates3D point = intersection(this, other, new Plane(direction, tolerance));
+ final Cartesian3D point = intersection(this, other, new Plane(direction, tolerance));
return new Line(point, point.add(direction), tolerance);
}
@@ -387,7 +400,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @param plane3 third plane2
* @return intersection point of three planes, null if some planes are parallel
*/
- public static Coordinates3D intersection(final Plane plane1, final Plane plane2, final Plane plane3) {
+ public static Cartesian3D intersection(final Plane plane1, final Plane plane2, final Plane plane3) {
// coefficients of the three planes linear equations
final double a1 = plane1.w.getX();
@@ -416,7 +429,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
}
final double r = 1.0 / determinant;
- return new Coordinates3D(
+ return new Cartesian3D(
(-a23 * d1 - (c1 * b3 - c3 * b1) * d2 - (c2 * b1 - c1 * b2) * d3) * r,
(-b23 * d1 - (c3 * a1 - c1 * a3) * d2 - (c1 * a2 - c2 * a1) * d3) * r,
(-c23 * d1 - (b1 * a3 - b3 * a1) * d2 - (b2 * a1 - b1 * a2) * d3) * r);
@@ -444,7 +457,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @param p point to check
* @return true if p belongs to the plane
*/
- public boolean contains(final Coordinates3D p) {
+ public boolean contains(final Cartesian3D p) {
return FastMath.abs(getOffset(p)) < tolerance;
}
@@ -480,7 +493,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
*/
@Override
public double getOffset(final Point<Euclidean3D> point) {
- return ((Coordinates3D) point).dotProduct(w) + originOffset;
+ return ((Cartesian3D) point).dotProduct(w) + originOffset;
}
/** Check if the instance has the same orientation as another hyperplane.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java
index fcf26f5..cf15f22 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java
@@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
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.AbstractRegion;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor;
@@ -123,7 +123,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* @exception MathIllegalArgumentException if some basic sanity checks fail
* @since 3.5
*/
- public PolyhedronsSet(final List<Coordinates3D> vertices, final List<int[]> facets,
+ public PolyhedronsSet(final List<Cartesian3D> vertices, final List<int[]> facets,
final double tolerance) {
super(buildBoundary(vertices, facets, tolerance), tolerance);
}
@@ -164,12 +164,12 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
// too thin box, build an empty polygons set
return new BSPTree<>(Boolean.FALSE);
}
- final Plane pxMin = new Plane(new Coordinates3D(xMin, 0, 0), Coordinates3D.MINUS_I, tolerance);
- final Plane pxMax = new Plane(new Coordinates3D(xMax, 0, 0), Coordinates3D.PLUS_I, tolerance);
- final Plane pyMin = new Plane(new Coordinates3D(0, yMin, 0), Coordinates3D.MINUS_J, tolerance);
- final Plane pyMax = new Plane(new Coordinates3D(0, yMax, 0), Coordinates3D.PLUS_J, tolerance);
- final Plane pzMin = new Plane(new Coordinates3D(0, 0, zMin), Coordinates3D.MINUS_K, tolerance);
- final Plane pzMax = new Plane(new Coordinates3D(0, 0, zMax), Coordinates3D.PLUS_K, tolerance);
+ final Plane pxMin = new Plane(new Cartesian3D(xMin, 0, 0), Cartesian3D.MINUS_I, tolerance);
+ final Plane pxMax = new Plane(new Cartesian3D(xMax, 0, 0), Cartesian3D.PLUS_I, tolerance);
+ final Plane pyMin = new Plane(new Cartesian3D(0, yMin, 0), Cartesian3D.MINUS_J, tolerance);
+ final Plane pyMax = new Plane(new Cartesian3D(0, yMax, 0), Cartesian3D.PLUS_J, tolerance);
+ final Plane pzMin = new Plane(new Cartesian3D(0, 0, zMin), Cartesian3D.MINUS_K, tolerance);
+ final Plane pzMax = new Plane(new Cartesian3D(0, 0, zMax), Cartesian3D.PLUS_K, tolerance);
final Region<Euclidean3D> boundary =
new RegionFactory<Euclidean3D>().buildConvex(pxMin, pxMax, pyMin, pyMax, pzMin, pzMax);
return boundary.getTree(false);
@@ -183,15 +183,15 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* @exception MathIllegalArgumentException if some basic sanity checks fail
* @since 3.5
*/
- private static List<SubHyperplane<Euclidean3D>> buildBoundary(final List<Coordinates3D> vertices,
+ private static List<SubHyperplane<Euclidean3D>> buildBoundary(final List<Cartesian3D> vertices,
final List<int[]> facets,
final double tolerance) {
// check vertices distances
for (int i = 0; i < vertices.size() - 1; ++i) {
- final Coordinates3D vi = vertices.get(i);
+ final Cartesian3D vi = vertices.get(i);
for (int j = i + 1; j < vertices.size(); ++j) {
- if (Coordinates3D.distance(vi, vertices.get(j)) <= tolerance) {
+ if (Cartesian3D.distance(vi, vertices.get(j)) <= tolerance) {
throw new MathIllegalArgumentException(LocalizedFormats.CLOSE_VERTICES,
vi.getX(), vi.getY(), vi.getZ());
}
@@ -216,8 +216,8 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
found = found || (v == vA);
}
if (!found) {
- final Coordinates3D start = vertices.get(vA);
- final Coordinates3D end = vertices.get(vB);
+ final Cartesian3D start = vertices.get(vA);
+ final Cartesian3D end = vertices.get(vB);
throw new MathIllegalArgumentException(LocalizedFormats.EDGE_CONNECTED_TO_ONE_FACET,
start.getX(), start.getY(), start.getZ(),
end.getX(), end.getY(), end.getZ());
@@ -235,9 +235,9 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
tolerance);
// check all points are in the plane
- final Coordinates2D[] two2Points = new Coordinates2D[facet.length];
+ final Cartesian2D[] two2Points = new Cartesian2D[facet.length];
for (int i = 0 ; i < facet.length; ++i) {
- final Coordinates3D v = vertices.get(facet[i]);
+ final Cartesian3D v = vertices.get(facet[i]);
if (!plane.contains(v)) {
throw new MathIllegalArgumentException(LocalizedFormats.OUT_OF_PLANE,
v.getX(), v.getY(), v.getZ());
@@ -261,7 +261,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* @exception MathIllegalArgumentException if some facets have fewer than 3 vertices
* @since 3.5
*/
- private static int[][] findReferences(final List<Coordinates3D> vertices, final List<int[]> facets) {
+ private static int[][] findReferences(final List<Cartesian3D> vertices, final List<int[]> facets) {
// find the maximum number of facets a vertex belongs to
final int[] nbFacets = new int[vertices.size()];
@@ -306,7 +306,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* once in the successors list (which means one facet orientation is wrong)
* @since 3.5
*/
- private static int[][] successors(final List<Coordinates3D> vertices, final List<int[]> facets,
+ private static int[][] successors(final List<Cartesian3D> vertices, final List<int[]> facets,
final int[][] references) {
// create an array large enough
@@ -329,8 +329,8 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
successors[v][k] = facet[(i + 1) % facet.length];
for (int l = 0; l < k; ++l) {
if (successors[v][l] == successors[v][k]) {
- final Coordinates3D start = vertices.get(v);
- final Coordinates3D end = vertices.get(successors[v][k]);
+ final Cartesian3D start = vertices.get(v);
+ final Cartesian3D end = vertices.get(successors[v][k]);
throw new MathIllegalArgumentException(LocalizedFormats.FACET_ORIENTATION_MISMATCH,
start.getX(), start.getY(), start.getZ(),
end.getX(), end.getY(), end.getZ());
@@ -361,11 +361,11 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
// the polyhedrons set as a finite outside
// surrounded by an infinite inside
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean3D>) Coordinates3D.NaN);
+ setBarycenter((Point<Euclidean3D>) Cartesian3D.NaN);
} else {
// the polyhedrons set is finite, apply the remaining scaling factors
setSize(getSize() / 3.0);
- setBarycenter((Point<Euclidean3D>) new Coordinates3D(1.0 / (4 * getSize()), (Coordinates3D) getBarycenter()));
+ setBarycenter((Point<Euclidean3D>) new Cartesian3D(1.0 / (4 * getSize()), (Cartesian3D) getBarycenter()));
}
}
@@ -376,7 +376,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
/** Simple constructor. */
FacetsContributionVisitor() {
setSize(0);
- setBarycenter((Point<Euclidean3D>) new Coordinates3D(0, 0, 0));
+ setBarycenter((Point<Euclidean3D>) new Cartesian3D(0, 0, 0));
}
/** {@inheritDoc} */
@@ -415,18 +415,18 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
if (Double.isInfinite(area)) {
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean3D>) Coordinates3D.NaN);
+ setBarycenter((Point<Euclidean3D>) Cartesian3D.NaN);
} else {
final Plane plane = (Plane) facet.getHyperplane();
- final Coordinates3D facetB = plane.toSpace(polygon.getBarycenter());
+ final Cartesian3D facetB = plane.toSpace(polygon.getBarycenter());
double scaled = area * facetB.dotProduct(plane.getNormal());
if (reversed) {
scaled = -scaled;
}
setSize(getSize() + scaled);
- setBarycenter((Point<Euclidean3D>) new Coordinates3D(1.0, (Coordinates3D) getBarycenter(), scaled, facetB));
+ setBarycenter((Point<Euclidean3D>) new Cartesian3D(1.0, (Cartesian3D) getBarycenter(), scaled, facetB));
}
@@ -441,7 +441,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* given point, or null if the line does not intersect any
* sub-hyperplane
*/
- public SubHyperplane<Euclidean3D> firstIntersection(final Coordinates3D point, final Line line) {
+ public SubHyperplane<Euclidean3D> firstIntersection(final Cartesian3D point, final Line line) {
return recurseFirstIntersection(getTree(true), point, line);
}
@@ -454,7 +454,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* sub-hyperplane
*/
private SubHyperplane<Euclidean3D> recurseFirstIntersection(final BSPTree<Euclidean3D> node,
- final Coordinates3D point,
+ final Cartesian3D point,
final Line line) {
final SubHyperplane<Euclidean3D> cut = node.getCut();
@@ -494,7 +494,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
if (!in) {
// search in the cut hyperplane
- final Coordinates3D hit3D = plane.intersection(line);
+ final Cartesian3D hit3D = plane.intersection(line);
if (hit3D != null && line.getAbscissa(hit3D) > line.getAbscissa(point)) {
final SubHyperplane<Euclidean3D> facet = boundaryFacet(hit3D, node);
if (facet != null) {
@@ -514,9 +514,9 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* @return the boundary facet this points belongs to (or null if it
* does not belong to any boundary facet)
*/
- private SubHyperplane<Euclidean3D> boundaryFacet(final Coordinates3D point,
+ private SubHyperplane<Euclidean3D> boundaryFacet(final Cartesian3D point,
final BSPTree<Euclidean3D> node) {
- final Coordinates2D point2D = ((Plane) node.getCut().getHyperplane()).toSubSpace((Point<Euclidean3D>) point);
+ final Cartesian2D point2D = ((Plane) node.getCut().getHyperplane()).toSubSpace(point);
@SuppressWarnings("unchecked")
final BoundaryAttribute<Euclidean3D> attribute =
(BoundaryAttribute<Euclidean3D>) node.getAttribute();
@@ -537,7 +537,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* @param rotation vectorial rotation operator
* @return a new instance representing the rotated region
*/
- public PolyhedronsSet rotate(final Coordinates3D center, final Rotation rotation) {
+ public PolyhedronsSet rotate(final Cartesian3D center, final Rotation rotation) {
return (PolyhedronsSet) applyTransform(new RotationTransform(center, rotation));
}
@@ -545,7 +545,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
private static class RotationTransform implements Transform<Euclidean3D, Euclidean2D> {
/** Center point of the rotation. */
- private final Coordinates3D center;
+ private final Cartesian3D center;
/** Vectorial rotation. */
private final Rotation rotation;
@@ -560,16 +560,16 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* @param center center point of the rotation
* @param rotation vectorial rotation
*/
- RotationTransform(final Coordinates3D center, final Rotation rotation) {
+ RotationTransform(final Cartesian3D center, final Rotation rotation) {
this.center = center;
this.rotation = rotation;
}
/** {@inheritDoc} */
@Override
- public Coordinates3D apply(final Point<Euclidean3D> point) {
- final Coordinates3D delta = ((Coordinates3D) point).subtract(center);
- return new Coordinates3D(1.0, center, 1.0, rotation.applyTo(delta));
+ public Cartesian3D apply(final Point<Euclidean3D> point) {
+ final Cartesian3D delta = ((Cartesian3D) point).subtract(center);
+ return new Cartesian3D(1.0, center, 1.0, rotation.applyTo(delta));
}
/** {@inheritDoc} */
@@ -588,12 +588,12 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
final Plane oPlane = (Plane) original;
final Plane tPlane = (Plane) transformed;
- final Coordinates3D p00 = oPlane.getOrigin();
- final Coordinates3D p10 = oPlane.toSpace((Point<Euclidean2D>) new Coordinates2D(1.0, 0.0));
- final Coordinates3D p01 = oPlane.toSpace((Point<Euclidean2D>) new Coordinates2D(0.0, 1.0));
- final Coordinates2D tP00 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p00));
- final Coordinates2D tP10 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p10));
- final Coordinates2D tP01 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p01));
+ final Cartesian3D p00 = oPlane.getOrigin();
+ final Cartesian3D p10 = oPlane.toSpace(new Cartesian2D(1.0, 0.0));
+ final Cartesian3D p01 = oPlane.toSpace(new Cartesian2D(0.0, 1.0));
+ final Cartesian2D tP00 = tPlane.toSubSpace(apply(p00));
+ final Cartesian2D tP10 = tPlane.toSubSpace(apply(p10));
+ final Cartesian2D tP01 = tPlane.toSubSpace(apply(p01));
cachedOriginal = (Plane) original;
cachedTransform =
@@ -615,7 +615,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
* @param translation translation to apply
* @return a new instance representing the translated region
*/
- public PolyhedronsSet translate(final Coordinates3D translation) {
+ public PolyhedronsSet translate(final Cartesian3D translation) {
return (PolyhedronsSet) applyTransform(new TranslationTransform(translation));
}
@@ -623,7 +623,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
private static class TranslationTransform implements Transform<Euclidean3D, Euclidean2D> {
/** Translation vector. */
- private final Coordinates3D translation;
+ private final Cartesian3D translation;
/** Cached original hyperplane. */
private Plane cachedOriginal;
@@ -634,14 +634,14 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
/** Build a translation transform.
* @param translation translation vector
*/
- TranslationTransform(final Coordinates3D translation) {
+ TranslationTransform(final Cartesian3D translation) {
this.translation = translation;
}
/** {@inheritDoc} */
@Override
- public Coordinates3D apply(final Point<Euclidean3D> point) {
- return new Coordinates3D(1.0, (Coordinates3D) point, 1.0, translation);
+ public Cartesian3D apply(final Point<Euclidean3D> point) {
+ return new Cartesian3D(1.0, (Cartesian3D) point, 1.0, translation);
}
/** {@inheritDoc} */
@@ -660,7 +660,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
final Plane oPlane = (Plane) original;
final Plane tPlane = (Plane) transformed;
- final Coordinates2D shift = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin()));
+ final Cartesian2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin()));
cachedOriginal = (Plane) original;
cachedTransform =
[02/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
Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java
index 41f9d77..cbbd003 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.euclidean.twod;
import org.apache.commons.math4.geometry.euclidean.twod.Line;
import org.apache.commons.math4.geometry.euclidean.twod.Segment;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -27,20 +27,20 @@ public class SegmentTest {
@Test
public void testDistance() {
- Coordinates2D start = new Coordinates2D(2, 2);
- Coordinates2D end = new Coordinates2D(-2, -2);
+ Cartesian2D start = new Cartesian2D(2, 2);
+ Cartesian2D end = new Cartesian2D(-2, -2);
Segment segment = new Segment(start, end, new Line(start, end, 1.0e-10));
// distance to center of segment
- Assert.assertEquals(FastMath.sqrt(2), segment.distance(new Coordinates2D(1, -1)), 1.0e-10);
+ Assert.assertEquals(FastMath.sqrt(2), segment.distance(new Cartesian2D(1, -1)), 1.0e-10);
// distance a point on segment
- Assert.assertEquals(FastMath.sin(Math.PI / 4.0), segment.distance(new Coordinates2D(0, -1)), 1.0e-10);
+ Assert.assertEquals(FastMath.sin(Math.PI / 4.0), segment.distance(new Cartesian2D(0, -1)), 1.0e-10);
// distance to end point
- Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Coordinates2D(0, 4)), 1.0e-10);
+ Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Cartesian2D(0, 4)), 1.0e-10);
// distance to start point
- Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Coordinates2D(0, -4)), 1.0e-10);
+ Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Cartesian2D(0, -4)), 1.0e-10);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java
index c59ab8c..cdfc2c0 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math4.geometry.euclidean.twod.Line;
import org.apache.commons.math4.geometry.euclidean.twod.Segment;
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.RegionFactory;
import org.junit.Assert;
import org.junit.Test;
@@ -32,19 +32,19 @@ public class SubLineTest {
@Test
public void testEndPoints() {
- Coordinates2D p1 = new Coordinates2D(-1, -7);
- Coordinates2D p2 = new Coordinates2D(7, -1);
+ Cartesian2D p1 = new Cartesian2D(-1, -7);
+ Cartesian2D p2 = new Cartesian2D(7, -1);
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 Coordinates2D(-1, -7).distance(segments.get(0).getStart()), 1.0e-10);
- Assert.assertEquals(0.0, new Coordinates2D( 7, -1).distance(segments.get(0).getEnd()), 1.0e-10);
+ Assert.assertEquals(0.0, new Cartesian2D(-1, -7).distance(segments.get(0).getStart()), 1.0e-10);
+ Assert.assertEquals(0.0, new Cartesian2D( 7, -1).distance(segments.get(0).getEnd()), 1.0e-10);
}
@Test
public void testNoEndPoints() {
- SubLine wholeLine = new Line(new Coordinates2D(-1, 7), new Coordinates2D(7, 1), 1.0e-10).wholeHyperplane();
+ SubLine wholeLine = new Line(new Cartesian2D(-1, 7), new Cartesian2D(7, 1), 1.0e-10).wholeHyperplane();
List<Segment> segments = wholeLine.getSegments();
Assert.assertEquals(1, segments.size());
Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getX()) &&
@@ -59,7 +59,7 @@ public class SubLineTest {
@Test
public void testNoSegments() {
- SubLine empty = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(7, -1), 1.0e-10),
+ SubLine empty = new SubLine(new Line(new Cartesian2D(-1, -7), new Cartesian2D(7, -1), 1.0e-10),
new RegionFactory<Euclidean1D>().getComplement(new IntervalsSet(1.0e-10)));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(0, segments.size());
@@ -67,7 +67,7 @@ public class SubLineTest {
@Test
public void testSeveralSegments() {
- SubLine twoSubs = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(7, -1), 1.0e-10),
+ SubLine twoSubs = new SubLine(new Line(new Cartesian2D(-1, -7), new Cartesian2D(7, -1), 1.0e-10),
new RegionFactory<Euclidean1D>().union(new IntervalsSet(1, 2, 1.0e-10),
new IntervalsSet(3, 4, 1.0e-10)));
List<Segment> segments = twoSubs.getSegments();
@@ -76,7 +76,7 @@ public class SubLineTest {
@Test
public void testHalfInfiniteNeg() {
- SubLine empty = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(7, -1), 1.0e-10),
+ SubLine empty = new SubLine(new Line(new Cartesian2D(-1, -7), new Cartesian2D(7, -1), 1.0e-10),
new IntervalsSet(Double.NEGATIVE_INFINITY, 0.0, 1.0e-10));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(1, segments.size());
@@ -84,16 +84,16 @@ public class SubLineTest {
segments.get(0).getStart().getX() < 0);
Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getY()) &&
segments.get(0).getStart().getY() < 0);
- Assert.assertEquals(0.0, new Coordinates2D(3, -4).distance(segments.get(0).getEnd()), 1.0e-10);
+ Assert.assertEquals(0.0, new Cartesian2D(3, -4).distance(segments.get(0).getEnd()), 1.0e-10);
}
@Test
public void testHalfInfinitePos() {
- SubLine empty = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(7, -1), 1.0e-10),
+ SubLine empty = new SubLine(new Line(new Cartesian2D(-1, -7), new Cartesian2D(7, -1), 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 Coordinates2D(3, -4).distance(segments.get(0).getStart()), 1.0e-10);
+ Assert.assertEquals(0.0, new Cartesian2D(3, -4).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()) &&
@@ -102,56 +102,56 @@ public class SubLineTest {
@Test
public void testIntersectionInsideInside() {
- SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(3, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 2), 1.0e-10);
- Assert.assertEquals(0.0, new Coordinates2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
- Assert.assertEquals(0.0, new Coordinates2D(2, 1).distance(sub1.intersection(sub2, false)), 1.0e-12);
+ SubLine sub1 = new SubLine(new Cartesian2D(1, 1), new Cartesian2D(3, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(new Cartesian2D(2, 0), new Cartesian2D(2, 2), 1.0e-10);
+ Assert.assertEquals(0.0, new Cartesian2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ Assert.assertEquals(0.0, new Cartesian2D(2, 1).distance(sub1.intersection(sub2, false)), 1.0e-12);
}
@Test
public void testIntersectionInsideBoundary() {
- SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(3, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 1), 1.0e-10);
- Assert.assertEquals(0.0, new Coordinates2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ SubLine sub1 = new SubLine(new Cartesian2D(1, 1), new Cartesian2D(3, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(new Cartesian2D(2, 0), new Cartesian2D(2, 1), 1.0e-10);
+ Assert.assertEquals(0.0, new Cartesian2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionInsideOutside() {
- SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(3, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(new Cartesian2D(1, 1), new Cartesian2D(3, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(new Cartesian2D(2, 0), new Cartesian2D(2, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionBoundaryBoundary() {
- SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(2, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 1), 1.0e-10);
- Assert.assertEquals(0.0, new Coordinates2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ SubLine sub1 = new SubLine(new Cartesian2D(1, 1), new Cartesian2D(2, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(new Cartesian2D(2, 0), new Cartesian2D(2, 1), 1.0e-10);
+ Assert.assertEquals(0.0, new Cartesian2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionBoundaryOutside() {
- SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(2, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(new Cartesian2D(1, 1), new Cartesian2D(2, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(new Cartesian2D(2, 0), new Cartesian2D(2, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionOutsideOutside() {
- SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(1.5, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(new Cartesian2D(1, 1), new Cartesian2D(1.5, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(new Cartesian2D(2, 0), new Cartesian2D(2, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionParallel() {
- final SubLine sub1 = new SubLine(new Coordinates2D(0, 1), new Coordinates2D(0, 2), 1.0e-10);
- final SubLine sub2 = new SubLine(new Coordinates2D(66, 3), new Coordinates2D(66, 4), 1.0e-10);
+ final SubLine sub1 = new SubLine(new Cartesian2D(0, 1), new Cartesian2D(0, 2), 1.0e-10);
+ final SubLine sub2 = new SubLine(new Cartesian2D(66, 3), new Cartesian2D(66, 4), 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/twod/Vector2DFormatAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java
index 491a04d..11f518a 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.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.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.euclidean.twod.Vector2DFormat;
import org.junit.Assert;
import org.junit.Test;
@@ -45,7 +45,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testSimpleNoDecimals() {
- Coordinates2D c = new Coordinates2D(1, 1);
+ Cartesian2D c = new Cartesian2D(1, 1);
String expected = "{1; 1}";
String actual = vector2DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -53,7 +53,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testSimpleWithDecimals() {
- Coordinates2D c = new Coordinates2D(1.23, 1.43);
+ Cartesian2D c = new Cartesian2D(1.23, 1.43);
String expected =
"{1" + getDecimalCharacter() +
"23; 1" + getDecimalCharacter() +
@@ -64,7 +64,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testSimpleWithDecimalsTrunc() {
- Coordinates2D c = new Coordinates2D(1.232323232323, 1.434343434343);
+ Cartesian2D c = new Cartesian2D(1.232323232323, 1.434343434343);
String expected =
"{1" + getDecimalCharacter() +
"2323232323; 1" + getDecimalCharacter() +
@@ -75,7 +75,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testNegativeX() {
- Coordinates2D c = new Coordinates2D(-1.232323232323, 1.43);
+ Cartesian2D c = new Cartesian2D(-1.232323232323, 1.43);
String expected =
"{-1" + getDecimalCharacter() +
"2323232323; 1" + getDecimalCharacter() +
@@ -86,7 +86,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testNegativeY() {
- Coordinates2D c = new Coordinates2D(1.23, -1.434343434343);
+ Cartesian2D c = new Cartesian2D(1.23, -1.434343434343);
String expected =
"{1" + getDecimalCharacter() +
"23; -1" + getDecimalCharacter() +
@@ -97,7 +97,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testNegativeZ() {
- Coordinates2D c = new Coordinates2D(1.23, 1.43);
+ Cartesian2D c = new Cartesian2D(1.23, 1.43);
String expected =
"{1" + getDecimalCharacter() +
"23; 1" + getDecimalCharacter() +
@@ -108,7 +108,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testNonDefaultSetting() {
- Coordinates2D c = new Coordinates2D(1, 1);
+ Cartesian2D c = new Cartesian2D(1, 1);
String expected = "[1 : 1]";
String actual = vector2DFormatSquare.format(c);
Assert.assertEquals(expected, actual);
@@ -119,7 +119,7 @@ public abstract class Vector2DFormatAbstractTest {
Locale defaultLocal = Locale.getDefault();
Locale.setDefault(getLocale());
- Coordinates2D c = new Coordinates2D(232.22222222222, -342.3333333333);
+ Cartesian2D c = new Cartesian2D(232.22222222222, -342.3333333333);
String expected =
"{232" + getDecimalCharacter() +
"2222222222; -342" + getDecimalCharacter() +
@@ -132,7 +132,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testNan() {
- Coordinates2D c = Coordinates2D.NaN;
+ Cartesian2D c = Cartesian2D.NaN;
String expected = "{(NaN); (NaN)}";
String actual = vector2DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -140,7 +140,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testPositiveInfinity() {
- Coordinates2D c = Coordinates2D.POSITIVE_INFINITY;
+ Cartesian2D c = Cartesian2D.POSITIVE_INFINITY;
String expected = "{(Infinity); (Infinity)}";
String actual = vector2DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -148,7 +148,7 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void tesNegativeInfinity() {
- Coordinates2D c = Coordinates2D.NEGATIVE_INFINITY;
+ Cartesian2D c = Cartesian2D.NEGATIVE_INFINITY;
String expected = "{(-Infinity); (-Infinity)}";
String actual = vector2DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -157,14 +157,14 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testParseSimpleNoDecimals() throws MathParseException {
String source = "{1; 1}";
- Coordinates2D expected = new Coordinates2D(1, 1);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(1, 1);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseIgnoredWhitespace() {
- Coordinates2D expected = new Coordinates2D(1, 1);
+ Cartesian2D expected = new Cartesian2D(1, 1);
ParsePosition pos1 = new ParsePosition(0);
String source1 = "{1;1}";
Assert.assertEquals(expected, vector2DFormat.parse(source1, pos1));
@@ -181,8 +181,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"23; 1" + getDecimalCharacter() +
"43}";
- Coordinates2D expected = new Coordinates2D(1.23, 1.43);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(1.23, 1.43);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -192,8 +192,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"2323; 1" + getDecimalCharacter() +
"4343}";
- Coordinates2D expected = new Coordinates2D(1.2323, 1.4343);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(1.2323, 1.4343);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -203,8 +203,8 @@ public abstract class Vector2DFormatAbstractTest {
"{-1" + getDecimalCharacter() +
"2323; 1" + getDecimalCharacter() +
"4343}";
- Coordinates2D expected = new Coordinates2D(-1.2323, 1.4343);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(-1.2323, 1.4343);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -214,8 +214,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"2323; -1" + getDecimalCharacter() +
"4343}";
- Coordinates2D expected = new Coordinates2D(1.2323, -1.4343);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(1.2323, -1.4343);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -225,8 +225,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"2323; 1" + getDecimalCharacter() +
"4343}";
- Coordinates2D expected = new Coordinates2D(1.2323, 1.4343);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(1.2323, 1.4343);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -236,8 +236,8 @@ public abstract class Vector2DFormatAbstractTest {
"{-1" + getDecimalCharacter() +
"2323; -1" + getDecimalCharacter() +
"4343}";
- Coordinates2D expected = new Coordinates2D(-1.2323, -1.4343);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(-1.2323, -1.4343);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -247,8 +247,8 @@ public abstract class Vector2DFormatAbstractTest {
"{0" + getDecimalCharacter() +
"0; -1" + getDecimalCharacter() +
"4343}";
- Coordinates2D expected = new Coordinates2D(0.0, -1.4343);
- Coordinates2D actual = vector2DFormat.parse(source);
+ Cartesian2D expected = new Cartesian2D(0.0, -1.4343);
+ Cartesian2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -258,30 +258,30 @@ public abstract class Vector2DFormatAbstractTest {
"[1" + getDecimalCharacter() +
"2323 : 1" + getDecimalCharacter() +
"4343]";
- Coordinates2D expected = new Coordinates2D(1.2323, 1.4343);
- Coordinates2D actual = vector2DFormatSquare.parse(source);
+ Cartesian2D expected = new Cartesian2D(1.2323, 1.4343);
+ Cartesian2D actual = vector2DFormatSquare.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseNan() throws MathParseException {
String source = "{(NaN); (NaN)}";
- Coordinates2D actual = vector2DFormat.parse(source);
- Assert.assertEquals(Coordinates2D.NaN, actual);
+ Cartesian2D actual = vector2DFormat.parse(source);
+ Assert.assertEquals(Cartesian2D.NaN, actual);
}
@Test
public void testParsePositiveInfinity() throws MathParseException {
String source = "{(Infinity); (Infinity)}";
- Coordinates2D actual = vector2DFormat.parse(source);
- Assert.assertEquals(Coordinates2D.POSITIVE_INFINITY, actual);
+ Cartesian2D actual = vector2DFormat.parse(source);
+ Assert.assertEquals(Cartesian2D.POSITIVE_INFINITY, actual);
}
@Test
public void testParseNegativeInfinity() throws MathParseException {
String source = "{(-Infinity); (-Infinity)}";
- Coordinates2D actual = vector2DFormat.parse(source);
- Assert.assertEquals(Coordinates2D.NEGATIVE_INFINITY, actual);
+ Cartesian2D actual = vector2DFormat.parse(source);
+ Assert.assertEquals(Cartesian2D.NEGATIVE_INFINITY, actual);
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java
index 77b68d1..cb760b2 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java
@@ -28,11 +28,11 @@ public class Vector2DTest {
@Test
public void testScaledVectorTripleConstructor() {
- Coordinates2D oneOne = new Coordinates2D(1.0,1.0);
- Coordinates2D oneTwo = new Coordinates2D(1.0,2.0);
- Coordinates2D oneThree = new Coordinates2D(1.0,3.0);
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D oneTwo = new Cartesian2D(1.0,2.0);
+ Cartesian2D oneThree = new Cartesian2D(1.0,3.0);
- Coordinates2D tripleCombo = new Coordinates2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree);
+ Cartesian2D tripleCombo = new Cartesian2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree);
Assert.assertEquals(3.0 * 1 + 1.0 * 1 + 2.5 * 1,tripleCombo.getX(), EPS);
Assert.assertEquals(3.0 * 1 + 1.0 * 2 + 2.5 * 3,tripleCombo.getY(), EPS);
@@ -40,12 +40,12 @@ public class Vector2DTest {
@Test
public void testScaledVectorQuadrupleConstructor() {
- Coordinates2D oneOne = new Coordinates2D(1.0, 1.0);
- Coordinates2D oneTwo = new Coordinates2D(1.0, 2.0);
- Coordinates2D oneThree = new Coordinates2D(1.0, 3.0);
- Coordinates2D oneFour = new Coordinates2D(1.0, 4.0);
+ Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
+ Cartesian2D oneTwo = new Cartesian2D(1.0, 2.0);
+ Cartesian2D oneThree = new Cartesian2D(1.0, 3.0);
+ Cartesian2D oneFour = new Cartesian2D(1.0, 4.0);
- Coordinates2D tripleCombo = new Coordinates2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree, 2.0, oneFour);
+ Cartesian2D tripleCombo = new Cartesian2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree, 2.0, oneFour);
Assert.assertEquals(3.0 * 1.0 + 1.0 * 1.0 + 2.5 * 1.0 + 2.0 * 1.0,tripleCombo.getX(), EPS);
Assert.assertEquals(3.0 * 1.0 + 1.0 * 2.0 + 2.5 * 3.0 + 2.0 * 4.0,tripleCombo.getY(), EPS);
@@ -55,7 +55,7 @@ public class Vector2DTest {
public void testConstructorExceptions() {
double[] v = new double[] {0.0, 1.0, 2.0};
try {
- new Coordinates2D(v);
+ new Cartesian2D(v);
}
catch (Exception e) {
Assert.assertTrue(e instanceof DimensionMismatchException);
@@ -64,7 +64,7 @@ public class Vector2DTest {
@Test
public void testToArray() {
- Coordinates2D oneTwo = new Coordinates2D(1.0, 2.0);
+ Cartesian2D oneTwo = new Cartesian2D(1.0, 2.0);
double[] array = oneTwo.toArray();
Assert.assertEquals(1.0, array[0], EPS);
Assert.assertEquals(2.0, array[1], EPS);
@@ -72,72 +72,72 @@ public class Vector2DTest {
@Test
public void testGetZero() {
- Coordinates2D zero = (new Coordinates2D(1.0, 1.0)).getZero();
+ Cartesian2D zero = (new Cartesian2D(1.0, 1.0)).getZero();
Assert.assertEquals(0.0, zero.getX(), EPS);
Assert.assertEquals(0.0, zero.getY(), EPS);
}
@Test
public void testNorm1() {
- Coordinates2D oneTwo = new Coordinates2D(-1.0, 2.0);
+ Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
Assert.assertEquals(3.0, oneTwo.getNorm1(), EPS);
}
@Test
public void testNormSq() {
- Coordinates2D oneTwo = new Coordinates2D(-1.0, 2.0);
+ Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
Assert.assertEquals(5.0, oneTwo.getNormSq(), EPS);
}
@Test
public void testNormInf() {
- Coordinates2D oneTwo = new Coordinates2D(-1.0, 2.0);
+ Cartesian2D oneTwo = new Cartesian2D(-1.0, 2.0);
Assert.assertEquals(2.0, oneTwo.getNormInf(), EPS);
}
@Test
public void testVectorAddition() {
- Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0);
- Coordinates2D threeFive = new Coordinates2D(3.0,5.0);
- Coordinates2D addition = minusOneTwo.add(threeFive);
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.add(threeFive);
Assert.assertEquals(2.0, addition.getX(), EPS);
Assert.assertEquals(7.0, addition.getY(), EPS);
}
@Test
public void testScaledVectorAddition() {
- Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0);
- Coordinates2D threeFive = new Coordinates2D(3.0,5.0);
- Coordinates2D addition = minusOneTwo.add(2.0, threeFive);
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.add(2.0, threeFive);
Assert.assertEquals(5.0, addition.getX(), EPS);
Assert.assertEquals(12.0, addition.getY(), EPS);
}
@Test
public void testVectorSubtraction() {
- Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0);
- Coordinates2D threeFive = new Coordinates2D(3.0,5.0);
- Coordinates2D addition = minusOneTwo.subtract(threeFive);
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.subtract(threeFive);
Assert.assertEquals(-4.0, addition.getX(), EPS);
Assert.assertEquals(-3.0, addition.getY(), EPS);
}
@Test
public void testScaledVectorSubtraction() {
- Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0);
- Coordinates2D threeFive = new Coordinates2D(3.0,5.0);
- Coordinates2D addition = minusOneTwo.subtract(2.0, threeFive);
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D threeFive = new Cartesian2D(3.0,5.0);
+ Cartesian2D addition = minusOneTwo.subtract(2.0, threeFive);
Assert.assertEquals(-7.0, addition.getX(), EPS);
Assert.assertEquals(-8.0, addition.getY(), EPS);
}
@Test
public void testNormalize() {
- Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0);
- Coordinates2D normalizedMinusOneTwo = minusOneTwo.normalize();
+ Cartesian2D minusOneTwo = new Cartesian2D(-1.0,2.0);
+ Cartesian2D normalizedMinusOneTwo = minusOneTwo.normalize();
Assert.assertEquals(-1.0/FastMath.sqrt(5), normalizedMinusOneTwo.getX(), EPS);
Assert.assertEquals(2.0/FastMath.sqrt(5), normalizedMinusOneTwo.getY(), EPS);
- Coordinates2D zero = minusOneTwo.getZero();
+ Cartesian2D zero = minusOneTwo.getZero();
try {
zero.normalize();
}
@@ -148,88 +148,88 @@ public class Vector2DTest {
@Test
public void testAngle() {
- Coordinates2D oneOne = new Coordinates2D(1.0, 1.0);
+ Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
try {
- Coordinates2D.angle(oneOne.getZero(), oneOne.getZero());
+ Cartesian2D.angle(oneOne.getZero(), oneOne.getZero());
}
catch (Exception e) {
Assert.assertTrue(e instanceof MathArithmeticException);
}
- Coordinates2D oneZero = new Coordinates2D(1.0,0.0);
- double angle = Coordinates2D.angle(oneOne, oneZero);
+ Cartesian2D oneZero = new Cartesian2D(1.0,0.0);
+ double angle = Cartesian2D.angle(oneOne, oneZero);
Assert.assertEquals(FastMath.PI/4, angle, EPS);
- Assert.assertEquals(0.004999958333958323, Coordinates2D.angle(new Coordinates2D(20.0,0.0), new Coordinates2D(20.0,0.1)), EPS);
+ Assert.assertEquals(0.004999958333958323, Cartesian2D.angle(new Cartesian2D(20.0,0.0), new Cartesian2D(20.0,0.1)), EPS);
}
@Test
public void testNegate() {
- Coordinates2D oneOne = new Coordinates2D(1.0,1.0);
- Coordinates2D negated = oneOne.negate();
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D negated = oneOne.negate();
Assert.assertEquals(-1.0, negated.getX(), EPS);
Assert.assertEquals(-1.0, negated.getY(), EPS);
}
@Test
public void testIsInfinite() {
- Coordinates2D oneOne = new Coordinates2D(1.0, 1.0);
- Coordinates2D infiniteVector = new Coordinates2D(Double.POSITIVE_INFINITY, 0.0);
+ Cartesian2D oneOne = new Cartesian2D(1.0, 1.0);
+ Cartesian2D infiniteVector = new Cartesian2D(Double.POSITIVE_INFINITY, 0.0);
Assert.assertFalse(oneOne.isInfinite());
Assert.assertTrue(infiniteVector.isInfinite());
}
@Test
public void testDistance1() {
- Coordinates2D oneOne = new Coordinates2D(1.0,1.0);
- Coordinates2D fiveEleven = new Coordinates2D(5.0,11.0);
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D fiveEleven = new Cartesian2D(5.0,11.0);
double distance1 = oneOne.distance1(fiveEleven);
Assert.assertEquals(14.0, distance1, EPS);
}
@Test
public void testDistanceInf() {
- Coordinates2D oneOne = new Coordinates2D(1.0,1.0);
- Coordinates2D fiveEleven = new Coordinates2D(5.0,11.0);
+ Cartesian2D oneOne = new Cartesian2D(1.0,1.0);
+ Cartesian2D fiveEleven = new Cartesian2D(5.0,11.0);
double distanceInf = oneOne.distanceInf(fiveEleven);
- double staticDistanceInf = Coordinates2D.distanceInf(oneOne, fiveEleven);
+ double staticDistanceInf = Cartesian2D.distanceInf(oneOne, fiveEleven);
Assert.assertEquals(10.0, distanceInf, EPS);
Assert.assertEquals(distanceInf, staticDistanceInf, EPS);
}
@Test
public void testDistanceSq() {
- Coordinates2D oneFive = new Coordinates2D(1.0, 5.0);
- Coordinates2D fourOne = new Coordinates2D(4.0, 1.0);
+ Cartesian2D oneFive = new Cartesian2D(1.0, 5.0);
+ Cartesian2D fourOne = new Cartesian2D(4.0, 1.0);
double distanceSq = oneFive.distanceSq(fourOne);
- double staticDistanceSq = Coordinates2D.distanceSq(oneFive, fourOne);
+ double staticDistanceSq = Cartesian2D.distanceSq(oneFive, fourOne);
Assert.assertEquals(25.0, distanceSq, EPS);
Assert.assertEquals(distanceSq, staticDistanceSq, EPS);
}
@Test
public void testHashCode() {
- int hashCode = (new Coordinates2D(1.0,1.0)).hashCode();
+ int hashCode = (new Cartesian2D(1.0,1.0)).hashCode();
Assert.assertEquals(887095296, hashCode);
- Assert.assertEquals(542, (new Coordinates2D(Double.NaN, Double.NaN)).hashCode());
+ Assert.assertEquals(542, (new Cartesian2D(Double.NaN, Double.NaN)).hashCode());
}
@Test
public void testToString() {
- Assert.assertEquals("{1; 2}", (new Coordinates2D(1.0,2.0)).toString());
+ Assert.assertEquals("{1; 2}", (new Cartesian2D(1.0,2.0)).toString());
}
@Test
public void testCrossProduct() {
- Coordinates2D p1 = new Coordinates2D(1, 1);
- Coordinates2D p2 = new Coordinates2D(2, 2);
+ Cartesian2D p1 = new Cartesian2D(1, 1);
+ Cartesian2D p2 = new Cartesian2D(2, 2);
- Coordinates2D p3 = new Coordinates2D(3, 3);
+ Cartesian2D p3 = new Cartesian2D(3, 3);
Assert.assertEquals(0.0, p3.crossProduct(p1, p2), EPS);
- Coordinates2D p4 = new Coordinates2D(1, 2);
+ Cartesian2D p4 = new Cartesian2D(1, 2);
Assert.assertEquals(1.0, p4.crossProduct(p1, p2), EPS);
- Coordinates2D p5 = new Coordinates2D(2, 1);
+ Cartesian2D p5 = new Cartesian2D(2, 1);
Assert.assertEquals(-1.0, p5.crossProduct(p1, p2), EPS);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java
index d91016a..edc5596 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.euclidean.twod.hull;
import java.util.Collection;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.AklToussaintHeuristic;
import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.MonotoneChain;
@@ -34,7 +34,7 @@ public class AklToussaintHeuristicTest extends ConvexHullGenerator2DAbstractTest
}
@Override
- protected Collection<Coordinates2D> reducePoints(Collection<Coordinates2D> points) {
+ protected Collection<Cartesian2D> reducePoints(Collection<Cartesian2D> points) {
return AklToussaintHeuristic.reducePoints(points);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
index 7f2fc7e..fd32cfe 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
@@ -24,7 +24,7 @@ import java.util.List;
import org.apache.commons.math4.exception.NullArgumentException;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHull2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D;
import org.apache.commons.math4.geometry.partitioning.Region;
@@ -49,7 +49,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
protected abstract ConvexHullGenerator2D createConvexHullGenerator(boolean includeCollinearPoints);
- protected Collection<Coordinates2D> reducePoints(Collection<Coordinates2D> points) {
+ protected Collection<Cartesian2D> reducePoints(Collection<Cartesian2D> points) {
// do nothing by default, may be overridden by other tests
return points;
}
@@ -70,14 +70,14 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testEmpty() {
- ConvexHull2D hull = generator.generate(Collections.<Coordinates2D>emptyList());
+ ConvexHull2D hull = generator.generate(Collections.<Cartesian2D>emptyList());
Assert.assertTrue(hull.getVertices().length == 0);
Assert.assertTrue(hull.getLineSegments().length == 0);
}
@Test
public void testOnePoint() {
- List<Coordinates2D> points = createRandomPoints(1);
+ List<Cartesian2D> points = createRandomPoints(1);
ConvexHull2D hull = generator.generate(points);
Assert.assertTrue(hull.getVertices().length == 1);
Assert.assertTrue(hull.getLineSegments().length == 0);
@@ -85,7 +85,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testTwoPoints() {
- List<Coordinates2D> points = createRandomPoints(2);
+ List<Cartesian2D> points = createRandomPoints(2);
ConvexHull2D hull = generator.generate(points);
Assert.assertTrue(hull.getVertices().length == 2);
Assert.assertTrue(hull.getLineSegments().length == 1);
@@ -93,11 +93,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testAllIdentical() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(1, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(1, 1));
final ConvexHull2D hull = generator.generate(points);
Assert.assertTrue(hull.getVertices().length == 1);
@@ -110,7 +110,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
// randomize the size from 4 to 100
int size = (int) FastMath.floor(random.nextDouble() * 96.0 + 4.0);
- List<Coordinates2D> points = createRandomPoints(size);
+ List<Cartesian2D> points = createRandomPoints(size);
ConvexHull2D hull = generator.generate(reducePoints(points));
checkConvexHull(points, hull);
}
@@ -118,12 +118,12 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPoints() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(2, 2));
- points.add(new Coordinates2D(2, 4));
- points.add(new Coordinates2D(4, 1));
- points.add(new Coordinates2D(10, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(2, 2));
+ points.add(new Cartesian2D(2, 4));
+ points.add(new Cartesian2D(4, 1));
+ points.add(new Cartesian2D(10, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -131,12 +131,12 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPointsReverse() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(2, 2));
- points.add(new Coordinates2D(2, 4));
- points.add(new Coordinates2D(10, 1));
- points.add(new Coordinates2D(4, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(2, 2));
+ points.add(new Cartesian2D(2, 4));
+ points.add(new Cartesian2D(10, 1));
+ points.add(new Cartesian2D(4, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -144,12 +144,12 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPointsIncluded() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(2, 2));
- points.add(new Coordinates2D(2, 4));
- points.add(new Coordinates2D(4, 1));
- points.add(new Coordinates2D(10, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(2, 2));
+ points.add(new Cartesian2D(2, 4));
+ points.add(new Cartesian2D(4, 1));
+ points.add(new Cartesian2D(10, 1));
final ConvexHull2D hull = createConvexHullGenerator(true).generate(points);
checkConvexHull(points, hull, true);
@@ -157,12 +157,12 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPointsIncludedReverse() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(2, 2));
- points.add(new Coordinates2D(2, 4));
- points.add(new Coordinates2D(10, 1));
- points.add(new Coordinates2D(4, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(2, 2));
+ points.add(new Cartesian2D(2, 4));
+ points.add(new Cartesian2D(10, 1));
+ points.add(new Cartesian2D(4, 1));
final ConvexHull2D hull = createConvexHullGenerator(true).generate(points);
checkConvexHull(points, hull, true);
@@ -170,12 +170,12 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testIdenticalPoints() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(2, 2));
- points.add(new Coordinates2D(2, 4));
- points.add(new Coordinates2D(4, 1));
- points.add(new Coordinates2D(1, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(2, 2));
+ points.add(new Cartesian2D(2, 4));
+ points.add(new Cartesian2D(4, 1));
+ points.add(new Cartesian2D(1, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -183,12 +183,12 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testIdenticalPoints2() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(2, 2));
- points.add(new Coordinates2D(2, 4));
- points.add(new Coordinates2D(4, 1));
- points.add(new Coordinates2D(1, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(2, 2));
+ points.add(new Cartesian2D(2, 4));
+ points.add(new Cartesian2D(4, 1));
+ points.add(new Cartesian2D(1, 1));
final ConvexHull2D hull = createConvexHullGenerator(true).generate(points);
checkConvexHull(points, hull, true);
@@ -196,12 +196,12 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testClosePoints() {
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(2, 2));
- points.add(new Coordinates2D(2, 4));
- points.add(new Coordinates2D(4, 1));
- points.add(new Coordinates2D(1.00001, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(2, 2));
+ points.add(new Cartesian2D(2, 4));
+ points.add(new Cartesian2D(4, 1));
+ points.add(new Cartesian2D(1.00001, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -211,17 +211,17 @@ public abstract class ConvexHullGenerator2DAbstractTest {
public void testCollinearPointOnExistingBoundary() {
// MATH-1135: check that collinear points on the hull are handled correctly
// when only a minimal hull shall be constructed
- final Collection<Coordinates2D> points = new ArrayList<>();
- points.add(new Coordinates2D(7.3152, 34.7472));
- points.add(new Coordinates2D(6.400799999999997, 34.747199999999985));
- points.add(new Coordinates2D(5.486399999999997, 34.7472));
- points.add(new Coordinates2D(4.876799999999999, 34.7472));
- points.add(new Coordinates2D(4.876799999999999, 34.1376));
- points.add(new Coordinates2D(4.876799999999999, 30.48));
- points.add(new Coordinates2D(6.0959999999999965, 30.48));
- points.add(new Coordinates2D(6.0959999999999965, 34.1376));
- points.add(new Coordinates2D(7.315199999999996, 34.1376));
- points.add(new Coordinates2D(7.3152, 30.48));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+ points.add(new Cartesian2D(7.3152, 34.7472));
+ points.add(new Cartesian2D(6.400799999999997, 34.747199999999985));
+ points.add(new Cartesian2D(5.486399999999997, 34.7472));
+ points.add(new Cartesian2D(4.876799999999999, 34.7472));
+ points.add(new Cartesian2D(4.876799999999999, 34.1376));
+ points.add(new Cartesian2D(4.876799999999999, 30.48));
+ points.add(new Cartesian2D(6.0959999999999965, 30.48));
+ points.add(new Cartesian2D(6.0959999999999965, 34.1376));
+ points.add(new Cartesian2D(7.315199999999996, 34.1376));
+ points.add(new Cartesian2D(7.3152, 30.48));
final ConvexHull2D hull = createConvexHullGenerator(false).generate(points);
checkConvexHull(points, hull);
@@ -233,13 +233,13 @@ public abstract class ConvexHullGenerator2DAbstractTest {
// make sure that they are processed in the proper order
// for each algorithm.
- List<Coordinates2D> points = new ArrayList<>();
+ List<Cartesian2D> points = new ArrayList<>();
// first case: 3 points are collinear
- points.add(new Coordinates2D(16.078200000000184, -36.52519999989808));
- points.add(new Coordinates2D(19.164300000000186, -36.52519999989808));
- points.add(new Coordinates2D(19.1643, -25.28136477910407));
- points.add(new Coordinates2D(19.1643, -17.678400000004157));
+ points.add(new Cartesian2D(16.078200000000184, -36.52519999989808));
+ points.add(new Cartesian2D(19.164300000000186, -36.52519999989808));
+ points.add(new Cartesian2D(19.1643, -25.28136477910407));
+ points.add(new Cartesian2D(19.1643, -17.678400000004157));
ConvexHull2D hull = createConvexHullGenerator(false).generate(points);
checkConvexHull(points, hull);
@@ -250,15 +250,15 @@ public abstract class ConvexHullGenerator2DAbstractTest {
points.clear();
// second case: multiple points are collinear
- points.add(new Coordinates2D(0, -29.959696875));
- points.add(new Coordinates2D(0, -31.621809375));
- points.add(new Coordinates2D(0, -28.435696875));
- points.add(new Coordinates2D(0, -33.145809375));
- points.add(new Coordinates2D(3.048, -33.145809375));
- points.add(new Coordinates2D(3.048, -31.621809375));
- points.add(new Coordinates2D(3.048, -29.959696875));
- points.add(new Coordinates2D(4.572, -33.145809375));
- points.add(new Coordinates2D(4.572, -28.435696875));
+ points.add(new Cartesian2D(0, -29.959696875));
+ points.add(new Cartesian2D(0, -31.621809375));
+ points.add(new Cartesian2D(0, -28.435696875));
+ points.add(new Cartesian2D(0, -33.145809375));
+ points.add(new Cartesian2D(3.048, -33.145809375));
+ points.add(new Cartesian2D(3.048, -31.621809375));
+ points.add(new Cartesian2D(3.048, -29.959696875));
+ points.add(new Cartesian2D(4.572, -33.145809375));
+ points.add(new Cartesian2D(4.572, -28.435696875));
hull = createConvexHullGenerator(false).generate(points);
checkConvexHull(points, hull);
@@ -270,7 +270,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testIssue1123() {
- List<Coordinates2D> points = new ArrayList<>();
+ List<Cartesian2D> points = new ArrayList<>();
int[][] data = new int[][] { { -11, -1 }, { -11, 0 }, { -11, 1 },
{ -10, -3 }, { -10, -2 }, { -10, -1 }, { -10, 0 }, { -10, 1 },
@@ -324,26 +324,26 @@ public abstract class ConvexHullGenerator2DAbstractTest {
{ 11, -1 }, { 11, 0 }, { 11, 1 } };
for (int[] line : data) {
- points.add(new Coordinates2D(line[0], line[1]));
+ points.add(new Cartesian2D(line[0], line[1]));
}
- Coordinates2D[] referenceHull = new Coordinates2D[] {
- new Coordinates2D(-11.0, -1.0),
- new Coordinates2D(-10.0, -3.0),
- new Coordinates2D( -6.0, -7.0),
- new Coordinates2D( -3.0, -8.0),
- new Coordinates2D( 3.0, -8.0),
- new Coordinates2D( 6.0, -7.0),
- new Coordinates2D( 10.0, -3.0),
- new Coordinates2D( 11.0, -1.0),
- new Coordinates2D( 11.0, 1.0),
- new Coordinates2D( 10.0, 3.0),
- new Coordinates2D( 6.0, 7.0),
- new Coordinates2D( 3.0, 8.0),
- new Coordinates2D( -3.0, 8.0),
- new Coordinates2D( -6.0, 7.0),
- new Coordinates2D(-10.0, 3.0),
- new Coordinates2D(-11.0, 1.0),
+ Cartesian2D[] referenceHull = new Cartesian2D[] {
+ new Cartesian2D(-11.0, -1.0),
+ new Cartesian2D(-10.0, -3.0),
+ new Cartesian2D( -6.0, -7.0),
+ new Cartesian2D( -3.0, -8.0),
+ new Cartesian2D( 3.0, -8.0),
+ new Cartesian2D( 6.0, -7.0),
+ new Cartesian2D( 10.0, -3.0),
+ new Cartesian2D( 11.0, -1.0),
+ new Cartesian2D( 11.0, 1.0),
+ new Cartesian2D( 10.0, 3.0),
+ new Cartesian2D( 6.0, 7.0),
+ new Cartesian2D( 3.0, 8.0),
+ new Cartesian2D( -3.0, 8.0),
+ new Cartesian2D( -6.0, 7.0),
+ new Cartesian2D(-10.0, 3.0),
+ new Cartesian2D(-11.0, 1.0),
};
ConvexHull2D convHull = generator.generate(points);
@@ -352,7 +352,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
Assert.assertEquals(274.0, hullRegion.getSize(), 1.0e-12);
double perimeter = 0;
for (int i = 0; i < referenceHull.length; ++i) {
- perimeter += Coordinates2D.distance(referenceHull[i],
+ perimeter += Cartesian2D.distance(referenceHull[i],
referenceHull[(i + 1) % referenceHull.length]);
}
Assert.assertEquals(perimeter, hullRegion.getBoundarySize(), 1.0e-12);
@@ -365,26 +365,26 @@ public abstract class ConvexHullGenerator2DAbstractTest {
// ------------------------------------------------------------------------------
- protected final List<Coordinates2D> createRandomPoints(int size) {
+ protected final List<Cartesian2D> createRandomPoints(int size) {
// create the cloud container
- List<Coordinates2D> points = new ArrayList<>(size);
+ List<Cartesian2D> points = new ArrayList<>(size);
// fill the cloud with a random distribution of points
for (int i = 0; i < size; i++) {
- points.add(new Coordinates2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0));
+ points.add(new Cartesian2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0));
}
return points;
}
- protected final void checkConvexHull(final Collection<Coordinates2D> points, final ConvexHull2D hull) {
+ protected final void checkConvexHull(final Collection<Cartesian2D> points, final ConvexHull2D hull) {
checkConvexHull(points, hull, false);
}
- protected final void checkConvexHull(final Collection<Coordinates2D> points, final ConvexHull2D hull,
+ protected final void checkConvexHull(final Collection<Cartesian2D> points, final ConvexHull2D hull,
final boolean includesCollinearPoints) {
checkConvexHull(points, hull, includesCollinearPoints, 1e-10);
}
- protected final void checkConvexHull(final Collection<Coordinates2D> points, final ConvexHull2D hull,
+ protected final void checkConvexHull(final Collection<Cartesian2D> points, final ConvexHull2D hull,
final boolean includesCollinearPoints, final double tolerance) {
Assert.assertNotNull(hull);
Assert.assertTrue(isConvex(hull, includesCollinearPoints, tolerance));
@@ -395,16 +395,16 @@ public abstract class ConvexHullGenerator2DAbstractTest {
protected final boolean isConvex(final ConvexHull2D hull, final boolean includesCollinearPoints,
final double tolerance) {
- final Coordinates2D[] points = hull.getVertices();
+ final Cartesian2D[] points = hull.getVertices();
int sign = 0;
for (int i = 0; i < points.length; i++) {
- Coordinates2D p1 = points[i == 0 ? points.length - 1 : i - 1];
- Coordinates2D p2 = points[i];
- Coordinates2D p3 = points[i == points.length - 1 ? 0 : i + 1];
+ Cartesian2D p1 = points[i == 0 ? points.length - 1 : i - 1];
+ Cartesian2D p2 = points[i];
+ Cartesian2D p3 = points[i == points.length - 1 ? 0 : i + 1];
- Coordinates2D d1 = p2.subtract(p1);
- Coordinates2D d2 = p3.subtract(p2);
+ Cartesian2D d1 = p2.subtract(p1);
+ Cartesian2D d2 = p3.subtract(p2);
Assert.assertTrue(d1.getNorm() > 1e-10);
Assert.assertTrue(d2.getNorm() > 1e-10);
@@ -427,14 +427,14 @@ public abstract class ConvexHullGenerator2DAbstractTest {
}
// verify that all points are inside the convex hull region
- protected final void checkPointsInsideHullRegion(final Collection<Coordinates2D> points,
+ protected final void checkPointsInsideHullRegion(final Collection<Cartesian2D> points,
final ConvexHull2D hull,
final boolean includesCollinearPoints) {
- final Collection<Coordinates2D> hullVertices = Arrays.asList(hull.getVertices());
+ final Collection<Cartesian2D> hullVertices = Arrays.asList(hull.getVertices());
final Region<Euclidean2D> region = hull.createRegion();
- for (final Coordinates2D p : points) {
+ for (final Cartesian2D p : points) {
Location location = region.checkPoint(p);
Assert.assertTrue(location != Location.OUTSIDE);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java
index 4813fdd..8ce3979 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.Collection;
import org.apache.commons.math4.exception.ConvergenceException;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHull2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D;
import org.apache.commons.math4.geometry.euclidean.twod.hull.MonotoneChain;
@@ -40,16 +40,16 @@ public class MonotoneChainTest extends ConvexHullGenerator2DAbstractTest {
@Test(expected=ConvergenceException.class)
public void testConvergenceException() {
- final Collection<Coordinates2D> points = new ArrayList<>();
-
- points.add(new Coordinates2D(1, 1));
- points.add(new Coordinates2D(1, 5));
- points.add(new Coordinates2D(0, 7));
- points.add(new Coordinates2D(1, 10));
- points.add(new Coordinates2D(1, 20));
- points.add(new Coordinates2D(20, 20));
- points.add(new Coordinates2D(20, 40));
- points.add(new Coordinates2D(40, 1));
+ final Collection<Cartesian2D> points = new ArrayList<>();
+
+ points.add(new Cartesian2D(1, 1));
+ points.add(new Cartesian2D(1, 5));
+ points.add(new Cartesian2D(0, 7));
+ points.add(new Cartesian2D(1, 10));
+ points.add(new Cartesian2D(1, 20));
+ points.add(new Cartesian2D(20, 20));
+ points.add(new Cartesian2D(20, 40));
+ points.add(new Cartesian2D(40, 1));
@SuppressWarnings("unused")
final ConvexHull2D hull = new MonotoneChain(true, 2).generate(points);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java
index 5c356a2..0107e22 100644
--- a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java
+++ b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java
@@ -23,15 +23,15 @@ import org.apache.commons.math4.geometry.Space;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D;
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.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.Line;
import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.spherical.oned.ArcsSet;
import org.apache.commons.math4.geometry.spherical.oned.LimitAngle;
import org.apache.commons.math4.geometry.spherical.oned.Sphere1D;
@@ -125,7 +125,7 @@ public class RegionDumper {
@Override
protected void formatHyperplane(final Hyperplane<Euclidean2D> hyperplane) {
final Line h = (Line) hyperplane;
- final Coordinates2D p = h.toSpace(Coordinates1D.ZERO);
+ final Cartesian2D p = h.toSpace(Cartesian1D.ZERO);
getFormatter().format("%22.15e %22.15e %22.15e %22.15e",
p.getX(), p.getY(), h.getAngle(), h.getTolerance());
}
@@ -146,7 +146,7 @@ public class RegionDumper {
@Override
protected void formatHyperplane(final Hyperplane<Euclidean3D> hyperplane) {
final Plane h = (Plane) hyperplane;
- final Coordinates3D p = h.toSpace(Coordinates2D.ZERO);
+ final Cartesian3D p = h.toSpace(Cartesian2D.ZERO);
getFormatter().format("%22.15e %22.15e %22.15e %22.15e %22.15e %22.15e %22.15e",
p.getX(), p.getY(), p.getZ(),
h.getNormal().getX(), h.getNormal().getY(), h.getNormal().getZ(),
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java
index 23a4c01..c338749 100644
--- a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java
+++ b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java
@@ -24,15 +24,15 @@ import org.apache.commons.math4.geometry.Space;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D;
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.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.Line;
import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.spherical.oned.ArcsSet;
import org.apache.commons.math4.geometry.spherical.oned.LimitAngle;
import org.apache.commons.math4.geometry.spherical.oned.S1Point;
@@ -90,7 +90,7 @@ public class RegionParser {
@Override
public Circle parseHyperplane()
throws IOException, ParseException {
- return new Circle(new Coordinates3D(getNumber(), getNumber(), getNumber()), getNumber());
+ return new Circle(new Cartesian3D(getNumber(), getNumber(), getNumber()), getNumber());
}
};
@@ -111,7 +111,7 @@ public class RegionParser {
@Override
public OrientedPoint parseHyperplane()
throws IOException, ParseException {
- return new OrientedPoint(new Coordinates1D(getNumber()), getBoolean(), getNumber());
+ return new OrientedPoint(new Cartesian1D(getNumber()), getBoolean(), getNumber());
}
};
@@ -132,7 +132,7 @@ public class RegionParser {
@Override
public Line parseHyperplane()
throws IOException, ParseException {
- return new Line(new Coordinates2D(getNumber(), getNumber()), getNumber(), getNumber());
+ return new Line(new Cartesian2D(getNumber(), getNumber()), getNumber(), getNumber());
}
};
@@ -153,8 +153,8 @@ public class RegionParser {
@Override
public Plane parseHyperplane()
throws IOException, ParseException {
- return new Plane(new Coordinates3D(getNumber(), getNumber(), getNumber()),
- new Coordinates3D(getNumber(), getNumber(), getNumber()),
+ return new Plane(new Cartesian3D(getNumber(), getNumber(), getNumber()),
+ new Cartesian3D(getNumber(), getNumber(), getNumber()),
getNumber());
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
index 3b6cd9d..f45c22d 100644
--- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
@@ -18,7 +18,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.RotationConvention;
-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.Transform;
import org.apache.commons.math4.geometry.spherical.oned.Arc;
import org.apache.commons.math4.geometry.spherical.oned.LimitAngle;
@@ -40,13 +40,13 @@ public class CircleTest {
@Test
public void testEquator() {
- Circle circle = new Circle(new Coordinates3D(0, 0, 1000), 1.0e-10).copySelf();
- Assert.assertEquals(Coordinates3D.PLUS_K, circle.getPole());
+ Circle circle = new Circle(new Cartesian3D(0, 0, 1000), 1.0e-10).copySelf();
+ Assert.assertEquals(Cartesian3D.PLUS_K, circle.getPole());
Assert.assertEquals(1.0e-10, circle.getTolerance(), 1.0e-20);
circle.revertSelf();
- Assert.assertEquals(Coordinates3D.MINUS_K, circle.getPole());
- Assert.assertEquals(Coordinates3D.PLUS_K, circle.getReverse().getPole());
- Assert.assertEquals(Coordinates3D.MINUS_K, circle.getPole());
+ Assert.assertEquals(Cartesian3D.MINUS_K, circle.getPole());
+ Assert.assertEquals(Cartesian3D.PLUS_K, circle.getReverse().getPole());
+ Assert.assertEquals(Cartesian3D.MINUS_K, circle.getPole());
}
@Test
@@ -54,11 +54,11 @@ public class CircleTest {
Circle circle = new Circle(new S2Point(1.2, 2.5), new S2Point(-4.3, 0), 1.0e-10);
Assert.assertEquals(0.0, circle.getPointAt(0).distance(circle.getXAxis()), 1.0e-10);
Assert.assertEquals(0.0, circle.getPointAt(0.5 * FastMath.PI).distance(circle.getYAxis()), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getXAxis(), circle.getYAxis()), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getXAxis(), circle.getPole()), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getPole(), circle.getYAxis()), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(circle.getXAxis(), circle.getYAxis()), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(circle.getXAxis(), circle.getPole()), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(circle.getPole(), circle.getYAxis()), 1.0e-10);
Assert.assertEquals(0.0,
- circle.getPole().distance(Coordinates3D.crossProduct(circle.getXAxis(), circle.getYAxis())),
+ circle.getPole().distance(Cartesian3D.crossProduct(circle.getXAxis(), circle.getYAxis())),
1.0e-10);
}
@@ -68,16 +68,16 @@ public class CircleTest {
Circle reversed = circle.getReverse();
Assert.assertEquals(0.0, reversed.getPointAt(0).distance(reversed.getXAxis()), 1.0e-10);
Assert.assertEquals(0.0, reversed.getPointAt(0.5 * FastMath.PI).distance(reversed.getYAxis()), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(reversed.getXAxis(), reversed.getYAxis()), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(reversed.getXAxis(), reversed.getPole()), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(reversed.getPole(), reversed.getYAxis()), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(reversed.getXAxis(), reversed.getYAxis()), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(reversed.getXAxis(), reversed.getPole()), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(reversed.getPole(), reversed.getYAxis()), 1.0e-10);
Assert.assertEquals(0.0,
- reversed.getPole().distance(Coordinates3D.crossProduct(reversed.getXAxis(), reversed.getYAxis())),
+ reversed.getPole().distance(Cartesian3D.crossProduct(reversed.getXAxis(), reversed.getYAxis())),
1.0e-10);
- Assert.assertEquals(0, Coordinates3D.angle(circle.getXAxis(), reversed.getXAxis()), 1.0e-10);
- Assert.assertEquals(FastMath.PI, Coordinates3D.angle(circle.getYAxis(), reversed.getYAxis()), 1.0e-10);
- Assert.assertEquals(FastMath.PI, Coordinates3D.angle(circle.getPole(), reversed.getPole()), 1.0e-10);
+ Assert.assertEquals(0, Cartesian3D.angle(circle.getXAxis(), reversed.getXAxis()), 1.0e-10);
+ Assert.assertEquals(FastMath.PI, Cartesian3D.angle(circle.getYAxis(), reversed.getYAxis()), 1.0e-10);
+ Assert.assertEquals(FastMath.PI, Cartesian3D.angle(circle.getPole(), reversed.getPole()), 1.0e-10);
Assert.assertTrue(circle.sameOrientationAs(circle));
Assert.assertFalse(circle.sameOrientationAs(reversed));
@@ -87,13 +87,13 @@ public class CircleTest {
@Test
public void testPhase() {
Circle circle = new Circle(new S2Point(1.2, 2.5), new S2Point(-4.3, 0), 1.0e-10);
- Coordinates3D p = new Coordinates3D(1, 2, -4);
- Coordinates3D samePhase = circle.getPointAt(circle.getPhase(p));
+ Cartesian3D p = new Cartesian3D(1, 2, -4);
+ Cartesian3D samePhase = circle.getPointAt(circle.getPhase(p));
Assert.assertEquals(0.0,
- Coordinates3D.angle(Coordinates3D.crossProduct(circle.getPole(), p),
- Coordinates3D.crossProduct(circle.getPole(), samePhase)),
+ Cartesian3D.angle(Cartesian3D.crossProduct(circle.getPole(), p),
+ Cartesian3D.crossProduct(circle.getPole(), samePhase)),
1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getPole(), samePhase), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(circle.getPole(), samePhase), 1.0e-10);
Assert.assertEquals(circle.getPhase(p), circle.getPhase(samePhase), 1.0e-10);
Assert.assertEquals(0.0, circle.getPhase(circle.getXAxis()), 1.0e-10);
Assert.assertEquals(0.5 * FastMath.PI, circle.getPhase(circle.getYAxis()), 1.0e-10);
@@ -105,7 +105,7 @@ public class CircleTest {
Circle circle = new Circle(new S2Point(1.2, 2.5), new S2Point(-4.3, 0), 1.0e-10);
Assert.assertEquals(0.0, circle.toSubSpace(new S2Point(circle.getXAxis())).getAlpha(), 1.0e-10);
Assert.assertEquals(0.5 * FastMath.PI, circle.toSubSpace(new S2Point(circle.getYAxis())).getAlpha(), 1.0e-10);
- Coordinates3D p = new Coordinates3D(1, 2, -4);
+ Cartesian3D p = new Cartesian3D(1, 2, -4);
Assert.assertEquals(circle.getPhase(p), circle.toSubSpace(new S2Point(p)).getAlpha(), 1.0e-10);
}
@@ -113,23 +113,23 @@ public class CircleTest {
public void testSpace() {
Circle circle = new Circle(new S2Point(1.2, 2.5), new S2Point(-4.3, 0), 1.0e-10);
for (double alpha = 0; alpha < MathUtils.TWO_PI; alpha += 0.1) {
- Coordinates3D p = new Coordinates3D(FastMath.cos(alpha), circle.getXAxis(),
+ Cartesian3D p = new Cartesian3D(FastMath.cos(alpha), circle.getXAxis(),
FastMath.sin(alpha), circle.getYAxis());
- Coordinates3D q = circle.toSpace(new S1Point(alpha)).getVector();
+ Cartesian3D q = circle.toSpace(new S1Point(alpha)).getVector();
Assert.assertEquals(0.0, p.distance(q), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getPole(), q), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, Cartesian3D.angle(circle.getPole(), q), 1.0e-10);
}
}
@Test
public void testOffset() {
- Circle circle = new Circle(Coordinates3D.PLUS_K, 1.0e-10);
- Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.PLUS_I)), 1.0e-10);
- Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.MINUS_I)), 1.0e-10);
- Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.PLUS_J)), 1.0e-10);
- Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.MINUS_J)), 1.0e-10);
- Assert.assertEquals(-0.5 * FastMath.PI, circle.getOffset(new S2Point(Coordinates3D.PLUS_K)), 1.0e-10);
- Assert.assertEquals(0.5 * FastMath.PI, circle.getOffset(new S2Point(Coordinates3D.MINUS_K)), 1.0e-10);
+ Circle circle = new Circle(Cartesian3D.PLUS_K, 1.0e-10);
+ Assert.assertEquals(0.0, circle.getOffset(new S2Point(Cartesian3D.PLUS_I)), 1.0e-10);
+ Assert.assertEquals(0.0, circle.getOffset(new S2Point(Cartesian3D.MINUS_I)), 1.0e-10);
+ Assert.assertEquals(0.0, circle.getOffset(new S2Point(Cartesian3D.PLUS_J)), 1.0e-10);
+ Assert.assertEquals(0.0, circle.getOffset(new S2Point(Cartesian3D.MINUS_J)), 1.0e-10);
+ Assert.assertEquals(-0.5 * FastMath.PI, circle.getOffset(new S2Point(Cartesian3D.PLUS_K)), 1.0e-10);
+ Assert.assertEquals(0.5 * FastMath.PI, circle.getOffset(new S2Point(Cartesian3D.MINUS_K)), 1.0e-10);
}
@@ -138,8 +138,8 @@ public class CircleTest {
UnitSphereRandomVectorGenerator sphRandom = new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A,
0xbfd34e92231bbcfel));
for (int i = 0; i < 100; ++i) {
- Circle c1 = new Circle(new Coordinates3D(sphRandom.nextVector()), 1.0e-10);
- Circle c2 = new Circle(new Coordinates3D(sphRandom.nextVector()), 1.0e-10);
+ Circle c1 = new Circle(new Cartesian3D(sphRandom.nextVector()), 1.0e-10);
+ Circle c2 = new Circle(new Cartesian3D(sphRandom.nextVector()), 1.0e-10);
checkArcIsInside(c1, c2);
checkArcIsInside(c2, c1);
}
@@ -163,16 +163,16 @@ public class CircleTest {
UnitSphereRandomVectorGenerator sphRandom = new UnitSphereRandomVectorGenerator(3, random);
for (int i = 0; i < 100; ++i) {
- Rotation r = new Rotation(new Coordinates3D(sphRandom.nextVector()),
+ Rotation r = new Rotation(new Cartesian3D(sphRandom.nextVector()),
FastMath.PI * random.nextDouble(),
RotationConvention.VECTOR_OPERATOR);
Transform<Sphere2D, Sphere1D> t = Circle.getTransform(r);
- S2Point p = new S2Point(new Coordinates3D(sphRandom.nextVector()));
+ S2Point p = new S2Point(new Cartesian3D(sphRandom.nextVector()));
S2Point tp = (S2Point) t.apply(p);
Assert.assertEquals(0.0, r.applyTo(p.getVector()).distance(tp.getVector()), 1.0e-10);
- Circle c = new Circle(new Coordinates3D(sphRandom.nextVector()), 1.0e-10);
+ Circle c = new Circle(new Cartesian3D(sphRandom.nextVector()), 1.0e-10);
Circle tc = (Circle) t.apply(c);
Assert.assertEquals(0.0, r.applyTo(c.getPole()).distance(tc.getPole()), 1.0e-10);
Assert.assertEquals(0.0, r.applyTo(c.getXAxis()).distance(tc.getXAxis()), 1.0e-10);
@@ -181,9 +181,9 @@ public class CircleTest {
SubLimitAngle sub = new LimitAngle(new S1Point(MathUtils.TWO_PI * random.nextDouble()),
random.nextBoolean(), 1.0e-10).wholeHyperplane();
- Coordinates3D psub = c.getPointAt(((LimitAngle) sub.getHyperplane()).getLocation().getAlpha());
+ Cartesian3D psub = c.getPointAt(((LimitAngle) sub.getHyperplane()).getLocation().getAlpha());
SubLimitAngle tsub = (SubLimitAngle) t.apply(sub, c, tc);
- Coordinates3D ptsub = tc.getPointAt(((LimitAngle) tsub.getHyperplane()).getLocation().getAlpha());
+ Cartesian3D ptsub = tc.getPointAt(((LimitAngle) tsub.getHyperplane()).getLocation().getAlpha());
Assert.assertEquals(0.0, r.applyTo(psub).distance(ptsub), 1.0e-10);
}
[03/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
Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
index 01bfdb3..0419585 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
@@ -22,12 +22,12 @@ import java.util.List;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.geometry.euclidean.oned.Interval;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
import org.apache.commons.math4.geometry.euclidean.twod.Line;
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.BoundaryProjection;
@@ -44,41 +44,41 @@ public class PolygonsSetTest {
@Test
public void testSimplyConnected() {
- Coordinates2D[][] vertices = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(36.0, 22.0),
- new Coordinates2D(39.0, 32.0),
- new Coordinates2D(19.0, 32.0),
- new Coordinates2D( 6.0, 16.0),
- new Coordinates2D(31.0, 10.0),
- new Coordinates2D(42.0, 16.0),
- new Coordinates2D(34.0, 20.0),
- new Coordinates2D(29.0, 19.0),
- new Coordinates2D(23.0, 22.0),
- new Coordinates2D(33.0, 25.0)
+ Cartesian2D[][] vertices = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(36.0, 22.0),
+ new Cartesian2D(39.0, 32.0),
+ new Cartesian2D(19.0, 32.0),
+ new Cartesian2D( 6.0, 16.0),
+ new Cartesian2D(31.0, 10.0),
+ new Cartesian2D(42.0, 16.0),
+ new Cartesian2D(34.0, 20.0),
+ new Cartesian2D(29.0, 19.0),
+ new Cartesian2D(23.0, 22.0),
+ new Cartesian2D(33.0, 25.0)
}
};
PolygonsSet set = buildSet(vertices);
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates2D(50.0, 30.0)));
- checkPoints(Region.Location.INSIDE, set, new Coordinates2D[] {
- new Coordinates2D(30.0, 15.0),
- new Coordinates2D(15.0, 20.0),
- new Coordinates2D(24.0, 25.0),
- new Coordinates2D(35.0, 30.0),
- new Coordinates2D(19.0, 17.0)
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Cartesian2D(50.0, 30.0)));
+ checkPoints(Region.Location.INSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(30.0, 15.0),
+ new Cartesian2D(15.0, 20.0),
+ new Cartesian2D(24.0, 25.0),
+ new Cartesian2D(35.0, 30.0),
+ new Cartesian2D(19.0, 17.0)
});
- checkPoints(Region.Location.OUTSIDE, set, new Coordinates2D[] {
- new Coordinates2D(50.0, 30.0),
- new Coordinates2D(30.0, 35.0),
- new Coordinates2D(10.0, 25.0),
- new Coordinates2D(10.0, 10.0),
- new Coordinates2D(40.0, 10.0),
- new Coordinates2D(50.0, 15.0),
- new Coordinates2D(30.0, 22.0)
+ checkPoints(Region.Location.OUTSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(50.0, 30.0),
+ new Cartesian2D(30.0, 35.0),
+ new Cartesian2D(10.0, 25.0),
+ new Cartesian2D(10.0, 10.0),
+ new Cartesian2D(40.0, 10.0),
+ new Cartesian2D(50.0, 15.0),
+ new Cartesian2D(30.0, 22.0)
});
- checkPoints(Region.Location.BOUNDARY, set, new Coordinates2D[] {
- new Coordinates2D(30.0, 32.0),
- new Coordinates2D(34.0, 20.0)
+ checkPoints(Region.Location.BOUNDARY, set, new Cartesian2D[] {
+ new Cartesian2D(30.0, 32.0),
+ new Cartesian2D(34.0, 20.0)
});
checkVertices(set.getVertices(), vertices);
}
@@ -98,18 +98,18 @@ public class PolygonsSetTest {
@Test
public void testStair() {
- Coordinates2D[][] vertices = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 0.0, 2.0),
- new Coordinates2D(-0.1, 2.0),
- new Coordinates2D(-0.1, 1.0),
- new Coordinates2D(-0.3, 1.0),
- new Coordinates2D(-0.3, 1.5),
- new Coordinates2D(-1.3, 1.5),
- new Coordinates2D(-1.3, 2.0),
- new Coordinates2D(-1.8, 2.0),
- new Coordinates2D(-1.8 - 1.0 / FastMath.sqrt(2.0),
+ Cartesian2D[][] vertices = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 0.0, 2.0),
+ new Cartesian2D(-0.1, 2.0),
+ new Cartesian2D(-0.1, 1.0),
+ new Cartesian2D(-0.3, 1.0),
+ new Cartesian2D(-0.3, 1.5),
+ new Cartesian2D(-1.3, 1.5),
+ new Cartesian2D(-1.3, 2.0),
+ new Cartesian2D(-1.8, 2.0),
+ new Cartesian2D(-1.8 - 1.0 / FastMath.sqrt(2.0),
2.0 - 1.0 / FastMath.sqrt(2.0))
}
};
@@ -131,7 +131,7 @@ public class PolygonsSetTest {
for (double y = -1; y < 1; y += 0.1) {
for (double x = -1; x < 1; x += 0.1) {
Assert.assertEquals(Double.POSITIVE_INFINITY,
- empty.projectToBoundary(new Coordinates2D(x, y)).getOffset(),
+ empty.projectToBoundary(new Cartesian2D(x, y)).getOffset(),
1.0e-10);
}
}
@@ -147,7 +147,7 @@ public class PolygonsSetTest {
for (double y = -1; y < 1; y += 0.1) {
for (double x = -1; x < 1; x += 0.1) {
Assert.assertEquals(Double.NEGATIVE_INFINITY,
- empty.projectToBoundary(new Coordinates2D(x, y)).getOffset(),
+ empty.projectToBoundary(new Cartesian2D(x, y)).getOffset(),
1.0e-10);
}
}
@@ -155,56 +155,56 @@ public class PolygonsSetTest {
@Test
public void testHole() {
- Coordinates2D[][] vertices = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(0.0, 0.0),
- new Coordinates2D(3.0, 0.0),
- new Coordinates2D(3.0, 3.0),
- new Coordinates2D(0.0, 3.0)
- }, new Coordinates2D[] {
- new Coordinates2D(1.0, 2.0),
- new Coordinates2D(2.0, 2.0),
- new Coordinates2D(2.0, 1.0),
- new Coordinates2D(1.0, 1.0)
+ Cartesian2D[][] vertices = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(0.0, 0.0),
+ new Cartesian2D(3.0, 0.0),
+ new Cartesian2D(3.0, 3.0),
+ new Cartesian2D(0.0, 3.0)
+ }, new Cartesian2D[] {
+ new Cartesian2D(1.0, 2.0),
+ new Cartesian2D(2.0, 2.0),
+ new Cartesian2D(2.0, 1.0),
+ new Cartesian2D(1.0, 1.0)
}
};
PolygonsSet set = buildSet(vertices);
- checkPoints(Region.Location.INSIDE, set, new Coordinates2D[] {
- new Coordinates2D(0.5, 0.5),
- new Coordinates2D(1.5, 0.5),
- new Coordinates2D(2.5, 0.5),
- new Coordinates2D(0.5, 1.5),
- new Coordinates2D(2.5, 1.5),
- new Coordinates2D(0.5, 2.5),
- new Coordinates2D(1.5, 2.5),
- new Coordinates2D(2.5, 2.5),
- new Coordinates2D(0.5, 1.0)
+ checkPoints(Region.Location.INSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(0.5, 0.5),
+ new Cartesian2D(1.5, 0.5),
+ new Cartesian2D(2.5, 0.5),
+ new Cartesian2D(0.5, 1.5),
+ new Cartesian2D(2.5, 1.5),
+ new Cartesian2D(0.5, 2.5),
+ new Cartesian2D(1.5, 2.5),
+ new Cartesian2D(2.5, 2.5),
+ new Cartesian2D(0.5, 1.0)
});
- checkPoints(Region.Location.OUTSIDE, set, new Coordinates2D[] {
- new Coordinates2D(1.5, 1.5),
- new Coordinates2D(3.5, 1.0),
- new Coordinates2D(4.0, 1.5),
- new Coordinates2D(6.0, 6.0)
+ checkPoints(Region.Location.OUTSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(1.5, 1.5),
+ new Cartesian2D(3.5, 1.0),
+ new Cartesian2D(4.0, 1.5),
+ new Cartesian2D(6.0, 6.0)
});
- checkPoints(Region.Location.BOUNDARY, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 1.0),
- new Coordinates2D(1.5, 0.0),
- new Coordinates2D(1.5, 1.0),
- new Coordinates2D(1.5, 2.0),
- new Coordinates2D(1.5, 3.0),
- new Coordinates2D(3.0, 3.0)
+ checkPoints(Region.Location.BOUNDARY, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 1.0),
+ new Cartesian2D(1.5, 0.0),
+ new Cartesian2D(1.5, 1.0),
+ new Cartesian2D(1.5, 2.0),
+ new Cartesian2D(1.5, 3.0),
+ new Cartesian2D(3.0, 3.0)
});
checkVertices(set.getVertices(), vertices);
for (double x = -0.999; x < 3.999; x += 0.11) {
- Coordinates2D v = new Coordinates2D(x, x + 0.5);
+ Cartesian2D v = new Cartesian2D(x, x + 0.5);
BoundaryProjection<Euclidean2D> projection = set.projectToBoundary(v);
Assert.assertTrue(projection.getOriginal() == v);
- Coordinates2D p = (Coordinates2D) projection.getProjected();
+ Cartesian2D p = (Cartesian2D) projection.getProjected();
if (x < -0.5) {
Assert.assertEquals(0.0, p.getX(), 1.0e-10);
Assert.assertEquals(0.0, p.getY(), 1.0e-10);
- Assert.assertEquals(+v.distance(Coordinates2D.ZERO), projection.getOffset(), 1.0e-10);
+ Assert.assertEquals(+v.distance(Cartesian2D.ZERO), projection.getOffset(), 1.0e-10);
} else if (x < 0.5) {
Assert.assertEquals(0.0, p.getX(), 1.0e-10);
Assert.assertEquals(v.getY(), p.getY(), 1.0e-10);
@@ -224,7 +224,7 @@ public class PolygonsSetTest {
} else {
Assert.assertEquals(3.0, p.getX(), 1.0e-10);
Assert.assertEquals(3.0, p.getY(), 1.0e-10);
- Assert.assertEquals(+v.distance(new Coordinates2D(3, 3)), projection.getOffset(), 1.0e-10);
+ Assert.assertEquals(+v.distance(new Cartesian2D(3, 3)), projection.getOffset(), 1.0e-10);
}
}
@@ -233,47 +233,47 @@ public class PolygonsSetTest {
@Test
public void testDisjointPolygons() {
- Coordinates2D[][] vertices = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(0.0, 1.0),
- new Coordinates2D(2.0, 1.0),
- new Coordinates2D(1.0, 2.0)
- }, new Coordinates2D[] {
- new Coordinates2D(4.0, 0.0),
- new Coordinates2D(5.0, 1.0),
- new Coordinates2D(3.0, 1.0)
+ Cartesian2D[][] vertices = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(0.0, 1.0),
+ new Cartesian2D(2.0, 1.0),
+ new Cartesian2D(1.0, 2.0)
+ }, new Cartesian2D[] {
+ new Cartesian2D(4.0, 0.0),
+ new Cartesian2D(5.0, 1.0),
+ new Cartesian2D(3.0, 1.0)
}
};
PolygonsSet set = buildSet(vertices);
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates2D(1.0, 1.5)));
- checkPoints(Region.Location.INSIDE, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 1.5),
- new Coordinates2D(4.5, 0.8)
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Cartesian2D(1.0, 1.5)));
+ checkPoints(Region.Location.INSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 1.5),
+ new Cartesian2D(4.5, 0.8)
});
- checkPoints(Region.Location.OUTSIDE, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 0.0),
- new Coordinates2D(3.5, 1.2),
- new Coordinates2D(2.5, 1.0),
- new Coordinates2D(3.0, 4.0)
+ checkPoints(Region.Location.OUTSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 0.0),
+ new Cartesian2D(3.5, 1.2),
+ new Cartesian2D(2.5, 1.0),
+ new Cartesian2D(3.0, 4.0)
});
- checkPoints(Region.Location.BOUNDARY, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 1.0),
- new Coordinates2D(3.5, 0.5),
- new Coordinates2D(0.0, 1.0)
+ checkPoints(Region.Location.BOUNDARY, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 1.0),
+ new Cartesian2D(3.5, 0.5),
+ new Cartesian2D(0.0, 1.0)
});
checkVertices(set.getVertices(), vertices);
}
@Test
public void testOppositeHyperplanes() {
- Coordinates2D[][] vertices = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(1.0, 0.0),
- new Coordinates2D(2.0, 1.0),
- new Coordinates2D(3.0, 1.0),
- new Coordinates2D(2.0, 2.0),
- new Coordinates2D(1.0, 1.0),
- new Coordinates2D(0.0, 1.0)
+ Cartesian2D[][] vertices = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(1.0, 0.0),
+ new Cartesian2D(2.0, 1.0),
+ new Cartesian2D(3.0, 1.0),
+ new Cartesian2D(2.0, 2.0),
+ new Cartesian2D(1.0, 1.0),
+ new Cartesian2D(0.0, 1.0)
}
};
PolygonsSet set = buildSet(vertices);
@@ -282,16 +282,16 @@ public class PolygonsSetTest {
@Test
public void testSingularPoint() {
- Coordinates2D[][] vertices = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 1.0, 0.0),
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 0.0, 1.0),
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D(-1.0, 0.0),
- new Coordinates2D(-1.0, -1.0),
- new Coordinates2D( 0.0, -1.0)
+ Cartesian2D[][] vertices = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 1.0, 0.0),
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 0.0, 1.0),
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D(-1.0, 0.0),
+ new Cartesian2D(-1.0, -1.0),
+ new Cartesian2D( 0.0, -1.0)
}
};
PolygonsSet set = buildSet(vertices);
@@ -300,48 +300,48 @@ public class PolygonsSetTest {
@Test
public void testLineIntersection() {
- Coordinates2D[][] vertices = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 1.0),
- new Coordinates2D( 3.0, 1.0),
- new Coordinates2D( 3.0, 3.0),
- new Coordinates2D( 1.0, 3.0),
- new Coordinates2D( 1.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ Cartesian2D[][] vertices = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 1.0),
+ new Cartesian2D( 3.0, 1.0),
+ new Cartesian2D( 3.0, 3.0),
+ new Cartesian2D( 1.0, 3.0),
+ new Cartesian2D( 1.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
}
};
PolygonsSet set = buildSet(vertices);
- Line l1 = new Line(new Coordinates2D(-1.5, 0.0), FastMath.PI / 4, 1.0e-10);
+ Line l1 = new Line(new Cartesian2D(-1.5, 0.0), FastMath.PI / 4, 1.0e-10);
SubLine s1 = (SubLine) set.intersection(l1.wholeHyperplane());
List<Interval> i1 = ((IntervalsSet) s1.getRemainingRegion()).asList();
Assert.assertEquals(2, i1.size());
Interval v10 = i1.get(0);
- Coordinates2D p10Lower = l1.toSpace(new Coordinates1D(v10.getInf()));
+ Cartesian2D p10Lower = l1.toSpace(new Cartesian1D(v10.getInf()));
Assert.assertEquals(0.0, p10Lower.getX(), 1.0e-10);
Assert.assertEquals(1.5, p10Lower.getY(), 1.0e-10);
- Coordinates2D p10Upper = l1.toSpace(new Coordinates1D(v10.getSup()));
+ Cartesian2D p10Upper = l1.toSpace(new Cartesian1D(v10.getSup()));
Assert.assertEquals(0.5, p10Upper.getX(), 1.0e-10);
Assert.assertEquals(2.0, p10Upper.getY(), 1.0e-10);
Interval v11 = i1.get(1);
- Coordinates2D p11Lower = l1.toSpace(new Coordinates1D(v11.getInf()));
+ Cartesian2D p11Lower = l1.toSpace(new Cartesian1D(v11.getInf()));
Assert.assertEquals(1.0, p11Lower.getX(), 1.0e-10);
Assert.assertEquals(2.5, p11Lower.getY(), 1.0e-10);
- Coordinates2D p11Upper = l1.toSpace(new Coordinates1D(v11.getSup()));
+ Cartesian2D p11Upper = l1.toSpace(new Cartesian1D(v11.getSup()));
Assert.assertEquals(1.5, p11Upper.getX(), 1.0e-10);
Assert.assertEquals(3.0, p11Upper.getY(), 1.0e-10);
- Line l2 = new Line(new Coordinates2D(-1.0, 2.0), 0, 1.0e-10);
+ Line l2 = new Line(new Cartesian2D(-1.0, 2.0), 0, 1.0e-10);
SubLine s2 = (SubLine) set.intersection(l2.wholeHyperplane());
List<Interval> i2 = ((IntervalsSet) s2.getRemainingRegion()).asList();
Assert.assertEquals(1, i2.size());
Interval v20 = i2.get(0);
- Coordinates2D p20Lower = l2.toSpace(new Coordinates1D(v20.getInf()));
+ Cartesian2D p20Lower = l2.toSpace(new Cartesian1D(v20.getInf()));
Assert.assertEquals(1.0, p20Lower.getX(), 1.0e-10);
Assert.assertEquals(2.0, p20Lower.getY(), 1.0e-10);
- Coordinates2D p20Upper = l2.toSpace(new Coordinates1D(v20.getSup()));
+ Cartesian2D p20Upper = l2.toSpace(new Cartesian1D(v20.getSup()));
Assert.assertEquals(3.0, p20Upper.getX(), 1.0e-10);
Assert.assertEquals(2.0, p20Upper.getY(), 1.0e-10);
@@ -349,20 +349,20 @@ public class PolygonsSetTest {
@Test
public void testUnlimitedSubHyperplane() {
- Coordinates2D[][] vertices1 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(0.0, 0.0),
- new Coordinates2D(4.0, 0.0),
- new Coordinates2D(1.4, 1.5),
- new Coordinates2D(0.0, 3.5)
+ Cartesian2D[][] vertices1 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(0.0, 0.0),
+ new Cartesian2D(4.0, 0.0),
+ new Cartesian2D(1.4, 1.5),
+ new Cartesian2D(0.0, 3.5)
}
};
PolygonsSet set1 = buildSet(vertices1);
- Coordinates2D[][] vertices2 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(1.4, 0.2),
- new Coordinates2D(2.8, -1.2),
- new Coordinates2D(2.5, 0.6)
+ Cartesian2D[][] vertices2 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(1.4, 0.2),
+ new Cartesian2D(2.8, -1.2),
+ new Cartesian2D(2.5, 0.6)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -372,15 +372,15 @@ public class PolygonsSetTest {
set2.copySelf());
checkVertices(set1.getVertices(), vertices1);
checkVertices(set2.getVertices(), vertices2);
- checkVertices(set.getVertices(), new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(0.0, 0.0),
- new Coordinates2D(1.6, 0.0),
- new Coordinates2D(2.8, -1.2),
- new Coordinates2D(2.6, 0.0),
- new Coordinates2D(4.0, 0.0),
- new Coordinates2D(1.4, 1.5),
- new Coordinates2D(0.0, 3.5)
+ checkVertices(set.getVertices(), new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(0.0, 0.0),
+ new Cartesian2D(1.6, 0.0),
+ new Cartesian2D(2.8, -1.2),
+ new Cartesian2D(2.6, 0.0),
+ new Cartesian2D(4.0, 0.0),
+ new Cartesian2D(1.4, 1.5),
+ new Cartesian2D(0.0, 3.5)
}
});
@@ -388,21 +388,21 @@ public class PolygonsSetTest {
@Test
public void testUnion() {
- Coordinates2D[][] vertices1 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ Cartesian2D[][] vertices1 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
- Coordinates2D[][] vertices2 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 3.0, 1.0),
- new Coordinates2D( 3.0, 3.0),
- new Coordinates2D( 1.0, 3.0)
+ Cartesian2D[][] vertices2 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 3.0, 1.0),
+ new Cartesian2D( 3.0, 3.0),
+ new Cartesian2D( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -410,63 +410,63 @@ public class PolygonsSetTest {
set2.copySelf());
checkVertices(set1.getVertices(), vertices1);
checkVertices(set2.getVertices(), vertices2);
- checkVertices(set.getVertices(), new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 1.0),
- new Coordinates2D( 3.0, 1.0),
- new Coordinates2D( 3.0, 3.0),
- new Coordinates2D( 1.0, 3.0),
- new Coordinates2D( 1.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ checkVertices(set.getVertices(), new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 1.0),
+ new Cartesian2D( 3.0, 1.0),
+ new Cartesian2D( 3.0, 3.0),
+ new Cartesian2D( 1.0, 3.0),
+ new Cartesian2D( 1.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
}
});
- checkPoints(Region.Location.INSIDE, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 1.0),
- new Coordinates2D(0.5, 0.5),
- new Coordinates2D(2.0, 2.0),
- new Coordinates2D(2.5, 2.5),
- new Coordinates2D(0.5, 1.5),
- new Coordinates2D(1.5, 1.5),
- new Coordinates2D(1.5, 0.5),
- new Coordinates2D(1.5, 2.5),
- new Coordinates2D(2.5, 1.5),
- new Coordinates2D(2.5, 2.5)
+ checkPoints(Region.Location.INSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 1.0),
+ new Cartesian2D(0.5, 0.5),
+ new Cartesian2D(2.0, 2.0),
+ new Cartesian2D(2.5, 2.5),
+ new Cartesian2D(0.5, 1.5),
+ new Cartesian2D(1.5, 1.5),
+ new Cartesian2D(1.5, 0.5),
+ new Cartesian2D(1.5, 2.5),
+ new Cartesian2D(2.5, 1.5),
+ new Cartesian2D(2.5, 2.5)
});
- checkPoints(Region.Location.OUTSIDE, set, new Coordinates2D[] {
- new Coordinates2D(-0.5, 0.5),
- new Coordinates2D( 0.5, 2.5),
- new Coordinates2D( 2.5, 0.5),
- new Coordinates2D( 3.5, 2.5)
+ checkPoints(Region.Location.OUTSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(-0.5, 0.5),
+ new Cartesian2D( 0.5, 2.5),
+ new Cartesian2D( 2.5, 0.5),
+ new Cartesian2D( 3.5, 2.5)
});
- checkPoints(Region.Location.BOUNDARY, set, new Coordinates2D[] {
- new Coordinates2D(0.0, 0.0),
- new Coordinates2D(0.5, 2.0),
- new Coordinates2D(2.0, 0.5),
- new Coordinates2D(2.5, 1.0),
- new Coordinates2D(3.0, 2.5)
+ checkPoints(Region.Location.BOUNDARY, set, new Cartesian2D[] {
+ new Cartesian2D(0.0, 0.0),
+ new Cartesian2D(0.5, 2.0),
+ new Cartesian2D(2.0, 0.5),
+ new Cartesian2D(2.5, 1.0),
+ new Cartesian2D(3.0, 2.5)
});
}
@Test
public void testIntersection() {
- Coordinates2D[][] vertices1 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ Cartesian2D[][] vertices1 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
- Coordinates2D[][] vertices2 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 3.0, 1.0),
- new Coordinates2D( 3.0, 3.0),
- new Coordinates2D( 1.0, 3.0)
+ Cartesian2D[][] vertices2 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 3.0, 1.0),
+ new Cartesian2D( 3.0, 3.0),
+ new Cartesian2D( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -474,48 +474,48 @@ public class PolygonsSetTest {
set2.copySelf());
checkVertices(set1.getVertices(), vertices1);
checkVertices(set2.getVertices(), vertices2);
- checkVertices(set.getVertices(), new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 2.0, 1.0),
- new Coordinates2D( 2.0, 2.0),
- new Coordinates2D( 1.0, 2.0)
+ checkVertices(set.getVertices(), new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 2.0, 1.0),
+ new Cartesian2D( 2.0, 2.0),
+ new Cartesian2D( 1.0, 2.0)
}
});
- checkPoints(Region.Location.INSIDE, set, new Coordinates2D[] {
- new Coordinates2D(1.5, 1.5)
+ checkPoints(Region.Location.INSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(1.5, 1.5)
});
- checkPoints(Region.Location.OUTSIDE, set, new Coordinates2D[] {
- new Coordinates2D(0.5, 1.5),
- new Coordinates2D(2.5, 1.5),
- new Coordinates2D(1.5, 0.5),
- new Coordinates2D(0.5, 0.5)
+ checkPoints(Region.Location.OUTSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(0.5, 1.5),
+ new Cartesian2D(2.5, 1.5),
+ new Cartesian2D(1.5, 0.5),
+ new Cartesian2D(0.5, 0.5)
});
- checkPoints(Region.Location.BOUNDARY, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 1.0),
- new Coordinates2D(2.0, 2.0),
- new Coordinates2D(1.0, 1.5),
- new Coordinates2D(1.5, 2.0)
+ checkPoints(Region.Location.BOUNDARY, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 1.0),
+ new Cartesian2D(2.0, 2.0),
+ new Cartesian2D(1.0, 1.5),
+ new Cartesian2D(1.5, 2.0)
});
}
@Test
public void testXor() {
- Coordinates2D[][] vertices1 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ Cartesian2D[][] vertices1 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
- Coordinates2D[][] vertices2 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 3.0, 1.0),
- new Coordinates2D( 3.0, 3.0),
- new Coordinates2D( 1.0, 3.0)
+ Cartesian2D[][] vertices2 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 3.0, 1.0),
+ new Cartesian2D( 3.0, 3.0),
+ new Cartesian2D( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -523,70 +523,70 @@ public class PolygonsSetTest {
set2.copySelf());
checkVertices(set1.getVertices(), vertices1);
checkVertices(set2.getVertices(), vertices2);
- checkVertices(set.getVertices(), new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 1.0),
- new Coordinates2D( 3.0, 1.0),
- new Coordinates2D( 3.0, 3.0),
- new Coordinates2D( 1.0, 3.0),
- new Coordinates2D( 1.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ checkVertices(set.getVertices(), new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 1.0),
+ new Cartesian2D( 3.0, 1.0),
+ new Cartesian2D( 3.0, 3.0),
+ new Cartesian2D( 1.0, 3.0),
+ new Cartesian2D( 1.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
},
- new Coordinates2D[] {
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 1.0, 2.0),
- new Coordinates2D( 2.0, 2.0),
- new Coordinates2D( 2.0, 1.0)
+ new Cartesian2D[] {
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 1.0, 2.0),
+ new Cartesian2D( 2.0, 2.0),
+ new Cartesian2D( 2.0, 1.0)
}
});
- checkPoints(Region.Location.INSIDE, set, new Coordinates2D[] {
- new Coordinates2D(0.5, 0.5),
- new Coordinates2D(2.5, 2.5),
- new Coordinates2D(0.5, 1.5),
- new Coordinates2D(1.5, 0.5),
- new Coordinates2D(1.5, 2.5),
- new Coordinates2D(2.5, 1.5),
- new Coordinates2D(2.5, 2.5)
+ checkPoints(Region.Location.INSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(0.5, 0.5),
+ new Cartesian2D(2.5, 2.5),
+ new Cartesian2D(0.5, 1.5),
+ new Cartesian2D(1.5, 0.5),
+ new Cartesian2D(1.5, 2.5),
+ new Cartesian2D(2.5, 1.5),
+ new Cartesian2D(2.5, 2.5)
});
- checkPoints(Region.Location.OUTSIDE, set, new Coordinates2D[] {
- new Coordinates2D(-0.5, 0.5),
- new Coordinates2D( 0.5, 2.5),
- new Coordinates2D( 2.5, 0.5),
- new Coordinates2D( 1.5, 1.5),
- new Coordinates2D( 3.5, 2.5)
+ checkPoints(Region.Location.OUTSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(-0.5, 0.5),
+ new Cartesian2D( 0.5, 2.5),
+ new Cartesian2D( 2.5, 0.5),
+ new Cartesian2D( 1.5, 1.5),
+ new Cartesian2D( 3.5, 2.5)
});
- checkPoints(Region.Location.BOUNDARY, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 1.0),
- new Coordinates2D(2.0, 2.0),
- new Coordinates2D(1.5, 1.0),
- new Coordinates2D(2.0, 1.5),
- new Coordinates2D(0.0, 0.0),
- new Coordinates2D(0.5, 2.0),
- new Coordinates2D(2.0, 0.5),
- new Coordinates2D(2.5, 1.0),
- new Coordinates2D(3.0, 2.5)
+ checkPoints(Region.Location.BOUNDARY, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 1.0),
+ new Cartesian2D(2.0, 2.0),
+ new Cartesian2D(1.5, 1.0),
+ new Cartesian2D(2.0, 1.5),
+ new Cartesian2D(0.0, 0.0),
+ new Cartesian2D(0.5, 2.0),
+ new Cartesian2D(2.0, 0.5),
+ new Cartesian2D(2.5, 1.0),
+ new Cartesian2D(3.0, 2.5)
});
}
@Test
public void testDifference() {
- Coordinates2D[][] vertices1 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ Cartesian2D[][] vertices1 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
- Coordinates2D[][] vertices2 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 3.0, 1.0),
- new Coordinates2D( 3.0, 3.0),
- new Coordinates2D( 1.0, 3.0)
+ Cartesian2D[][] vertices2 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 3.0, 1.0),
+ new Cartesian2D( 3.0, 3.0),
+ new Cartesian2D( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -594,62 +594,62 @@ public class PolygonsSetTest {
set2.copySelf());
checkVertices(set1.getVertices(), vertices1);
checkVertices(set2.getVertices(), vertices2);
- checkVertices(set.getVertices(), new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.0, 0.0),
- new Coordinates2D( 2.0, 0.0),
- new Coordinates2D( 2.0, 1.0),
- new Coordinates2D( 1.0, 1.0),
- new Coordinates2D( 1.0, 2.0),
- new Coordinates2D( 0.0, 2.0)
+ checkVertices(set.getVertices(), new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.0, 0.0),
+ new Cartesian2D( 2.0, 0.0),
+ new Cartesian2D( 2.0, 1.0),
+ new Cartesian2D( 1.0, 1.0),
+ new Cartesian2D( 1.0, 2.0),
+ new Cartesian2D( 0.0, 2.0)
}
});
- checkPoints(Region.Location.INSIDE, set, new Coordinates2D[] {
- new Coordinates2D(0.5, 0.5),
- new Coordinates2D(0.5, 1.5),
- new Coordinates2D(1.5, 0.5)
+ checkPoints(Region.Location.INSIDE, set, new Cartesian2D[] {
+ new Cartesian2D(0.5, 0.5),
+ new Cartesian2D(0.5, 1.5),
+ new Cartesian2D(1.5, 0.5)
});
- checkPoints(Region.Location.OUTSIDE, set, new Coordinates2D[] {
- new Coordinates2D( 2.5, 2.5),
- new Coordinates2D(-0.5, 0.5),
- new Coordinates2D( 0.5, 2.5),
- new Coordinates2D( 2.5, 0.5),
- new Coordinates2D( 1.5, 1.5),
- new Coordinates2D( 3.5, 2.5),
- new Coordinates2D( 1.5, 2.5),
- new Coordinates2D( 2.5, 1.5),
- new Coordinates2D( 2.0, 1.5),
- new Coordinates2D( 2.0, 2.0),
- new Coordinates2D( 2.5, 1.0),
- new Coordinates2D( 2.5, 2.5),
- new Coordinates2D( 3.0, 2.5)
+ checkPoints(Region.Location.OUTSIDE, set, new Cartesian2D[] {
+ new Cartesian2D( 2.5, 2.5),
+ new Cartesian2D(-0.5, 0.5),
+ new Cartesian2D( 0.5, 2.5),
+ new Cartesian2D( 2.5, 0.5),
+ new Cartesian2D( 1.5, 1.5),
+ new Cartesian2D( 3.5, 2.5),
+ new Cartesian2D( 1.5, 2.5),
+ new Cartesian2D( 2.5, 1.5),
+ new Cartesian2D( 2.0, 1.5),
+ new Cartesian2D( 2.0, 2.0),
+ new Cartesian2D( 2.5, 1.0),
+ new Cartesian2D( 2.5, 2.5),
+ new Cartesian2D( 3.0, 2.5)
});
- checkPoints(Region.Location.BOUNDARY, set, new Coordinates2D[] {
- new Coordinates2D(1.0, 1.0),
- new Coordinates2D(1.5, 1.0),
- new Coordinates2D(0.0, 0.0),
- new Coordinates2D(0.5, 2.0),
- new Coordinates2D(2.0, 0.5)
+ checkPoints(Region.Location.BOUNDARY, set, new Cartesian2D[] {
+ new Cartesian2D(1.0, 1.0),
+ new Cartesian2D(1.5, 1.0),
+ new Cartesian2D(0.0, 0.0),
+ new Cartesian2D(0.5, 2.0),
+ new Cartesian2D(2.0, 0.5)
});
}
@Test
public void testEmptyDifference() {
- Coordinates2D[][] vertices1 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.5, 3.5),
- new Coordinates2D( 0.5, 4.5),
- new Coordinates2D(-0.5, 4.5),
- new Coordinates2D(-0.5, 3.5)
+ Cartesian2D[][] vertices1 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.5, 3.5),
+ new Cartesian2D( 0.5, 4.5),
+ new Cartesian2D(-0.5, 4.5),
+ new Cartesian2D(-0.5, 3.5)
}
};
PolygonsSet set1 = buildSet(vertices1);
- Coordinates2D[][] vertices2 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 1.0, 2.0),
- new Coordinates2D( 1.0, 8.0),
- new Coordinates2D(-1.0, 8.0),
- new Coordinates2D(-1.0, 2.0)
+ Cartesian2D[][] vertices2 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 1.0, 2.0),
+ new Cartesian2D( 1.0, 8.0),
+ new Cartesian2D(-1.0, 8.0),
+ new Cartesian2D(-1.0, 2.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -661,13 +661,13 @@ public class PolygonsSetTest {
double pi6 = FastMath.PI / 6.0;
double sqrt3 = FastMath.sqrt(3.0);
SubLine[] hyp = {
- new Line(new Coordinates2D( 0.0, 1.0), 5 * pi6, 1.0e-10).wholeHyperplane(),
- new Line(new Coordinates2D(-sqrt3, 1.0), 7 * pi6, 1.0e-10).wholeHyperplane(),
- new Line(new Coordinates2D(-sqrt3, 1.0), 9 * pi6, 1.0e-10).wholeHyperplane(),
- new Line(new Coordinates2D(-sqrt3, 0.0), 11 * pi6, 1.0e-10).wholeHyperplane(),
- new Line(new Coordinates2D( 0.0, 0.0), 13 * pi6, 1.0e-10).wholeHyperplane(),
- new Line(new Coordinates2D( 0.0, 1.0), 3 * pi6, 1.0e-10).wholeHyperplane(),
- new Line(new Coordinates2D(-5.0 * sqrt3 / 6.0, 0.0), 9 * pi6, 1.0e-10).wholeHyperplane()
+ new Line(new Cartesian2D( 0.0, 1.0), 5 * pi6, 1.0e-10).wholeHyperplane(),
+ new Line(new Cartesian2D(-sqrt3, 1.0), 7 * pi6, 1.0e-10).wholeHyperplane(),
+ new Line(new Cartesian2D(-sqrt3, 1.0), 9 * pi6, 1.0e-10).wholeHyperplane(),
+ new Line(new Cartesian2D(-sqrt3, 0.0), 11 * pi6, 1.0e-10).wholeHyperplane(),
+ new Line(new Cartesian2D( 0.0, 0.0), 13 * pi6, 1.0e-10).wholeHyperplane(),
+ new Line(new Cartesian2D( 0.0, 1.0), 3 * pi6, 1.0e-10).wholeHyperplane(),
+ new Line(new Cartesian2D(-5.0 * sqrt3 / 6.0, 0.0), 9 * pi6, 1.0e-10).wholeHyperplane()
};
hyp[1] = (SubLine) hyp[1].split(hyp[0].getHyperplane()).getMinus();
hyp[2] = (SubLine) hyp[2].split(hyp[1].getHyperplane()).getMinus();
@@ -681,14 +681,14 @@ public class PolygonsSetTest {
}
PolygonsSet set = new PolygonsSet(tree, 1.0e-10);
SubLine splitter =
- new Line(new Coordinates2D(-2.0 * sqrt3 / 3.0, 0.0), 9 * pi6, 1.0e-10).wholeHyperplane();
+ new Line(new Cartesian2D(-2.0 * sqrt3 / 3.0, 0.0), 9 * pi6, 1.0e-10).wholeHyperplane();
PolygonsSet slice =
new PolygonsSet(new BSPTree<>(splitter,
set.getTree(false).split(splitter).getPlus(),
new BSPTree<Euclidean2D>(Boolean.FALSE), null),
1.0e-10);
Assert.assertEquals(Region.Location.OUTSIDE,
- slice.checkPoint(new Coordinates2D(0.1, 0.5)));
+ slice.checkPoint(new Cartesian2D(0.1, 0.5)));
Assert.assertEquals(11.0 / 3.0, slice.getBoundarySize(), 1.0e-10);
}
@@ -696,27 +696,27 @@ public class PolygonsSetTest {
@Test
public void testConcentric() {
double h = FastMath.sqrt(3.0) / 2.0;
- Coordinates2D[][] vertices1 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.00, 0.1 * h),
- new Coordinates2D( 0.05, 0.1 * h),
- new Coordinates2D( 0.10, 0.2 * h),
- new Coordinates2D( 0.05, 0.3 * h),
- new Coordinates2D(-0.05, 0.3 * h),
- new Coordinates2D(-0.10, 0.2 * h),
- new Coordinates2D(-0.05, 0.1 * h)
+ Cartesian2D[][] vertices1 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.00, 0.1 * h),
+ new Cartesian2D( 0.05, 0.1 * h),
+ new Cartesian2D( 0.10, 0.2 * h),
+ new Cartesian2D( 0.05, 0.3 * h),
+ new Cartesian2D(-0.05, 0.3 * h),
+ new Cartesian2D(-0.10, 0.2 * h),
+ new Cartesian2D(-0.05, 0.1 * h)
}
};
PolygonsSet set1 = buildSet(vertices1);
- Coordinates2D[][] vertices2 = new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D( 0.00, 0.0 * h),
- new Coordinates2D( 0.10, 0.0 * h),
- new Coordinates2D( 0.20, 0.2 * h),
- new Coordinates2D( 0.10, 0.4 * h),
- new Coordinates2D(-0.10, 0.4 * h),
- new Coordinates2D(-0.20, 0.2 * h),
- new Coordinates2D(-0.10, 0.0 * h)
+ Cartesian2D[][] vertices2 = new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D( 0.00, 0.0 * h),
+ new Cartesian2D( 0.10, 0.0 * h),
+ new Cartesian2D( 0.20, 0.2 * h),
+ new Cartesian2D( 0.10, 0.4 * h),
+ new Cartesian2D(-0.10, 0.4 * h),
+ new Cartesian2D(-0.20, 0.2 * h),
+ new Cartesian2D(-0.10, 0.0 * h)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -726,126 +726,126 @@ public class PolygonsSetTest {
@Test
public void testBug20040520() {
BSPTree<Euclidean2D> a0 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.85, -0.05),
- new Coordinates2D(0.90, -0.10)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.85, -0.05),
+ new Cartesian2D(0.90, -0.10)),
new BSPTree<Euclidean2D>(Boolean.FALSE),
new BSPTree<Euclidean2D>(Boolean.TRUE),
null);
BSPTree<Euclidean2D> a1 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.85, -0.10),
- new Coordinates2D(0.90, -0.10)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.85, -0.10),
+ new Cartesian2D(0.90, -0.10)),
new BSPTree<Euclidean2D>(Boolean.FALSE), a0, null);
BSPTree<Euclidean2D> a2 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.90, -0.05),
- new Coordinates2D(0.85, -0.05)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.90, -0.05),
+ new Cartesian2D(0.85, -0.05)),
new BSPTree<Euclidean2D>(Boolean.FALSE), a1, null);
BSPTree<Euclidean2D> a3 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.82, -0.05),
- new Coordinates2D(0.82, -0.08)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.82, -0.05),
+ new Cartesian2D(0.82, -0.08)),
new BSPTree<Euclidean2D>(Boolean.FALSE),
new BSPTree<Euclidean2D>(Boolean.TRUE),
null);
BSPTree<Euclidean2D> a4 =
- new BSPTree<>(buildHalfLine(new Coordinates2D(0.85, -0.05),
- new Coordinates2D(0.80, -0.05),
+ new BSPTree<>(buildHalfLine(new Cartesian2D(0.85, -0.05),
+ new Cartesian2D(0.80, -0.05),
false),
new BSPTree<Euclidean2D>(Boolean.FALSE), a3, null);
BSPTree<Euclidean2D> a5 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.82, -0.08),
- new Coordinates2D(0.82, -0.18)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.82, -0.08),
+ new Cartesian2D(0.82, -0.18)),
new BSPTree<Euclidean2D>(Boolean.FALSE),
new BSPTree<Euclidean2D>(Boolean.TRUE),
null);
BSPTree<Euclidean2D> a6 =
- new BSPTree<>(buildHalfLine(new Coordinates2D(0.82, -0.18),
- new Coordinates2D(0.85, -0.15),
+ new BSPTree<>(buildHalfLine(new Cartesian2D(0.82, -0.18),
+ new Cartesian2D(0.85, -0.15),
true),
new BSPTree<Euclidean2D>(Boolean.FALSE), a5, null);
BSPTree<Euclidean2D> a7 =
- new BSPTree<>(buildHalfLine(new Coordinates2D(0.85, -0.05),
- new Coordinates2D(0.82, -0.08),
+ new BSPTree<>(buildHalfLine(new Cartesian2D(0.85, -0.05),
+ new Cartesian2D(0.82, -0.08),
false),
a4, a6, null);
BSPTree<Euclidean2D> a8 =
- new BSPTree<>(buildLine(new Coordinates2D(0.85, -0.25),
- new Coordinates2D(0.85, 0.05)),
+ new BSPTree<>(buildLine(new Cartesian2D(0.85, -0.25),
+ new Cartesian2D(0.85, 0.05)),
a2, a7, null);
BSPTree<Euclidean2D> a9 =
- new BSPTree<>(buildLine(new Coordinates2D(0.90, 0.05),
- new Coordinates2D(0.90, -0.50)),
+ new BSPTree<>(buildLine(new Cartesian2D(0.90, 0.05),
+ new Cartesian2D(0.90, -0.50)),
a8, new BSPTree<Euclidean2D>(Boolean.FALSE), null);
BSPTree<Euclidean2D> b0 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.92, -0.12),
- new Coordinates2D(0.92, -0.08)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.92, -0.12),
+ new Cartesian2D(0.92, -0.08)),
new BSPTree<Euclidean2D>(Boolean.FALSE), new BSPTree<Euclidean2D>(Boolean.TRUE),
null);
BSPTree<Euclidean2D> b1 =
- new BSPTree<>(buildHalfLine(new Coordinates2D(0.92, -0.08),
- new Coordinates2D(0.90, -0.10),
+ new BSPTree<>(buildHalfLine(new Cartesian2D(0.92, -0.08),
+ new Cartesian2D(0.90, -0.10),
true),
new BSPTree<Euclidean2D>(Boolean.FALSE), b0, null);
BSPTree<Euclidean2D> b2 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.92, -0.18),
- new Coordinates2D(0.92, -0.12)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.92, -0.18),
+ new Cartesian2D(0.92, -0.12)),
new BSPTree<Euclidean2D>(Boolean.FALSE), new BSPTree<Euclidean2D>(Boolean.TRUE),
null);
BSPTree<Euclidean2D> b3 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.85, -0.15),
- new Coordinates2D(0.90, -0.20)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.85, -0.15),
+ new Cartesian2D(0.90, -0.20)),
new BSPTree<Euclidean2D>(Boolean.FALSE), b2, null);
BSPTree<Euclidean2D> b4 =
- new BSPTree<>(buildSegment(new Coordinates2D(0.95, -0.15),
- new Coordinates2D(0.85, -0.05)),
+ new BSPTree<>(buildSegment(new Cartesian2D(0.95, -0.15),
+ new Cartesian2D(0.85, -0.05)),
b1, b3, null);
BSPTree<Euclidean2D> b5 =
- new BSPTree<>(buildHalfLine(new Coordinates2D(0.85, -0.05),
- new Coordinates2D(0.85, -0.25),
+ new BSPTree<>(buildHalfLine(new Cartesian2D(0.85, -0.05),
+ new Cartesian2D(0.85, -0.25),
true),
new BSPTree<Euclidean2D>(Boolean.FALSE), b4, null);
BSPTree<Euclidean2D> b6 =
- new BSPTree<>(buildLine(new Coordinates2D(0.0, -1.10),
- new Coordinates2D(1.0, -0.10)),
+ new BSPTree<>(buildLine(new Cartesian2D(0.0, -1.10),
+ new Cartesian2D(1.0, -0.10)),
new BSPTree<Euclidean2D>(Boolean.FALSE), b5, null);
PolygonsSet c =
(PolygonsSet) new RegionFactory<Euclidean2D>().union(new PolygonsSet(a9, 1.0e-10),
new PolygonsSet(b6, 1.0e-10));
- checkPoints(Region.Location.INSIDE, c, new Coordinates2D[] {
- new Coordinates2D(0.83, -0.06),
- new Coordinates2D(0.83, -0.15),
- new Coordinates2D(0.88, -0.15),
- new Coordinates2D(0.88, -0.09),
- new Coordinates2D(0.88, -0.07),
- new Coordinates2D(0.91, -0.18),
- new Coordinates2D(0.91, -0.10)
+ checkPoints(Region.Location.INSIDE, c, new Cartesian2D[] {
+ new Cartesian2D(0.83, -0.06),
+ new Cartesian2D(0.83, -0.15),
+ new Cartesian2D(0.88, -0.15),
+ new Cartesian2D(0.88, -0.09),
+ new Cartesian2D(0.88, -0.07),
+ new Cartesian2D(0.91, -0.18),
+ new Cartesian2D(0.91, -0.10)
});
- checkPoints(Region.Location.OUTSIDE, c, new Coordinates2D[] {
- new Coordinates2D(0.80, -0.10),
- new Coordinates2D(0.83, -0.50),
- new Coordinates2D(0.83, -0.20),
- new Coordinates2D(0.83, -0.02),
- new Coordinates2D(0.87, -0.50),
- new Coordinates2D(0.87, -0.20),
- new Coordinates2D(0.87, -0.02),
- new Coordinates2D(0.91, -0.20),
- new Coordinates2D(0.91, -0.08),
- new Coordinates2D(0.93, -0.15)
+ checkPoints(Region.Location.OUTSIDE, c, new Cartesian2D[] {
+ new Cartesian2D(0.80, -0.10),
+ new Cartesian2D(0.83, -0.50),
+ new Cartesian2D(0.83, -0.20),
+ new Cartesian2D(0.83, -0.02),
+ new Cartesian2D(0.87, -0.50),
+ new Cartesian2D(0.87, -0.20),
+ new Cartesian2D(0.87, -0.02),
+ new Cartesian2D(0.91, -0.20),
+ new Cartesian2D(0.91, -0.08),
+ new Cartesian2D(0.93, -0.15)
});
checkVertices(c.getVertices(),
- new Coordinates2D[][] {
- new Coordinates2D[] {
- new Coordinates2D(0.85, -0.15),
- new Coordinates2D(0.90, -0.20),
- new Coordinates2D(0.92, -0.18),
- new Coordinates2D(0.92, -0.08),
- new Coordinates2D(0.90, -0.10),
- new Coordinates2D(0.90, -0.05),
- new Coordinates2D(0.82, -0.05),
- new Coordinates2D(0.82, -0.18),
+ new Cartesian2D[][] {
+ new Cartesian2D[] {
+ new Cartesian2D(0.85, -0.15),
+ new Cartesian2D(0.90, -0.20),
+ new Cartesian2D(0.92, -0.18),
+ new Cartesian2D(0.92, -0.08),
+ new Cartesian2D(0.90, -0.10),
+ new Cartesian2D(0.90, -0.05),
+ new Cartesian2D(0.82, -0.05),
+ new Cartesian2D(0.82, -0.18),
}
});
@@ -855,14 +855,14 @@ public class PolygonsSetTest {
public void testBug20041003() {
Line[] l = {
- new Line(new Coordinates2D(0.0, 0.625000007541172),
- new Coordinates2D(1.0, 0.625000007541172), 1.0e-10),
- new Line(new Coordinates2D(-0.19204433621902645, 0.0),
- new Coordinates2D(-0.19204433621902645, 1.0), 1.0e-10),
- new Line(new Coordinates2D(-0.40303524786887, 0.4248364535319128),
- new Coordinates2D(-1.12851149797877, -0.2634107480798909), 1.0e-10),
- new Line(new Coordinates2D(0.0, 2.0),
- new Coordinates2D(1.0, 2.0), 1.0e-10)
+ new Line(new Cartesian2D(0.0, 0.625000007541172),
+ new Cartesian2D(1.0, 0.625000007541172), 1.0e-10),
+ new Line(new Cartesian2D(-0.19204433621902645, 0.0),
+ new Cartesian2D(-0.19204433621902645, 1.0), 1.0e-10),
+ new Line(new Cartesian2D(-0.40303524786887, 0.4248364535319128),
+ new Cartesian2D(-1.12851149797877, -0.2634107480798909), 1.0e-10),
+ new Line(new Cartesian2D(0.0, 2.0),
+ new Cartesian2D(1.0, 2.0), 1.0e-10)
};
BSPTree<Euclidean2D> node1 =
@@ -902,182 +902,182 @@ public class PolygonsSetTest {
@Test
public void testSqueezedHexa() {
PolygonsSet set = new PolygonsSet(1.0e-10,
- new Coordinates2D(-6, -4), new Coordinates2D(-8, -8), new Coordinates2D( 8, -8),
- new Coordinates2D( 6, -4), new Coordinates2D(10, 4), new Coordinates2D(-10, 4));
- Assert.assertEquals(Location.OUTSIDE, set.checkPoint(new Coordinates2D(0, 6)));
+ new Cartesian2D(-6, -4), new Cartesian2D(-8, -8), new Cartesian2D( 8, -8),
+ new Cartesian2D( 6, -4), new Cartesian2D(10, 4), new Cartesian2D(-10, 4));
+ Assert.assertEquals(Location.OUTSIDE, set.checkPoint(new Cartesian2D(0, 6)));
}
@Test
public void testIssue880Simplified() {
- Coordinates2D[] vertices1 = new Coordinates2D[] {
- new Coordinates2D( 90.13595870833188, 38.33604606376991),
- new Coordinates2D( 90.14047850603913, 38.34600084496253),
- new Coordinates2D( 90.11045289492762, 38.36801537312368),
- new Coordinates2D( 90.10871471476526, 38.36878044144294),
- new Coordinates2D( 90.10424901707671, 38.374300101757),
- new Coordinates2D( 90.0979455456843, 38.373578376172475),
- new Coordinates2D( 90.09081227075944, 38.37526295920463),
- new Coordinates2D( 90.09081378927135, 38.375193883266434)
+ Cartesian2D[] vertices1 = new Cartesian2D[] {
+ new Cartesian2D( 90.13595870833188, 38.33604606376991),
+ new Cartesian2D( 90.14047850603913, 38.34600084496253),
+ new Cartesian2D( 90.11045289492762, 38.36801537312368),
+ new Cartesian2D( 90.10871471476526, 38.36878044144294),
+ new Cartesian2D( 90.10424901707671, 38.374300101757),
+ new Cartesian2D( 90.0979455456843, 38.373578376172475),
+ new Cartesian2D( 90.09081227075944, 38.37526295920463),
+ new Cartesian2D( 90.09081378927135, 38.375193883266434)
};
PolygonsSet set1 = new PolygonsSet(1.0e-10, vertices1);
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Coordinates2D(90.12, 38.32)));
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Coordinates2D(90.135, 38.355)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Cartesian2D(90.12, 38.32)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Cartesian2D(90.135, 38.355)));
}
@Test
public void testIssue880Complete() {
- Coordinates2D[] vertices1 = new Coordinates2D[] {
- new Coordinates2D( 90.08714908223715, 38.370299337260235),
- new Coordinates2D( 90.08709517675004, 38.3702895991413),
- new Coordinates2D( 90.08401538704919, 38.368849330127944),
- new Coordinates2D( 90.08258210430711, 38.367634558585564),
- new Coordinates2D( 90.08251455106665, 38.36763409247078),
- new Coordinates2D( 90.08106599752608, 38.36761621664249),
- new Coordinates2D( 90.08249585300035, 38.36753627557965),
- new Coordinates2D( 90.09075743352184, 38.35914647644972),
- new Coordinates2D( 90.09099945896571, 38.35896264724079),
- new Coordinates2D( 90.09269383800086, 38.34595756121246),
- new Coordinates2D( 90.09638631543191, 38.3457988093121),
- new Coordinates2D( 90.09666417351019, 38.34523360999418),
- new Coordinates2D( 90.1297082145872, 38.337670454923625),
- new Coordinates2D( 90.12971687748956, 38.337669827794684),
- new Coordinates2D( 90.1240820219179, 38.34328502001131),
- new Coordinates2D( 90.13084259656404, 38.34017811765017),
- new Coordinates2D( 90.13378567942857, 38.33860579180606),
- new Coordinates2D( 90.13519557833206, 38.33621054663689),
- new Coordinates2D( 90.13545616732307, 38.33614965452864),
- new Coordinates2D( 90.13553111202748, 38.33613962818305),
- new Coordinates2D( 90.1356903436448, 38.33610227127048),
- new Coordinates2D( 90.13576283227428, 38.33609255422783),
- new Coordinates2D( 90.13595870833188, 38.33604606376991),
- new Coordinates2D( 90.1361556630693, 38.3360024198866),
- new Coordinates2D( 90.13622408795709, 38.335987048115726),
- new Coordinates2D( 90.13696189099994, 38.33581914328681),
- new Coordinates2D( 90.13746655304897, 38.33616706665265),
- new Coordinates2D( 90.13845973716064, 38.33650776167099),
- new Coordinates2D( 90.13950901827667, 38.3368469456463),
- new Coordinates2D( 90.14393814424852, 38.337591835857495),
- new Coordinates2D( 90.14483839716831, 38.337076122362475),
- new Coordinates2D( 90.14565474433601, 38.33769000964429),
- new Coordinates2D( 90.14569421179482, 38.3377117256905),
- new Coordinates2D( 90.14577067124333, 38.33770883625908),
- new Coordinates2D( 90.14600350631684, 38.337714326520995),
- new Coordinates2D( 90.14600355139731, 38.33771435193319),
- new Coordinates2D( 90.14600369112401, 38.33771443882085),
- new Coordinates2D( 90.14600382486884, 38.33771453466096),
- new Coordinates2D( 90.14600395205912, 38.33771463904344),
- new Coordinates2D( 90.14600407214999, 38.337714751520764),
- new Coordinates2D( 90.14600418462749, 38.337714871611695),
- new Coordinates2D( 90.14600422249327, 38.337714915811034),
- new Coordinates2D( 90.14867838361471, 38.34113888210675),
- new Coordinates2D( 90.14923750157374, 38.341582537502575),
- new Coordinates2D( 90.14877083250991, 38.34160685841391),
- new Coordinates2D( 90.14816667319519, 38.34244232585684),
- new Coordinates2D( 90.14797696744586, 38.34248455284745),
- new Coordinates2D( 90.14484318014337, 38.34385573215269),
- new Coordinates2D( 90.14477919958296, 38.3453797747614),
- new Coordinates2D( 90.14202393306448, 38.34464324839456),
- new Coordinates2D( 90.14198920640195, 38.344651155237216),
- new Coordinates2D( 90.14155207025175, 38.34486424263724),
- new Coordinates2D( 90.1415196143314, 38.344871730519),
- new Coordinates2D( 90.14128611910814, 38.34500196593859),
- new Coordinates2D( 90.14047850603913, 38.34600084496253),
- new Coordinates2D( 90.14045907000337, 38.34601860032171),
- new Coordinates2D( 90.14039496493928, 38.346223030432384),
- new Coordinates2D( 90.14037626063737, 38.346240203360026),
- new Coordinates2D( 90.14030005823724, 38.34646920000705),
- new Coordinates2D( 90.13799164754806, 38.34903093011013),
- new Coordinates2D( 90.11045289492762, 38.36801537312368),
- new Coordinates2D( 90.10871471476526, 38.36878044144294),
- new Coordinates2D( 90.10424901707671, 38.374300101757),
- new Coordinates2D( 90.10263482039932, 38.37310041316073),
- new Coordinates2D( 90.09834601753448, 38.373615053823414),
- new Coordinates2D( 90.0979455456843, 38.373578376172475),
- new Coordinates2D( 90.09086514328669, 38.37527884194668),
- new Coordinates2D( 90.09084931407364, 38.37590801712463),
- new Coordinates2D( 90.09081227075944, 38.37526295920463),
- new Coordinates2D( 90.09081378927135, 38.375193883266434)
+ Cartesian2D[] vertices1 = new Cartesian2D[] {
+ new Cartesian2D( 90.08714908223715, 38.370299337260235),
+ new Cartesian2D( 90.08709517675004, 38.3702895991413),
+ new Cartesian2D( 90.08401538704919, 38.368849330127944),
+ new Cartesian2D( 90.08258210430711, 38.367634558585564),
+ new Cartesian2D( 90.08251455106665, 38.36763409247078),
+ new Cartesian2D( 90.08106599752608, 38.36761621664249),
+ new Cartesian2D( 90.08249585300035, 38.36753627557965),
+ new Cartesian2D( 90.09075743352184, 38.35914647644972),
+ new Cartesian2D( 90.09099945896571, 38.35896264724079),
+ new Cartesian2D( 90.09269383800086, 38.34595756121246),
+ new Cartesian2D( 90.09638631543191, 38.3457988093121),
+ new Cartesian2D( 90.09666417351019, 38.34523360999418),
+ new Cartesian2D( 90.1297082145872, 38.337670454923625),
+ new Cartesian2D( 90.12971687748956, 38.337669827794684),
+ new Cartesian2D( 90.1240820219179, 38.34328502001131),
+ new Cartesian2D( 90.13084259656404, 38.34017811765017),
+ new Cartesian2D( 90.13378567942857, 38.33860579180606),
+ new Cartesian2D( 90.13519557833206, 38.33621054663689),
+ new Cartesian2D( 90.13545616732307, 38.33614965452864),
+ new Cartesian2D( 90.13553111202748, 38.33613962818305),
+ new Cartesian2D( 90.1356903436448, 38.33610227127048),
+ new Cartesian2D( 90.13576283227428, 38.33609255422783),
+ new Cartesian2D( 90.13595870833188, 38.33604606376991),
+ new Cartesian2D( 90.1361556630693, 38.3360024198866),
+ new Cartesian2D( 90.13622408795709, 38.335987048115726),
+ new Cartesian2D( 90.13696189099994, 38.33581914328681),
+ new Cartesian2D( 90.13746655304897, 38.33616706665265),
+ new Cartesian2D( 90.13845973716064, 38.33650776167099),
+ new Cartesian2D( 90.13950901827667, 38.3368469456463),
+ new Cartesian2D( 90.14393814424852, 38.337591835857495),
+ new Cartesian2D( 90.14483839716831, 38.337076122362475),
+ new Cartesian2D( 90.14565474433601, 38.33769000964429),
+ new Cartesian2D( 90.14569421179482, 38.3377117256905),
+ new Cartesian2D( 90.14577067124333, 38.33770883625908),
+ new Cartesian2D( 90.14600350631684, 38.337714326520995),
+ new Cartesian2D( 90.14600355139731, 38.33771435193319),
+ new Cartesian2D( 90.14600369112401, 38.33771443882085),
+ new Cartesian2D( 90.14600382486884, 38.33771453466096),
+ new Cartesian2D( 90.14600395205912, 38.33771463904344),
+ new Cartesian2D( 90.14600407214999, 38.337714751520764),
+ new Cartesian2D( 90.14600418462749, 38.337714871611695),
+ new Cartesian2D( 90.14600422249327, 38.337714915811034),
+ new Cartesian2D( 90.14867838361471, 38.34113888210675),
+ new Cartesian2D( 90.14923750157374, 38.341582537502575),
+ new Cartesian2D( 90.14877083250991, 38.34160685841391),
+ new Cartesian2D( 90.14816667319519, 38.34244232585684),
+ new Cartesian2D( 90.14797696744586, 38.34248455284745),
+ new Cartesian2D( 90.14484318014337, 38.34385573215269),
+ new Cartesian2D( 90.14477919958296, 38.3453797747614),
+ new Cartesian2D( 90.14202393306448, 38.34464324839456),
+ new Cartesian2D( 90.14198920640195, 38.344651155237216),
+ new Cartesian2D( 90.14155207025175, 38.34486424263724),
+ new Cartesian2D( 90.1415196143314, 38.344871730519),
+ new Cartesian2D( 90.14128611910814, 38.34500196593859),
+ new Cartesian2D( 90.14047850603913, 38.34600084496253),
+ new Cartesian2D( 90.14045907000337, 38.34601860032171),
+ new Cartesian2D( 90.14039496493928, 38.346223030432384),
+ new Cartesian2D( 90.14037626063737, 38.346240203360026),
+ new Cartesian2D( 90.14030005823724, 38.34646920000705),
+ new Cartesian2D( 90.13799164754806, 38.34903093011013),
+ new Cartesian2D( 90.11045289492762, 38.36801537312368),
+ new Cartesian2D( 90.10871471476526, 38.36878044144294),
+ new Cartesian2D( 90.10424901707671, 38.374300101757),
+ new Cartesian2D( 90.10263482039932, 38.37310041316073),
+ new Cartesian2D( 90.09834601753448, 38.373615053823414),
+ new Cartesian2D( 90.0979455456843, 38.373578376172475),
+ new Cartesian2D( 90.09086514328669, 38.37527884194668),
+ new Cartesian2D( 90.09084931407364, 38.37590801712463),
+ new Cartesian2D( 90.09081227075944, 38.37526295920463),
+ new Cartesian2D( 90.09081378927135, 38.375193883266434)
};
PolygonsSet set1 = new PolygonsSet(1.0e-8, vertices1);
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Coordinates2D(90.0905, 38.3755)));
- Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Coordinates2D(90.09084, 38.3755)));
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Coordinates2D(90.0913, 38.3755)));
- Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Coordinates2D(90.1042, 38.3739)));
- Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Coordinates2D(90.1111, 38.3673)));
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Coordinates2D(90.0959, 38.3457)));
-
- Coordinates2D[] vertices2 = new Coordinates2D[] {
- new Coordinates2D( 90.13067558880044, 38.36977255037573),
- new Coordinates2D( 90.12907570488, 38.36817308242706),
- new Coordinates2D( 90.1342774136516, 38.356886880294724),
- new Coordinates2D( 90.13090330629757, 38.34664392676211),
- new Coordinates2D( 90.13078571364593, 38.344904617518466),
- new Coordinates2D( 90.1315602208914, 38.3447185040846),
- new Coordinates2D( 90.1316336226821, 38.34470643148342),
- new Coordinates2D( 90.134020944832, 38.340936644972885),
- new Coordinates2D( 90.13912536387306, 38.335497255122334),
- new Coordinates2D( 90.1396178806582, 38.334878075552126),
- new Coordinates2D( 90.14083049696671, 38.33316530644106),
- new Coordinates2D( 90.14145252901329, 38.33152722916191),
- new Coordinates2D( 90.1404779335565, 38.32863516047786),
- new Coordinates2D( 90.14282712131586, 38.327504432532066),
- new Coordinates2D( 90.14616669875488, 38.3237354115015),
- new Coordinates2D( 90.14860976050608, 38.315714862457924),
- new Coordinates2D( 90.14999277782437, 38.3164932507504),
- new Coordinates2D( 90.15005207194997, 38.316534677663356),
- new Coordinates2D( 90.15508513859612, 38.31878731691609),
- new Coordinates2D( 90.15919938519221, 38.31852743183782),
- new Coordinates2D( 90.16093758658837, 38.31880662005153),
- new Coordinates2D( 90.16099420184912, 38.318825953291594),
- new Coordinates2D( 90.1665411125756, 38.31859497874757),
- new Coordinates2D( 90.16999653861313, 38.32505772048029),
- new Coordinates2D( 90.17475243391698, 38.32594398441148),
- new Coordinates2D( 90.17940844844992, 38.327427213761325),
- new Coordinates2D( 90.20951909541378, 38.330616833491774),
- new Coordinates2D( 90.2155400467941, 38.331746223670336),
- new Coordinates2D( 90.21559881391778, 38.33175551425302),
- new Coordinates2D( 90.21916646426041, 38.332584299620805),
- new Coordinates2D( 90.23863749852285, 38.34778978875795),
- new Coordinates2D( 90.25459855175802, 38.357790570608984),
- new Coordinates2D( 90.25964298227257, 38.356918010203174),
- new Coordinates2D( 90.26024593994703, 38.361692743151366),
- new Coordinates2D( 90.26146187570015, 38.36311080550837),
- new Coordinates2D( 90.26614159359622, 38.36510808579902),
- new Coordinates2D( 90.26621342936448, 38.36507942500333),
- new Coordinates2D( 90.26652190211962, 38.36494042196722),
- new Coordinates2D( 90.26621240678867, 38.365113172030874),
- new Coordinates2D( 90.26614057102057, 38.365141832826794),
- new Coordinates2D( 90.26380080055299, 38.3660381760273),
- new Coordinates2D( 90.26315345241, 38.36670658276421),
- new Coordinates2D( 90.26251574942881, 38.367490323488084),
- new Coordinates2D( 90.26247873448426, 38.36755266444749),
- new Coordinates2D( 90.26234628016698, 38.36787989125406),
- new Coordinates2D( 90.26214559424784, 38.36945909356126),
- new Coordinates2D( 90.25861728442555, 38.37200753430875),
- new Coordinates2D( 90.23905557537864, 38.375405314295904),
- new Coordinates2D( 90.22517251874075, 38.38984691662256),
- new Coordinates2D( 90.22549955153215, 38.3911564273979),
- new Coordinates2D( 90.22434386063355, 38.391476432092134),
- new Coordinates2D( 90.22147729457276, 38.39134652252034),
- new Coordinates2D( 90.22142070120117, 38.391349167741964),
- new Coordinates2D( 90.20665060751588, 38.39475580900313),
- new Coordinates2D( 90.20042268367109, 38.39842558622888),
- new Coordinates2D( 90.17423771242085, 38.402727751805344),
- new Coordinates2D( 90.16756796257476, 38.40913898597597),
- new Coordinates2D( 90.16728283954308, 38.411255399912875),
- new Coordinates2D( 90.16703538220418, 38.41136059866693),
- new Coordinates2D( 90.16725865657685, 38.41013618805954),
- new Coordinates2D( 90.16746107640665, 38.40902614307544),
- new Coordinates2D( 90.16122795307462, 38.39773101873203)
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Cartesian2D(90.0905, 38.3755)));
+ Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Cartesian2D(90.09084, 38.3755)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Cartesian2D(90.0913, 38.3755)));
+ Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Cartesian2D(90.1042, 38.3739)));
+ Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Cartesian2D(90.1111, 38.3673)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Cartesian2D(90.0959, 38.3457)));
+
+ Cartesian2D[] vertices2 = new Cartesian2D[] {
+ new Cartesian2D( 90.13067558880044, 38.36977255037573),
+ new Cartesian2D( 90.12907570488, 38.36817308242706),
+ new Cartesian2D( 90.1342774136516, 38.356886880294724),
+ new Cartesian2D( 90.13090330629757, 38.34664392676211),
+ new Cartesian2D( 90.13078571364593, 38.344904617518466),
+ new Cartesian2D( 90.1315602208914, 38.3447185040846),
+ new Cartesian2D( 90.1316336226821, 38.34470643148342),
+ new Cartesian2D( 90.134020944832, 38.340936644972885),
+ new Cartesian2D( 90.13912536387306, 38.335497255122334),
+ new Cartesian2D( 90.1396178806582, 38.334878075552126),
+ new Cartesian2D( 90.14083049696671, 38.33316530644106),
+ new Cartesian2D( 90.14145252901329, 38.33152722916191),
+ new Cartesian2D( 90.1404779335565, 38.32863516047786),
+ new Cartesian2D( 90.14282712131586, 38.327504432532066),
+ new Cartesian2D( 90.14616669875488, 38.3237354115015),
+ new Cartesian2D( 90.14860976050608, 38.315714862457924),
+ new Cartesian2D( 90.14999277782437, 38.3164932507504),
+ new Cartesian2D( 90.15005207194997, 38.316534677663356),
+ new Cartesian2D( 90.15508513859612, 38.31878731691609),
+ new Cartesian2D( 90.15919938519221, 38.31852743183782),
+ new Cartesian2D( 90.16093758658837, 38.31880662005153),
+ new Cartesian2D( 90.16099420184912, 38.318825953291594),
+ new Cartesian2D( 90.1665411125756, 38.31859497874757),
+ new Cartesian2D( 90.16999653861313, 38.32505772048029),
+ new Cartesian2D( 90.17475243391698, 38.32594398441148),
+ new Cartesian2D( 90.17940844844992, 38.327427213761325),
+ new Cartesian2D( 90.20951909541378, 38.330616833491774),
+ new Cartesian2D( 90.2155400467941, 38.331746223670336),
+ new Cartesian2D( 90.21559881391778, 38.33175551425302),
+ new Cartesian2D( 90.21916646426041, 38.332584299620805),
+ new Cartesian2D( 90.23863749852285, 38.34778978875795),
+ new Cartesian2D( 90.25459855175802, 38.357790570608984),
+ new Cartesian2D( 90.25964298227257, 38.356918010203174),
+ new Cartesian2D( 90.26024593994703, 38.361692743151366),
+ new Cartesian2D( 90.26146187570015, 38.36311080550837),
+ new Cartesian2D( 90.26614159359622, 38.36510808579902),
+ new Cartesian2D( 90.26621342936448, 38.36507942500333),
+ new Cartesian2D( 90.26652190211962, 38.36494042196722),
+ new Cartesian2D( 90.26621240678867, 38.365113172030874),
+ new Cartesian2D( 90.26614057102057, 38.365141832826794),
+ new Cartesian2D( 90.26380080055299, 38.3660381760273),
+ new Cartesian2D( 90.26315345241, 38.36670658276421),
+ new Cartesian2D( 90.26251574942881, 38.367490323488084),
+ new Cartesian2D( 90.26247873448426, 38.36755266444749),
+ new Cartesian2D( 90.26234628016698, 38.36787989125406),
+ new Cartesian2D( 90.26214559424784, 38.36945909356126),
+ new Cartesian2D( 90.25861728442555, 38.37200753430875),
+ new Cartesian2D( 90.23905557537864, 38.375405314295904),
+ new Cartesian2D( 90.22517251874075, 38.38984691662256),
+ new Cartesian2D( 90.22549955153215, 38.3911564273979),
+ new Cartesian2D( 90.22434386063355, 38.391476432092134),
+ new Cartesian2D( 90.22147729457276, 38.39134652252034),
+ new Cartesian2D( 90.22142070120117, 38.391349167741964),
+ new Cartesian2D( 90.20665060751588, 38.39475580900313),
+ new Cartesian2D( 90.20042268367109, 38.39842558622888),
+ new Cartesian2D( 90.17423771242085, 38.402727751805344),
+ new Cartesian2D( 90.16756796257476, 38.40913898597597),
+ new Cartesian2D( 90.16728283954308, 38.411255399912875),
+ new Cartesian2D( 90.16703538220418, 38.41136059866693),
+ new Cartesian2D( 90.16725865657685, 38.41013618805954),
+ new Cartesian2D( 90.16746107640665, 38.40902614307544),
+ new Cartesian2D( 90.16122795307462, 38.39773101873203)
};
PolygonsSet set2 = new PolygonsSet(1.0e-8, vertices2);
PolygonsSet set = (PolygonsSet) new
RegionFactory<Euclidean2D>().difference(set1.copySelf(),
set2.copySelf());
- Coordinates2D[][] vertices = set.getVertices();
+ Cartesian2D[][] vertices = set.getVertices();
Assert.assertTrue(vertices[0][0] != null);
Assert.assertEquals(1, vertices.length);
}
@@ -1107,17 +1107,17 @@ public class PolygonsSetTest {
@Test
public void testIssue1162() {
PolygonsSet p = new PolygonsSet(1.0e-10,
- new Coordinates2D(4.267199999996532, -11.928637756014894),
- new Coordinates2D(4.267200000026445, -14.12360595809307),
- new Coordinates2D(9.144000000273694, -14.12360595809307),
- new Coordinates2D(9.144000000233383, -11.928637756020067));
+ new Cartesian2D(4.267199999996532, -11.928637756014894),
+ new Cartesian2D(4.267200000026445, -14.12360595809307),
+ new Cartesian2D(9.144000000273694, -14.12360595809307),
+ new Cartesian2D(9.144000000233383, -11.928637756020067));
PolygonsSet w = new PolygonsSet(1.0e-10,
- new Coordinates2D(2.56735636510452512E-9, -11.933116461089332),
- new Coordinates2D(2.56735636510452512E-9, -12.393225665247766),
- new Coordinates2D(2.56735636510452512E-9, -27.785625665247778),
- new Coordinates2D(4.267200000030211, -27.785625665247778),
- new Coordinates2D(4.267200000030211, -11.933116461089332));
+ new Cartesian2D(2.56735636510452512E-9, -11.933116461089332),
+ new Cartesian2D(2.56735636510452512E-9, -12.393225665247766),
+ new Cartesian2D(2.56735636510452512E-9, -27.785625665247778),
+ new Cartesian2D(4.267200000030211, -27.785625665247778),
+ new Cartesian2D(4.267200000030211, -11.933116461089332));
Assert.assertFalse(p.contains(w));
@@ -1127,10 +1127,10 @@ public class PolygonsSetTest {
public void testThinRectangle() {
RegionFactory<Euclidean2D> factory = new RegionFactory<>();
- Coordinates2D pA = new Coordinates2D(0.0, 1.0);
- Coordinates2D pB = new Coordinates2D(0.0, 0.0);
- Coordinates2D pC = new Coordinates2D(1.0 / 64.0, 0.0);
- Coordinates2D pD = new Coordinates2D(1.0 / 64.0, 1.0);
+ Cartesian2D pA = new Cartesian2D(0.0, 1.0);
+ Cartesian2D pB = new Cartesian2D(0.0, 0.0);
+ Cartesian2D pC = new Cartesian2D(1.0 / 64.0, 0.0);
+ Cartesian2D pD = new Cartesian2D(1.0 / 64.0, 1.0);
// if tolerance is smaller than rectangle width, the rectangle is computed accurately
Hyperplane<Euclidean2D>[] h1 = new Line[] {
@@ -1163,8 +1163,8 @@ public class PolygonsSetTest {
@Test(expected=MathIllegalArgumentException.class)
public void testInconsistentHyperplanes() {
double tolerance = 1.0e-10;
- new RegionFactory<Euclidean2D>().buildConvex(new Line(new Coordinates2D(0, 0), new Coordinates2D(0, 1), tolerance),
- new Line(new Coordinates2D(1, 1), new Coordinates2D(1, 0), tolerance));
+ new RegionFactory<Euclidean2D>().buildConvex(new Line(new Cartesian2D(0, 0), new Cartesian2D(0, 1), tolerance),
+ new Line(new Cartesian2D(1, 1), new Cartesian2D(1, 0), tolerance));
}
@Test
@@ -1172,11 +1172,11 @@ public class PolygonsSetTest {
// a simple square will result in a 4 cuts and 5 leafs tree
PolygonsSet square = new PolygonsSet(1.0e-10,
- new Coordinates2D(0, 0),
- new Coordinates2D(1, 0),
- new Coordinates2D(1, 1),
- new Coordinates2D(0, 1));
- Coordinates2D[][] squareBoundary = square.getVertices();
+ new Cartesian2D(0, 0),
+ new Cartesian2D(1, 0),
+ new Cartesian2D(1, 1),
+ new Cartesian2D(0, 1));
+ Cartesian2D[][] squareBoundary = square.getVertices();
Assert.assertEquals(1, squareBoundary.length);
Assert.assertEquals(4, squareBoundary[0].length);
Counter squareCount = new Counter();
@@ -1186,7 +1186,7 @@ public class PolygonsSetTest {
// splitting the square in two halves increases the BSP tree
// with 3 more cuts and 3 more leaf nodes
- SubLine cut = new Line(new Coordinates2D(0.5, 0.5), 0.0, square.getTolerance()).wholeHyperplane();
+ SubLine cut = new Line(new Cartesian2D(0.5, 0.5), 0.0, square.getTolerance()).wholeHyperplane();
PolygonsSet splitSquare = new PolygonsSet(square.getTree(false).split(cut),
square.getTolerance());
Counter splitSquareCount = new Counter();
@@ -1197,7 +1197,7 @@ public class PolygonsSetTest {
// the number of vertices should not change, as the intermediate vertices
// at (0.0, 0.5) and (1.0, 0.5) induced by the top level horizontal split
// should be removed during the boundary extraction process
- Coordinates2D[][] splitBoundary = splitSquare.getVertices();
+ Cartesian2D[][] splitBoundary = splitSquare.getVertices();
Assert.assertEquals(1, splitBoundary.length);
Assert.assertEquals(4, splitBoundary[0].length);
@@ -1238,7 +1238,7 @@ public class PolygonsSetTest {
}
- private PolygonsSet buildSet(Coordinates2D[][] vertices) {
+ private PolygonsSet buildSet(Cartesian2D
<TRUNCATED>
[17/19] [math] MATH-1284: Restore Vector2D class as an abstract
implementation of Vector and now Cartesian2D extends Vector2D.
Restore the public interface of Vector2DFormat to act on Vector2D.
Posted by ra...@apache.org.
MATH-1284: Restore Vector2D class as an abstract implementation of Vector<Euclidean2D> and now Cartesian2D extends Vector2D.
Restore the public interface of Vector2DFormat to act on Vector2D.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/09c55eb8
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/09c55eb8
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/09c55eb8
Branch: refs/heads/feature-MATH-1284
Commit: 09c55eb8120da36aef1807628f87bde83749428b
Parents: 9be91f3
Author: Ray DeCampo <ra...@decampo.org>
Authored: Sat May 6 10:51:16 2017 -0400
Committer: Ray DeCampo <ra...@decampo.org>
Committed: Sat May 6 10:51:16 2017 -0400
----------------------------------------------------------------------
.../geometry/euclidean/twod/Cartesian2D.java | 2 +-
.../math4/geometry/euclidean/twod/Vector2D.java | 38 ++++++++++++++++++
.../geometry/euclidean/twod/Vector2DFormat.java | 10 ++---
.../twod/Vector2DFormatAbstractTest.java | 42 ++++++++++----------
4 files changed, 65 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/09c55eb8/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
index 51109d0..7e68362 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Cartesian2D.java
@@ -36,7 +36,7 @@ import org.apache.commons.math4.util.MathUtils;
* <p>Instances of this class are guaranteed to be immutable.</p>
* @since 4.0
*/
-public class Cartesian2D implements Point<Euclidean2D>, Vector<Euclidean2D> {
+public class Cartesian2D extends Vector2D implements Point<Euclidean2D> {
/** Origin (coordinates: 0, 0). */
public static final Cartesian2D ZERO = new Cartesian2D(0, 0);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/09c55eb8/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java
new file mode 100644
index 0000000..4a2a398
--- /dev/null
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2D.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.geometry.euclidean.twod;
+
+import org.apache.commons.math4.geometry.Vector;
+
+/** This class represents a 2D vector.
+ * @since 3.0
+ */
+public abstract class Vector2D implements Vector<Euclidean2D> {
+
+ /** Get the abscissa of the vector.
+ * @return abscissa of the vector
+ * @see #Vector2D(double, double)
+ */
+ public abstract double getX();
+
+ /** Get the ordinate of the vector.
+ * @return ordinate of the vector
+ * @see #Vector2D(double, double)
+ */
+ public abstract double getY();
+
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/09c55eb8/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
index 936450a..cb76596 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
@@ -108,26 +108,26 @@ public class Vector2DFormat extends VectorFormat<Euclidean2D> {
@Override
public StringBuffer format(final Vector<Euclidean2D> vector, final StringBuffer toAppendTo,
final FieldPosition pos) {
- final Cartesian2D p2 = (Cartesian2D) vector;
+ final Vector2D p2 = (Vector2D) vector;
return format(toAppendTo, pos, p2.getX(), p2.getY());
}
/** {@inheritDoc} */
@Override
- public Cartesian2D parse(final String source) throws MathParseException {
+ public Vector2D parse(final String source) throws MathParseException {
ParsePosition parsePosition = new ParsePosition(0);
- Cartesian2D result = parse(source, parsePosition);
+ Vector2D result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw new MathParseException(source,
parsePosition.getErrorIndex(),
- Cartesian2D.class);
+ Vector2D.class);
}
return result;
}
/** {@inheritDoc} */
@Override
- public Cartesian2D parse(final String source, final ParsePosition pos) {
+ public Vector2D parse(final String source, final ParsePosition pos) {
final double[] coordinates = parseCoordinates(2, source, pos);
if (coordinates == null) {
return null;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/09c55eb8/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java
index 11f518a..93d3421 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java
@@ -157,8 +157,8 @@ public abstract class Vector2DFormatAbstractTest {
@Test
public void testParseSimpleNoDecimals() throws MathParseException {
String source = "{1; 1}";
- Cartesian2D expected = new Cartesian2D(1, 1);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(1, 1);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -181,8 +181,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"23; 1" + getDecimalCharacter() +
"43}";
- Cartesian2D expected = new Cartesian2D(1.23, 1.43);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(1.23, 1.43);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -192,8 +192,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"2323; 1" + getDecimalCharacter() +
"4343}";
- Cartesian2D expected = new Cartesian2D(1.2323, 1.4343);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(1.2323, 1.4343);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -203,8 +203,8 @@ public abstract class Vector2DFormatAbstractTest {
"{-1" + getDecimalCharacter() +
"2323; 1" + getDecimalCharacter() +
"4343}";
- Cartesian2D expected = new Cartesian2D(-1.2323, 1.4343);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(-1.2323, 1.4343);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -214,8 +214,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"2323; -1" + getDecimalCharacter() +
"4343}";
- Cartesian2D expected = new Cartesian2D(1.2323, -1.4343);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(1.2323, -1.4343);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -225,8 +225,8 @@ public abstract class Vector2DFormatAbstractTest {
"{1" + getDecimalCharacter() +
"2323; 1" + getDecimalCharacter() +
"4343}";
- Cartesian2D expected = new Cartesian2D(1.2323, 1.4343);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(1.2323, 1.4343);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -236,8 +236,8 @@ public abstract class Vector2DFormatAbstractTest {
"{-1" + getDecimalCharacter() +
"2323; -1" + getDecimalCharacter() +
"4343}";
- Cartesian2D expected = new Cartesian2D(-1.2323, -1.4343);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(-1.2323, -1.4343);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -247,8 +247,8 @@ public abstract class Vector2DFormatAbstractTest {
"{0" + getDecimalCharacter() +
"0; -1" + getDecimalCharacter() +
"4343}";
- Cartesian2D expected = new Cartesian2D(0.0, -1.4343);
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D expected = new Cartesian2D(0.0, -1.4343);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -258,29 +258,29 @@ public abstract class Vector2DFormatAbstractTest {
"[1" + getDecimalCharacter() +
"2323 : 1" + getDecimalCharacter() +
"4343]";
- Cartesian2D expected = new Cartesian2D(1.2323, 1.4343);
- Cartesian2D actual = vector2DFormatSquare.parse(source);
+ Vector2D expected = new Cartesian2D(1.2323, 1.4343);
+ Vector2D actual = vector2DFormatSquare.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseNan() throws MathParseException {
String source = "{(NaN); (NaN)}";
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(Cartesian2D.NaN, actual);
}
@Test
public void testParsePositiveInfinity() throws MathParseException {
String source = "{(Infinity); (Infinity)}";
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(Cartesian2D.POSITIVE_INFINITY, actual);
}
@Test
public void testParseNegativeInfinity() throws MathParseException {
String source = "{(-Infinity); (-Infinity)}";
- Cartesian2D actual = vector2DFormat.parse(source);
+ Vector2D actual = vector2DFormat.parse(source);
Assert.assertEquals(Cartesian2D.NEGATIVE_INFINITY, actual);
}