Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E89BD200C72 for ; Fri, 12 May 2017 23:32:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E74E6160BCB; Fri, 12 May 2017 21:32:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 427D6160BB8 for ; Fri, 12 May 2017 23:32:11 +0200 (CEST) Received: (qmail 16474 invoked by uid 500); 12 May 2017 21:32:10 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 16458 invoked by uid 99); 12 May 2017 21:32:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 May 2017 21:32:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2FE54E038B; Fri, 12 May 2017 21:32:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: raydecampo@apache.org To: commits@commons.apache.org Date: Fri, 12 May 2017 21:32:10 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/31] [math] MATH-1284: Vector no longer extends Point. Replace/rename Vector?D classes with Coordinate?D classes which implement both Vector and Point. When there are multiple implementations of the same method which would confuse the compiler, prefer archived-at: Fri, 12 May 2017 21:32:13 -0000 Repository: commons-math Updated Branches: refs/heads/master bf9158489 -> 7a59c0af2 http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 92ca21a..22fb232 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.Vector3D; +import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; 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) { - Vector3D v = new Vector3D(random.nextVector()); + Coordinates3D v = new Coordinates3D(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) { - Vector3D v = new Vector3D(random.nextVector()); + Coordinates3D v = new Coordinates3D(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(Vector3D.MINUS_K, tol); + SphericalPolygonsSet south = new SphericalPolygonsSet(Coordinates3D.MINUS_K, tol); UnitSphereRandomVectorGenerator random = new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A, 0x6b9d4a6ad90d7b0bl)); for (int i = 0; i < 1000; ++i) { - Vector3D v = new Vector3D(random.nextVector()); + Coordinates3D v = new Coordinates3D(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 factory = new RegionFactory<>(); - SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); - SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); - SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); + 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 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) { - Vector3D v = new Vector3D(random.nextVector()); + Coordinates3D v = new Coordinates3D(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(Vector3D.PLUS_I) < 1.0e-10; - yPFound = yPFound || e.getCircle().getPole().distance(Vector3D.PLUS_J) < 1.0e-10; - zPFound = zPFound || e.getCircle().getPole().distance(Vector3D.PLUS_K) < 1.0e-10; + 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; Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10); - xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_I) < 1.0e-10; - yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10; - zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) < 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; } 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 Vector3D(1, 1, 1))), + ((S2Point) octant.getBarycenter()).distance(new S2Point(new Coordinates3D(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 reversedCap = ((SphericalPolygonsSet) factory.getComplement(octant)).getEnclosingCap(); - Assert.assertEquals(0, reversedCap.getCenter().distance(new S2Point(new Vector3D(-1, -1, -1))), 1.0e-10); + Assert.assertEquals(0, reversedCap.getCenter().distance(new S2Point(new Coordinates3D(-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) { - Vector3D v = new Vector3D(random.nextVector()); + Coordinates3D v = new Coordinates3D(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 factory = new RegionFactory<>(); - SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); - SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); - SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); + 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 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) { - Vector3D v = new Vector3D(random.nextVector()); + Coordinates3D v = new Coordinates3D(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(Vector3D.MINUS_I) < 1.0e-10) { + if (e.getCircle().getPole().distance(Coordinates3D.MINUS_I) < 1.0e-10) { xPFound = true; sumPoleX += e.getLength(); - } else if (e.getCircle().getPole().distance(Vector3D.MINUS_J) < 1.0e-10) { + } else if (e.getCircle().getPole().distance(Coordinates3D.MINUS_J) < 1.0e-10) { yPFound = true; sumPoleY += e.getLength(); } else { - Assert.assertEquals(0.0, e.getCircle().getPole().distance(Vector3D.PLUS_K), 1.0e-10); + Assert.assertEquals(0.0, e.getCircle().getPole().distance(Coordinates3D.PLUS_K), 1.0e-10); zPFound = true; sumPoleZ += e.getLength(); } - xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_I) < 1.0e-10; - yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10; - zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) < 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; } Assert.assertTrue(xPFound); Assert.assertTrue(yPFound); @@ -274,22 +274,22 @@ public class SphericalPolygonsSetTest { public void testModeratlyComplexShape() { double tol = 0.01; List> boundary = new ArrayList<>(); - boundary.add(create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.MINUS_I, Vector3D.PLUS_K, Vector3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.MINUS_I, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.MINUS_J, Vector3D.MINUS_I, Vector3D.MINUS_K, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.MINUS_I, Vector3D.MINUS_K, Vector3D.MINUS_J, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.PLUS_K, Vector3D.MINUS_J, Vector3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI)); + 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)); SphericalPolygonsSet polygon = new SphericalPolygonsSet(boundary, tol); - Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D( 1, 1, 1).normalize()))); - Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, 1, 1).normalize()))); - Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, -1, 1).normalize()))); - Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D( 1, -1, 1).normalize()))); - Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D( 1, 1, -1).normalize()))); - Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, 1, -1).normalize()))); - Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, -1, -1).normalize()))); - Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D( 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.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(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(Vector3D.PLUS_I) < 1.0e-10; - mXFound = mXFound || v.getLocation().getVector().distance(Vector3D.MINUS_I) < 1.0e-10; - pYFound = pYFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10; - mYFound = mYFound || v.getLocation().getVector().distance(Vector3D.MINUS_J) < 1.0e-10; - pZFound = pZFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) < 1.0e-10; - mZFound = mZFound || v.getLocation().getVector().distance(Vector3D.MINUS_K) < 1.0e-10; + 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; Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10); } Assert.assertTrue(pXFound); @@ -333,14 +333,14 @@ public class SphericalPolygonsSetTest { List> boundary = new ArrayList<>(); // first part: +X, +Y, +Z octant - boundary.add(create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K, tol, 0.0, 0.5 * FastMath.PI)); + 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)); // first part: -X, -Y, -Z octant - boundary.add(create(Vector3D.MINUS_J, Vector3D.MINUS_I, Vector3D.MINUS_K, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.MINUS_I, Vector3D.MINUS_K, Vector3D.MINUS_J, tol, 0.0, 0.5 * FastMath.PI)); - boundary.add(create(Vector3D.MINUS_K, Vector3D.MINUS_J, Vector3D.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.MINUS_K, Coordinates3D.MINUS_J, Coordinates3D.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) { - Vector3D v = new Vector3D(random.nextVector()); + Coordinates3D v = new Coordinates3D(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 Vector3D(1, 1, 1)); - SphericalPolygonsSet hexa = new SphericalPolygonsSet(center.getVector(), Vector3D.PLUS_K, alpha, 6, tol); + S2Point center = new S2Point(new Coordinates3D(1, 1, 1)); + SphericalPolygonsSet hexa = new SphericalPolygonsSet(center.getVector(), Coordinates3D.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; - Vector3D center = new Vector3D(1, 1, 1); - SphericalPolygonsSet hexaOut = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.9, 6, tol); - SphericalPolygonsSet hexaIn = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.8, 6, tol); - SphericalPolygonsSet pentaOut = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.7, 5, tol); - SphericalPolygonsSet pentaIn = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.6, 5, tol); - SphericalPolygonsSet quadriOut = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.5, 4, tol); - SphericalPolygonsSet quadriIn = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.4, 4, tol); - SphericalPolygonsSet triOut = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.25, 3, tol); - SphericalPolygonsSet triIn = new SphericalPolygonsSet(center, Vector3D.PLUS_K, 0.15, 3, tol); + 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); RegionFactory factory = new RegionFactory<>(); SphericalPolygonsSet hexa = (SphericalPolygonsSet) factory.difference(hexaOut, hexaIn); @@ -477,7 +477,7 @@ public class SphericalPolygonsSetTest { RegionFactory factory = new RegionFactory<>(); SphericalPolygonsSet zone = (SphericalPolygonsSet) factory.union(continental, corsica); EnclosingBall enclosing = zone.getEnclosingCap(); - Vector3D enclosingCenter = ((S2Point) enclosing.getCenter()).getVector(); + Coordinates3D 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) { - Vector3D p = v.getOutgoing().getPointAt(i * step); - Assert.assertTrue(Vector3D.angle(p, enclosingCenter) <= enclosing.getRadius()); + Coordinates3D p = v.getOutgoing().getPointAt(i * step); + Assert.assertTrue(Coordinates3D.angle(p, enclosingCenter) <= enclosing.getRadius()); } } } @@ -500,37 +500,37 @@ public class SphericalPolygonsSetTest { EnclosingBall continentalInscribed = ((SphericalPolygonsSet) factory.getComplement(continental)).getEnclosingCap(); - Vector3D continentalCenter = ((S2Point) continentalInscribed.getCenter()).getVector(); + Coordinates3D 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) { - Vector3D p = v.getOutgoing().getPointAt(i * step); - Assert.assertTrue(Vector3D.angle(p, continentalCenter) <= continentalInscribed.getRadius()); + Coordinates3D p = v.getOutgoing().getPointAt(i * step); + Assert.assertTrue(Coordinates3D.angle(p, continentalCenter) <= continentalInscribed.getRadius()); } } } EnclosingBall corsicaInscribed = ((SphericalPolygonsSet) factory.getComplement(corsica)).getEnclosingCap(); - Vector3D corsicaCenter = ((S2Point) corsicaInscribed.getCenter()).getVector(); + Coordinates3D 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) { - Vector3D p = v.getOutgoing().getPointAt(i * step); - Assert.assertTrue(Vector3D.angle(p, corsicaCenter) <= corsicaInscribed.getRadius()); + Coordinates3D p = v.getOutgoing().getPointAt(i * step); + Assert.assertTrue(Coordinates3D.angle(p, corsicaCenter) <= corsicaInscribed.getRadius()); } } } } - private SubCircle create(Vector3D pole, Vector3D x, Vector3D y, + private SubCircle create(Coordinates3D pole, Coordinates3D x, Coordinates3D y, double tolerance, double ... limits) { RegionFactory factory = new RegionFactory<>(); Circle circle = new Circle(pole, tolerance); http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 34b6278..4404f60 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.Vector3D; +import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; 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(Vector3D.PLUS_K, 1.0e-10); + Circle circle = new Circle(Coordinates3D.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(Vector3D.PLUS_J, 1.0e-10); + Circle xzPlane = new Circle(Coordinates3D.PLUS_J, 1.0e-10); - SubCircle sc1 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); + SubCircle sc1 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); Assert.assertEquals(Side.BOTH, sc1.split(xzPlane).getSide()); - SubCircle sc2 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0); + SubCircle sc2 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0); Assert.assertEquals(Side.MINUS, sc2.split(xzPlane).getSide()); - SubCircle sc3 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 5.0, 6.0); + SubCircle sc3 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.PLUS, sc3.split(xzPlane).getSide()); - SubCircle sc4 = create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, 1.0e-10, 5.0, 6.0); + SubCircle sc4 = create(Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.HYPER, sc4.split(xzPlane).getSide()); - SubCircle sc5 = create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, 1.0e-10, 5.0, 6.0); + SubCircle sc5 = create(Coordinates3D.MINUS_J, Coordinates3D.PLUS_I, Coordinates3D.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(Vector3D.PLUS_J, 1.0e-10); + Circle xzPlane = new Circle(Coordinates3D.PLUS_J, 1.0e-10); - SubCircle sc1 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); + SubCircle sc1 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); SplitSubHyperplane 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(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0); + SubCircle sc2 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 1.0, 3.0); SplitSubHyperplane 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(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 5.0, 6.0); + SubCircle sc3 = create(Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, Coordinates3D.PLUS_J, 1.0e-10, 5.0, 6.0); SplitSubHyperplane 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(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, 1.0e-10, 5.0, 6.0); + SubCircle sc4 = create(Coordinates3D.PLUS_J, Coordinates3D.PLUS_K, Coordinates3D.PLUS_I, 1.0e-10, 5.0, 6.0); SplitSubHyperplane split4 = sc4.split(xzPlane); Assert.assertEquals(Side.HYPER, sc4.split(xzPlane).getSide()); Assert.assertNull(split4.getPlus()); Assert.assertNull(split4.getMinus()); - SubCircle sc5 = create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, 1.0e-10, 5.0, 6.0); + SubCircle sc5 = create(Coordinates3D.MINUS_J, Coordinates3D.PLUS_I, Coordinates3D.PLUS_K, 1.0e-10, 5.0, 6.0); SplitSubHyperplane 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 Vector3D(9.738804529764676E-5, -0.6772824575010357, -0.7357230887208355), + Circle hyperplane = new Circle(new Coordinates3D(9.738804529764676E-5, -0.6772824575010357, -0.7357230887208355), tolerance); - SubCircle sub = new SubCircle(new Circle(new Vector3D(2.1793884139073498E-4, 0.9790647032675541, -0.20354915700704285), + SubCircle sub = new SubCircle(new Circle(new Coordinates3D(2.1793884139073498E-4, 0.9790647032675541, -0.20354915700704285), tolerance), new ArcsSet(4.7121441684170700, 4.7125386635004760, tolerance)); SplitSubHyperplane split = sub.split(hyperplane); @@ -125,7 +125,7 @@ public class SubCircleTest { } - private SubCircle create(Vector3D pole, Vector3D x, Vector3D y, + private SubCircle create(Coordinates3D pole, Coordinates3D x, Coordinates3D y, double tolerance, double ... limits) { RegionFactory factory = new RegionFactory<>(); Circle circle = new Circle(pole, tolerance); http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 0a7090c..e52fa34 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.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; 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) - Vector2D center = new Vector2D(o.getPointRef()[0], o.getPointRef()[1]); + Coordinates2D center = new Coordinates2D(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/b815d2af/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 5e5e90a..beb3532 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.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; 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 points; + private ArrayList points; public CircleScalar() { points = new ArrayList<>(); } public void addPoint(double px, double py) { - points.add(new Vector2D(px, py)); + points.add(new Coordinates2D(px, py)); } - public double getRadius(Vector2D center) { + public double getRadius(Coordinates2D center) { double r = 0; - for (Vector2D point : points) { + for (Coordinates2D 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) { - Vector2D center = new Vector2D(params[0], params[1]); + Coordinates2D center = new Coordinates2D(params[0], params[1]); double radius = getRadius(center); double sum = 0; - for (Vector2D point : points) { + for (Coordinates2D 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) { - Vector2D center = new Vector2D(params[0], params[1]); + Coordinates2D center = new Coordinates2D(params[0], params[1]); double radius = getRadius(center); // gradient of the sum of squared residuals double dJdX = 0; double dJdY = 0; - for (Vector2D pk : points) { + for (Coordinates2D 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/b815d2af/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 12b2897..54a827e 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.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; 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 })); - Vector2D center = new Vector2D(optimum.getPointRef()[0], optimum.getPointRef()[1]); + Coordinates2D center = new Coordinates2D(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);