This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit 45bffa7314331f787865dd3ef126424e156d8148 Author: Matt Juntunen <[email protected]> AuthorDate: Sun Sep 9 15:00:56 2018 -0400 GEOMETRY-9: removing Point?D/Vector?D static convenience methods to clean up API, per pull request discussion --- .../commons/geometry/euclidean/oned/Point1D.java | 12 -- .../commons/geometry/euclidean/oned/Vector1D.java | 12 -- .../commons/geometry/euclidean/threed/Point3D.java | 12 -- .../geometry/euclidean/threed/Vector3D.java | 67 --------- .../commons/geometry/euclidean/twod/Point2D.java | 12 -- .../commons/geometry/euclidean/twod/Vector2D.java | 56 -------- .../geometry/euclidean/oned/Point1DTest.java | 26 ---- .../geometry/euclidean/oned/Vector1DTest.java | 26 ---- .../geometry/euclidean/threed/Point3DTest.java | 26 ---- .../geometry/euclidean/threed/Vector3DTest.java | 152 --------------------- .../geometry/euclidean/twod/Point2DTest.java | 26 ---- .../geometry/euclidean/twod/Vector2DTest.java | 119 ---------------- .../geometry/spherical/twod/EdgesBuilder.java | 4 +- .../spherical/twod/PropertiesComputer.java | 4 +- .../spherical/twod/SphericalPolygonsSet.java | 4 +- .../commons/geometry/spherical/twod/SubCircle.java | 3 +- .../geometry/spherical/twod/CircleTest.java | 32 ++--- .../spherical/twod/SphericalPolygonsSetTest.java | 6 +- 18 files changed, 25 insertions(+), 574 deletions(-) diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java index 800f157..eec4b79 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java @@ -161,18 +161,6 @@ public final class Point1D extends Cartesian1D implements EuclideanPoint<Point1D return SimpleTupleFormat.getDefault().parse(str, Point1D::new); } - /** Linearly interpolates between the two given points. This methods simply - * calls {@code a.lerp(b, t)}. - * @param a first point - * @param b second point - * @param t interpolation parameter - * @return the interpolated point - * @see #lerp(Point1D, double) - */ - public static Point1D lerp(Point1D a, Point1D b, double t) { - return a.lerp(b, t); - } - /** Returns a point with coordinates calculated by multiplying each input coordinate * with its corresponding factor and adding the results. * diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java index 57f85b5..df40670 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java @@ -313,18 +313,6 @@ public final class Vector1D extends Cartesian1D implements EuclideanVector<Point return SimpleTupleFormat.getDefault().parse(str, Vector1D::new); } - /** Linearly interpolates between the two given vectors. This methods simply - * calls {@code a.lerp(b, t)}. - * @param a first vector - * @param b second vector - * @param t interpolation parameter - * @return the interpolated vector - * @see #lerp(Vector1D, double) - */ - public static Vector1D lerp(Vector1D a, Vector1D b, double t) { - return a.lerp(b, t); - } - /** Returns a vector consisting of the linear combination of the inputs. * <p> * A linear combination is the sum of all of the inputs multiplied by their diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java index a930ba0..8e15230 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java @@ -196,18 +196,6 @@ public final class Point3D extends Cartesian3D implements EuclideanPoint<Point3D return SimpleTupleFormat.getDefault().parse(str, Point3D::new); } - /** Linearly interpolates between the two given points. This methods simply - * calls {@code a.lerp(b, t)}. - * @param a first point - * @param b second point - * @param t interpolation parameter - * @return the interpolated point - * @see #lerp(Point3D, double) - */ - public static Point3D lerp(Point3D a, Point3D b, double t) { - return a.lerp(b, t); - } - /** Returns a point with coordinates calculated by multiplying each input coordinate * with its corresponding factor and adding the results. * diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java index 61644ef..fd52558 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java @@ -427,61 +427,6 @@ public final class Vector3D extends Cartesian3D implements EuclideanVector<Point return new Vector3D(projX, projY, projZ); } - /** Computes the dot product between to vectors. This method simply - * calls {@code v1.dotProduct(v2)}. - * @param v1 first vector - * @param v2 second vector - * @return the dot product - * @see #dotProduct(Vector3D) - */ - public static double dotProduct(Vector3D v1, Vector3D v2) { - return v1.dotProduct(v2); - } - - /** Computes the angle in radians between two vectors. This method - * simply calls {@code v1.angle(v2)}. - * @param v1 first vector - * @param v2 second vector - * @return the angle between the vectors in radians - * @see #angle(Vector3D) - */ - public static double angle(Vector3D v1, Vector3D v2) { - return v1.angle(v2); - } - - /** Projects the given vector onto {@code base}. This method simply - * calls {@code v.project(base)}. - * @param v vector to project - * @param base the base vector to project onto - * @return the projected vector - * @see #project(Vector3D) - */ - public static Vector3D project(Vector3D v, Vector3D base) { - return v.project(base); - } - - /** Returns the vector rejection of {@code v} from {@code base}. This - * method simply calls {@code v.reject(base)}. - * @param v vector to reject - * @param base the base vector to reject from - * @return the vector rejection - * @see #reject(Vector3D) - */ - public static Vector3D reject(Vector3D v, Vector3D base) { - return v.reject(base); - } - - /** Computes the cross product between two vectors. This method simply - * calls {@code v1.crossProduct(v2)}. - * @param v1 first vector - * @param v2 second vector - * @return the computed cross product vector - * @see #crossProduct(Vector3D) - */ - public static Vector3D crossProduct(Vector3D v1, Vector3D v2) { - return v1.crossProduct(v2); - } - /** Returns a vector with the given coordinate values. * @param x abscissa (first coordinate value) * @param y abscissa (second coordinate value) @@ -525,18 +470,6 @@ public final class Vector3D extends Cartesian3D implements EuclideanVector<Point return SimpleTupleFormat.getDefault().parse(str, Vector3D::new); } - /** Linearly interpolates between the two given vectors. This methods simply - * calls {@code a.lerp(b, t)}. - * @param a first vector - * @param b second vector - * @param t interpolation parameter - * @return the interpolated vector - * @see #lerp(Vector3D, double) - */ - public static Vector3D lerp(Vector3D a, Vector3D b, double t) { - return a.lerp(b, t); - } - /** Returns a vector consisting of the linear combination of the inputs. * <p> * A linear combination is the sum of all of the inputs multiplied by their diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java index 3600689..e7a89cb 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java @@ -179,18 +179,6 @@ public final class Point2D extends Cartesian2D implements EuclideanPoint<Point2D return SimpleTupleFormat.getDefault().parse(str, Point2D::new); } - /** Linearly interpolates between the two given points. This methods simply - * calls {@code a.lerp(b, t)}. - * @param a first point - * @param b second point - * @param t interpolation parameter - * @return the interpolated point - * @see #lerp(Point2D, double) - */ - public static Point2D lerp(Point2D a, Point2D b, double t) { - return a.lerp(b, t); - } - /** Returns a point with coordinates calculated by multiplying each input coordinate * with its corresponding factor and adding the results. * diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java index 946d01b..fec9764 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java @@ -372,50 +372,6 @@ public final class Vector2D extends Cartesian2D implements EuclideanVector<Point return new Vector2D(projX, projY); } - /** Computes the dot product between to vectors. This method simply - * calls {@code v1.dotProduct(v2)}. - * @param v1 first vector - * @param v2 second vector - * @return the dot product - * @see #dotProduct(Vector2D) - */ - public static double dotProduct(Vector2D v1, Vector2D v2) { - return v1.dotProduct(v2); - } - - /** Projects the given vector onto {@code base}. This method simply - * calls {@code v.project(base)}. - * @param v vector to project - * @param base the base vector to project onto - * @return the projected vector - * @see #project(Vector2D) - */ - public static Vector2D project(Vector2D v, Vector2D base) { - return v.project(base); - } - - /** Returns the vector rejection of {@code v} from {@code base}. This - * method simply calls {@code v.reject(base)}. - * @param v vector to reject - * @param base the base vector to reject from - * @return the vector rejection - * @see #reject(Vector2D) - */ - public static Vector2D reject(Vector2D v, Vector2D base) { - return v.reject(base); - } - - /** Computes the angle in radians between two vectors. This method - * simply calls {@code v1.angle(v2)}. - * @param v1 first vector - * @param v2 second vector - * @return the angle between the vectors in radians - * @see #angle(Vector2D) - */ - public static double angle(Vector2D v1, Vector2D v2) { - return v1.angle(v2); - } - /** Returns a vector with the given coordinate values. * @param x abscissa (first coordinate value) * @param y abscissa (second coordinate value) @@ -456,18 +412,6 @@ public final class Vector2D extends Cartesian2D implements EuclideanVector<Point return SimpleTupleFormat.getDefault().parse(str, Vector2D::new); } - /** Linearly interpolates between the two given vectors. This methods simply - * calls {@code a.lerp(b, t)}. - * @param a first vector - * @param b second vector - * @param t interpolation parameter - * @return the interpolated vector - * @see #lerp(Vector2D, double) - */ - public static Vector2D lerp(Vector2D a, Vector2D b, double t) { - return a.lerp(b, t); - } - /** Returns a vector consisting of the linear combination of the inputs. * <p> * A linear combination is the sum of all of the inputs multiplied by their diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java index e9379b1..25b2fe6 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java @@ -144,32 +144,6 @@ public class Point1DTest { } @Test - public void testLerp_static() { - // arrange - Point1D p1 = Point1D.of(1); - Point1D p2 = Point1D.of(-4); - Point1D p3 = Point1D.of(10); - - // act/assert - checkPoint(Point1D.lerp(p1, p1, 0), 1); - checkPoint(Point1D.lerp(p1, p1, 1), 1); - - checkPoint(Point1D.lerp(p1, p2, -0.25), 2.25); - checkPoint(Point1D.lerp(p1, p2, 0), 1); - checkPoint(Point1D.lerp(p1, p2, 0.25), -0.25); - checkPoint(Point1D.lerp(p1, p2, 0.5), -1.5); - checkPoint(Point1D.lerp(p1, p2, 0.75), -2.75); - checkPoint(Point1D.lerp(p1, p2, 1), -4); - checkPoint(Point1D.lerp(p1, p2, 1.25), -5.25); - - checkPoint(Point1D.lerp(p1, p3, 0), 1); - checkPoint(Point1D.lerp(p1, p3, 0.25), 3.25); - checkPoint(Point1D.lerp(p1, p3, 0.5), 5.5); - checkPoint(Point1D.lerp(p1, p3, 0.75), 7.75); - checkPoint(Point1D.lerp(p1, p3, 1), 10); - } - - @Test public void testAdd() { // arrange Point1D p1 = Point1D.of(2.0); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java index 20396fe..e5b580a 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java @@ -415,32 +415,6 @@ public class Vector1DTest { } @Test - public void testLerp_static() { - // arrange - Vector1D v1 = Vector1D.of(1); - Vector1D v2 = Vector1D.of(-4); - Vector1D v3 = Vector1D.of(10); - - // act/assert - checkVector(Vector1D.lerp(v1, v1, 0), 1); - checkVector(Vector1D.lerp(v1, v1, 1), 1); - - checkVector(Vector1D.lerp(v1, v2, -0.25), 2.25); - checkVector(Vector1D.lerp(v1, v2, 0), 1); - checkVector(Vector1D.lerp(v1, v2, 0.25), -0.25); - checkVector(Vector1D.lerp(v1, v2, 0.5), -1.5); - checkVector(Vector1D.lerp(v1, v2, 0.75), -2.75); - checkVector(Vector1D.lerp(v1, v2, 1), -4); - checkVector(Vector1D.lerp(v1, v2, 1.25), -5.25); - - checkVector(Vector1D.lerp(v1, v3, 0), 1); - checkVector(Vector1D.lerp(v1, v3, 0.25), 3.25); - checkVector(Vector1D.lerp(v1, v3, 0.5), 5.5); - checkVector(Vector1D.lerp(v1, v3, 0.75), 7.75); - checkVector(Vector1D.lerp(v1, v3, 1), 10); - } - - @Test public void testHashCode() { // arrange Vector1D u = Vector1D.of(1); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Point3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Point3DTest.java index df54e58..3e312dd 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Point3DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Point3DTest.java @@ -129,32 +129,6 @@ public class Point3DTest { } @Test - public void testLerp_static() { - // arrange - Point3D p1 = Point3D.of(1, -5, 2); - Point3D p2 = Point3D.of(-4, 0, 2); - Point3D p3 = Point3D.of(10, -4, 0); - - // act/assert - checkPoint(Point3D.lerp(p1, p1, 0), 1, -5, 2); - checkPoint(Point3D.lerp(p1, p1, 1), 1, -5, 2); - - checkPoint(Point3D.lerp(p1, p2, -0.25), 2.25, -6.25, 2); - checkPoint(Point3D.lerp(p1, p2, 0), 1, -5, 2); - checkPoint(Point3D.lerp(p1, p2, 0.25), -0.25, -3.75, 2); - checkPoint(Point3D.lerp(p1, p2, 0.5), -1.5, -2.5, 2); - checkPoint(Point3D.lerp(p1, p2, 0.75), -2.75, -1.25, 2); - checkPoint(Point3D.lerp(p1, p2, 1), -4, 0, 2); - checkPoint(Point3D.lerp(p1, p2, 1.25), -5.25, 1.25, 2); - - checkPoint(Point3D.lerp(p1, p3, 0), 1, -5, 2); - checkPoint(Point3D.lerp(p1, p3, 0.25), 3.25, -4.75, 1.5); - checkPoint(Point3D.lerp(p1, p3, 0.5), 5.5, -4.5, 1); - checkPoint(Point3D.lerp(p1, p3, 0.75), 7.75, -4.25, 0.5); - checkPoint(Point3D.lerp(p1, p3, 1), 10, -4, 0); - } - - @Test public void testAdd() { // act/assert Point3D p1 = Point3D.of(1, 2, 3); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java index 4880438..3aa2dd7 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java @@ -316,28 +316,6 @@ public class Vector3DTest { // act/assert Assert.assertTrue(Math.abs(v1.angle(v2) - 1.2) < 1.0e-12); - } - - @Test - public void testAngle_static() { - // arrange - double tolerance = 1e-10; - - Vector3D v1 = Vector3D.of(1, 2, 3); - Vector3D v2 = Vector3D.of(4, 5, 6); - - // act/assert - Assert.assertEquals(0.22572612855273393616, Vector3D.angle(v1, v2), tolerance); - Assert.assertEquals(7.98595620686106654517199e-8, Vector3D.angle(v1, Vector3D.of(2, 4, 6.000001)), tolerance); - Assert.assertEquals(3.14159257373023116985197793156, Vector3D.angle(v1, Vector3D.of(-2, -4, -6.000001)), tolerance); - - Assert.assertEquals(0.0, Vector3D.angle(Vector3D.PLUS_X, Vector3D.PLUS_X), tolerance); - Assert.assertEquals(Geometry.PI, Vector3D.angle(Vector3D.PLUS_X, Vector3D.MINUS_X), tolerance); - - Assert.assertEquals(Geometry.HALF_PI, Vector3D.angle(Vector3D.PLUS_X, Vector3D.PLUS_Y), tolerance); - Assert.assertEquals(Geometry.HALF_PI, Vector3D.angle(Vector3D.PLUS_X, Vector3D.MINUS_Y), tolerance); - Assert.assertEquals(Geometry.HALF_PI, Vector3D.angle(Vector3D.PLUS_X, Vector3D.PLUS_Z), tolerance); - Assert.assertEquals(Geometry.HALF_PI, Vector3D.angle(Vector3D.PLUS_X, Vector3D.MINUS_Z), tolerance); } @Test @@ -422,21 +400,6 @@ public class Vector3DTest { } @Test - public void testCrossProduct_static() { - // act/assert - checkVector(Vector3D.crossProduct(Vector3D.PLUS_X, Vector3D.PLUS_Y), 0, 0, 1); - checkVector(Vector3D.crossProduct(Vector3D.PLUS_X, Vector3D.MINUS_Y), 0, 0, -1); - - checkVector(Vector3D.crossProduct(Vector3D.MINUS_X, Vector3D.MINUS_Y), 0, 0, 1); - checkVector(Vector3D.crossProduct(Vector3D.MINUS_X, Vector3D.PLUS_Y), 0, 0, -1); - - checkVector(Vector3D.crossProduct(Vector3D.of(2, 1, -4), Vector3D.of(3, 1, -1)), 3, -10, -1); - - double invSqrt6 = 1 / Math.sqrt(6); - checkVector(Vector3D.crossProduct(Vector3D.of(1, 1, 1), Vector3D.of(-1, 0, 1)).normalize(), invSqrt6, - 2 * invSqrt6, invSqrt6); - } - - @Test public void testScalarMultiply() { // arrange Vector3D v1 = Vector3D.of(2, 3, 4); @@ -600,23 +563,6 @@ public class Vector3DTest { } @Test - public void testDotProduct_static() { - // arrange - Vector3D v1 = Vector3D.of(1, -2, 3); - Vector3D v2 = Vector3D.of(-4, 5, -6); - Vector3D v3 = Vector3D.of(7, 8, 9); - - // act/assert - Assert.assertEquals(14, Vector3D.dotProduct(v1, v1), EPS); - - Assert.assertEquals(-32, Vector3D.dotProduct(v1, v2), EPS); - Assert.assertEquals(-32, Vector3D.dotProduct(v2, v1), EPS); - - Assert.assertEquals(18, Vector3D.dotProduct(v1, v3), EPS); - Assert.assertEquals(18, Vector3D.dotProduct(v3, v1), EPS); - } - - @Test public void testProject() { // arrange Vector3D v1 = Vector3D.of(2.0, 3.0, 4.0); @@ -653,42 +599,6 @@ public class Vector3DTest { } @Test - public void testProject_static() { - // arrange - Vector3D v1 = Vector3D.of(2.0, 3.0, 4.0); - Vector3D v2 = Vector3D.of(-5.0, -6.0, -7.0); - - // act/assert - checkVector(Vector3D.project(Vector3D.ZERO, Vector3D.PLUS_X), 0.0, 0.0, 0.0); - - checkVector(Vector3D.project(v1, Vector3D.PLUS_X), 2.0, 0.0, 0.0); - checkVector(Vector3D.project(v1, Vector3D.MINUS_X), 2.0, 0.0, 0.0); - checkVector(Vector3D.project(v1, Vector3D.PLUS_Y), 0.0, 3.0, 0.0); - checkVector(Vector3D.project(v1, Vector3D.MINUS_Y), 0.0, 3.0, 0.0); - checkVector(Vector3D.project(v1, Vector3D.PLUS_Z), 0.0, 0.0, 4.0); - checkVector(Vector3D.project(v1, Vector3D.MINUS_Z), 0.0, 0.0, 4.0); - - checkVector(Vector3D.project(v2, Vector3D.PLUS_X), -5.0, 0.0, 0.0); - checkVector(Vector3D.project(v2, Vector3D.MINUS_X), -5.0, 0.0, 0.0); - checkVector(Vector3D.project(v2, Vector3D.PLUS_Y), 0.0, -6.0, 0.0); - checkVector(Vector3D.project(v2, Vector3D.MINUS_Y), 0.0, -6.0, 0.0); - checkVector(Vector3D.project(v2, Vector3D.PLUS_Z), 0.0, 0.0, -7.0); - checkVector(Vector3D.project(v2, Vector3D.MINUS_Z), 0.0, 0.0, -7.0); - - checkVector(Vector3D.project(v1, Vector3D.of(1.0, 1.0, 1.0)), 3.0, 3.0, 3.0); - checkVector(Vector3D.project(v1, Vector3D.of(-1.0, -1.0, -1.0)), 3.0, 3.0, 3.0); - - checkVector(Vector3D.project(v2, Vector3D.of(1.0, 1.0, 1.0)), -6.0, -6.0, -6.0); - checkVector(Vector3D.project(v2, Vector3D.of(-1.0, -1.0, -1.0)), -6.0, -6.0, -6.0); - } - - @Test(expected = IllegalStateException.class) - public void testProject_baseHasZeroNorm_static() { - // act/assert - Vector3D.project(Vector3D.of(1.0, 1.0, 1.0), Vector3D.ZERO); - } - - @Test public void testReject() { // arrange Vector3D v1 = Vector3D.of(2.0, 3.0, 4.0); @@ -725,42 +635,6 @@ public class Vector3DTest { } @Test - public void testReject_static() { - // arrange - Vector3D v1 = Vector3D.of(2.0, 3.0, 4.0); - Vector3D v2 = Vector3D.of(-5.0, -6.0, -7.0); - - // act/assert - checkVector(Vector3D.reject(Vector3D.ZERO, Vector3D.PLUS_X), 0.0, 0.0, 0.0); - - checkVector(Vector3D.reject(v1, Vector3D.PLUS_X), 0.0, 3.0, 4.0); - checkVector(Vector3D.reject(v1, Vector3D.MINUS_X), 0.0, 3.0, 4.0); - checkVector(Vector3D.reject(v1, Vector3D.PLUS_Y), 2.0, 0.0, 4.0); - checkVector(Vector3D.reject(v1, Vector3D.MINUS_Y), 2.0, 0.0, 4.0); - checkVector(Vector3D.reject(v1, Vector3D.PLUS_Z), 2.0, 3.0, 0.0); - checkVector(Vector3D.reject(v1, Vector3D.MINUS_Z), 2.0, 3.0, 0.0); - - checkVector(Vector3D.reject(v2, Vector3D.PLUS_X), 0.0, -6.0, -7.0); - checkVector(Vector3D.reject(v2, Vector3D.MINUS_X), 0.0, -6.0, -7.0); - checkVector(Vector3D.reject(v2, Vector3D.PLUS_Y), -5.0, 0.0, -7.0); - checkVector(Vector3D.reject(v2, Vector3D.MINUS_Y), -5.0, 0.0, -7.0); - checkVector(Vector3D.reject(v2, Vector3D.PLUS_Z), -5.0, -6.0, 0.0); - checkVector(Vector3D.reject(v2, Vector3D.MINUS_Z), -5.0, -6.0, 0.0); - - checkVector(Vector3D.reject(v1, Vector3D.of(1.0, 1.0, 1.0)), -1.0, 0.0, 1.0); - checkVector(Vector3D.reject(v1, Vector3D.of(-1.0, -1.0, -1.0)), -1.0, 0.0, 1.0); - - checkVector(Vector3D.reject(v2, Vector3D.of(1.0, 1.0, 1.0)), 1.0, 0.0, -1.0); - checkVector(Vector3D.reject(v2, Vector3D.of(-1.0, -1.0, -1.0)), 1.0, 0.0, -1.0); - } - - @Test(expected = IllegalStateException.class) - public void testReject_baseHasZeroNorm_static() { - // act/assert - Vector3D.reject(Vector3D.of(1.0, 1.0, 1.0), Vector3D.ZERO); - } - - @Test public void testProjectAndReject_areComplementary() { // arrange double eps = 1e-12; @@ -837,32 +711,6 @@ public class Vector3DTest { } @Test - public void testLerp_static() { - // arrange - Vector3D v1 = Vector3D.of(1, -5, 2); - Vector3D v2 = Vector3D.of(-4, 0, 2); - Vector3D v3 = Vector3D.of(10, -4, 0); - - // act/assert - checkVector(Vector3D.lerp(v1, v1, 0), 1, -5, 2); - checkVector(Vector3D.lerp(v1, v1, 1), 1, -5, 2); - - checkVector(Vector3D.lerp(v1, v2, -0.25), 2.25, -6.25, 2); - checkVector(Vector3D.lerp(v1, v2, 0), 1, -5, 2); - checkVector(Vector3D.lerp(v1, v2, 0.25), -0.25, -3.75, 2); - checkVector(Vector3D.lerp(v1, v2, 0.5), -1.5, -2.5, 2); - checkVector(Vector3D.lerp(v1, v2, 0.75), -2.75, -1.25, 2); - checkVector(Vector3D.lerp(v1, v2, 1), -4, 0, 2); - checkVector(Vector3D.lerp(v1, v2, 1.25), -5.25, 1.25, 2); - - checkVector(Vector3D.lerp(v1, v3, 0), 1, -5, 2); - checkVector(Vector3D.lerp(v1, v3, 0.25), 3.25, -4.75, 1.5); - checkVector(Vector3D.lerp(v1, v3, 0.5), 5.5, -4.5, 1); - checkVector(Vector3D.lerp(v1, v3, 0.75), 7.75, -4.25, 0.5); - checkVector(Vector3D.lerp(v1, v3, 1), 10, -4, 0); - } - - @Test public void testHashCode() { // arrange double delta = 10 * Precision.EPSILON; diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Point2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Point2DTest.java index 199abd2..d5903de 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Point2DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Point2DTest.java @@ -120,32 +120,6 @@ public class Point2DTest { } @Test - public void testLerp_static() { - // arrange - Point2D p1 = Point2D.of(1, -5); - Point2D p2 = Point2D.of(-4, 0); - Point2D p3 = Point2D.of(10, -4); - - // act/assert - checkPoint(Point2D.lerp(p1, p1, 0), 1, -5); - checkPoint(Point2D.lerp(p1, p1, 1), 1, -5); - - checkPoint(Point2D.lerp(p1, p2, -0.25), 2.25, -6.25); - checkPoint(Point2D.lerp(p1, p2, 0), 1, -5); - checkPoint(Point2D.lerp(p1, p2, 0.25), -0.25, -3.75); - checkPoint(Point2D.lerp(p1, p2, 0.5), -1.5, -2.5); - checkPoint(Point2D.lerp(p1, p2, 0.75), -2.75, -1.25); - checkPoint(Point2D.lerp(p1, p2, 1), -4, 0); - checkPoint(Point2D.lerp(p1, p2, 1.25), -5.25, 1.25); - - checkPoint(Point2D.lerp(p1, p3, 0), 1, -5); - checkPoint(Point2D.lerp(p1, p3, 0.25), 3.25, -4.75); - checkPoint(Point2D.lerp(p1, p3, 0.5), 5.5, -4.5); - checkPoint(Point2D.lerp(p1, p3, 0.75), 7.75, -4.25); - checkPoint(Point2D.lerp(p1, p3, 1), 10, -4); - } - - @Test public void testAdd() { // arrange Point2D p1 = Point2D.of(1, 1); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java index 1e3a1ba..62e0c8e 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java @@ -361,30 +361,6 @@ public class Vector2DTest { } @Test - public void testDotProduct_static() { - // arrange - Vector2D v1 = Vector2D.of(1, 1); - Vector2D v2 = Vector2D.of(4, 5); - Vector2D v3 = Vector2D.of(-1, 0); - - // act/assert - Assert.assertEquals(2, Vector2D.dotProduct(v1, v1), EPS); - Assert.assertEquals(41, Vector2D.dotProduct(v2, v2), EPS); - Assert.assertEquals(1, Vector2D.dotProduct(v3, v3), EPS); - - Assert.assertEquals(9, Vector2D.dotProduct(v1, v2), EPS); - Assert.assertEquals(9, Vector2D.dotProduct(v2, v1), EPS); - - Assert.assertEquals(-1, Vector2D.dotProduct(v1, v3), EPS); - Assert.assertEquals(-1, Vector2D.dotProduct(v3, v1), EPS); - - Assert.assertEquals(1, Vector2D.dotProduct(Vector2D.PLUS_X, Vector2D.PLUS_X), EPS); - Assert.assertEquals(0, Vector2D.dotProduct(Vector2D.PLUS_X, Vector2D.PLUS_Y), EPS); - Assert.assertEquals(-1, Vector2D.dotProduct(Vector2D.PLUS_X, Vector2D.MINUS_X), EPS); - Assert.assertEquals(0, Vector2D.dotProduct(Vector2D.PLUS_X, Vector2D.MINUS_Y), EPS); - } - - @Test public void testAngle() { // act/assert Assert.assertEquals(0, Vector2D.PLUS_X.angle(Vector2D.PLUS_X), EPS); @@ -399,21 +375,6 @@ public class Vector2DTest { Assert.assertEquals(0.004999958333958323, Vector2D.of(20.0, 0.0).angle(Vector2D.of(20.0, 0.1)), EPS); } - @Test - public void testAngle_static() { - // act/assert - Assert.assertEquals(0, Vector2D.angle(Vector2D.PLUS_X, Vector2D.PLUS_X), EPS); - - Assert.assertEquals(Geometry.PI, Vector2D.angle(Vector2D.PLUS_X, Vector2D.MINUS_X), EPS); - Assert.assertEquals(Geometry.HALF_PI, Vector2D.angle(Vector2D.PLUS_X, Vector2D.PLUS_Y), EPS); - Assert.assertEquals(Geometry.HALF_PI, Vector2D.angle(Vector2D.PLUS_X, Vector2D.MINUS_Y), EPS); - - Assert.assertEquals(Geometry.PI / 4, Vector2D.angle(Vector2D.of(1, 1), Vector2D.of(1, 0)), EPS); - Assert.assertEquals(Geometry.PI / 4, Vector2D.angle(Vector2D.of(1, 0), Vector2D.of(1, 1)), EPS); - - Assert.assertEquals(0.004999958333958323, Vector2D.angle(Vector2D.of(20.0, 0.0), Vector2D.of(20.0, 0.1)), EPS); - } - @Test(expected = IllegalStateException.class) public void testAngle_zeroNorm() { @@ -464,33 +425,6 @@ public class Vector2DTest { } @Test - public void testProject_static() { - // arrange - Vector2D v1 = Vector2D.of(3.0, 4.0); - Vector2D v2 = Vector2D.of(1.0, 4.0); - - // act/assert - checkVector(Vector2D.project(Vector2D.ZERO, v1), 0.0, 0.0); - - checkVector(Vector2D.project(v1, v1), 3.0, 4.0); - checkVector(Vector2D.project(v1, v1.negate()), 3.0, 4.0); - - checkVector(Vector2D.project(v1, Vector2D.PLUS_X), 3.0, 0.0); - checkVector(Vector2D.project(v1, Vector2D.MINUS_X), 3.0, 0.0); - - checkVector(Vector2D.project(v1, Vector2D.PLUS_Y), 0.0, 4.0); - checkVector(Vector2D.project(v1, Vector2D.MINUS_Y), 0.0, 4.0); - - checkVector(Vector2D.project(v2, v1), (19.0 / 25.0) * 3.0, (19.0 / 25.0) * 4.0); - } - - @Test(expected = IllegalStateException.class) - public void testProject_baseHasZeroNorm_static() { - // act/assert - Vector2D.project(Vector2D.of(1.0, 1.0), Vector2D.ZERO); - } - - @Test public void testReject() { // arrange Vector2D v1 = Vector2D.of(3.0, 4.0); @@ -518,33 +452,6 @@ public class Vector2DTest { } @Test - public void testReject_static() { - // arrange - Vector2D v1 = Vector2D.of(3.0, 4.0); - Vector2D v2 = Vector2D.of(1.0, 4.0); - - // act/assert - checkVector(Vector2D.ZERO.reject(v1), 0.0, 0.0); - - checkVector(Vector2D.reject(v1, v1), 0.0, 0.0); - checkVector(Vector2D.reject(v1, v1.negate()), 0.0, 0.0); - - checkVector(Vector2D.reject(v1, Vector2D.PLUS_X), 0.0, 4.0); - checkVector(Vector2D.reject(v1, Vector2D.MINUS_X), 0.0, 4.0); - - checkVector(Vector2D.reject(v1, Vector2D.PLUS_Y), 3.0, 0.0); - checkVector(Vector2D.reject(v1, Vector2D.MINUS_Y), 3.0, 0.0); - - checkVector(Vector2D.reject(v2, v1), (-32.0 / 25.0), (6.0 / 25.0) * 4.0); - } - - @Test(expected = IllegalStateException.class) - public void testReject_baseHasZeroNorm_static() { - // act/assert - Vector2D.reject(Vector2D.of(1.0, 1.0), Vector2D.ZERO); - } - - @Test public void testProjectAndReject_areComplementary() { // arrange double eps = 1e-12; @@ -617,32 +524,6 @@ public class Vector2DTest { } @Test - public void testLerp_static() { - // arrange - Vector2D v1 = Vector2D.of(1, -5); - Vector2D v2 = Vector2D.of(-4, 0); - Vector2D v3 = Vector2D.of(10, -4); - - // act/assert - checkVector(Vector2D.lerp(v1, v1, 0), 1, -5); - checkVector(Vector2D.lerp(v1, v1, 1), 1, -5); - - checkVector(Vector2D.lerp(v1, v2, -0.25), 2.25, -6.25); - checkVector(Vector2D.lerp(v1, v2, 0), 1, -5); - checkVector(Vector2D.lerp(v1, v2, 0.25), -0.25, -3.75); - checkVector(Vector2D.lerp(v1, v2, 0.5), -1.5, -2.5); - checkVector(Vector2D.lerp(v1, v2, 0.75), -2.75, -1.25); - checkVector(Vector2D.lerp(v1, v2, 1), -4, 0); - checkVector(Vector2D.lerp(v1, v2, 1.25), -5.25, 1.25); - - checkVector(Vector2D.lerp(v1, v3, 0), 1, -5); - checkVector(Vector2D.lerp(v1, v3, 0.25), 3.25, -4.75); - checkVector(Vector2D.lerp(v1, v3, 0.5), 5.5, -4.5); - checkVector(Vector2D.lerp(v1, v3, 0.75), 7.75, -4.25); - checkVector(Vector2D.lerp(v1, v3, 1), 10, -4); - } - - @Test public void testHashCode() { // arrange Vector2D u = Vector2D.of(1, 1); diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/EdgesBuilder.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/EdgesBuilder.java index 085f9c5..b44ee95 100644 --- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/EdgesBuilder.java +++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/EdgesBuilder.java @@ -126,7 +126,7 @@ class EdgesBuilder implements BSPTreeVisitor<S2Point> { for (final Edge edge : nodeToEdgesList.get(node)) { if (edge != previous && edge.getStart().getIncoming() == null) { final Vector3D edgeStart = edge.getStart().getLocation().getVector(); - final double gap = Vector3D.angle(point.getVector(), edgeStart); + final double gap = point.getVector().angle(edgeStart); if (gap <= closest) { closest = gap; following = edge; @@ -137,7 +137,7 @@ class EdgesBuilder implements BSPTreeVisitor<S2Point> { if (following == null) { final Vector3D previousStart = previous.getStart().getLocation().getVector(); - if (Vector3D.angle(point.getVector(), previousStart) <= tolerance) { + if (point.getVector().angle(previousStart) <= tolerance) { // the edge connects back to itself return previous; } diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/PropertiesComputer.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/PropertiesComputer.java index 982c8af..3f6da88 100644 --- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/PropertiesComputer.java +++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/PropertiesComputer.java @@ -110,8 +110,8 @@ class PropertiesComputer implements BSPTreeVisitor<S2Point> { final Vector3D previousPole = e.getCircle().getPole(); final Vector3D nextPole = e.getEnd().getOutgoing().getCircle().getPole(); final Vector3D point = e.getEnd().getLocation().getVector(); - double alpha = Math.atan2(Vector3D.dotProduct(nextPole, Vector3D.crossProduct(point, previousPole)), - -Vector3D.dotProduct(nextPole, previousPole)); + double alpha = Math.atan2(nextPole.dotProduct(point.crossProduct(previousPole)), + - nextPole.dotProduct(previousPole)); if (alpha < 0) { alpha += Geometry.TWO_PI; } diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSet.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSet.java index fafac75..d16ef8b 100644 --- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSet.java +++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSet.java @@ -159,7 +159,7 @@ public class SphericalPolygonsSet extends AbstractRegion<S2Point, S1Point> { private static S2Point[] createRegularPolygonVertices(final Vector3D center, final Vector3D meridian, final double outsideRadius, final int n) { final S2Point[] array = new S2Point[n]; - final Rotation r0 = new Rotation(Vector3D.crossProduct(center, meridian), + final Rotation r0 = new Rotation(center.crossProduct(meridian), outsideRadius, RotationConvention.VECTOR_OPERATOR); array[0] = S2Point.ofVector(r0.applyTo(center)); @@ -223,7 +223,7 @@ public class SphericalPolygonsSet extends AbstractRegion<S2Point, S1Point> { // create the edge and store it edges.add(new Edge(start, end, - Vector3D.angle(start.getLocation().getVector(), + start.getLocation().getVector().angle( end.getLocation().getVector()), circle)); diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubCircle.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubCircle.java index 2205060..30349ca 100644 --- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubCircle.java +++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubCircle.java @@ -19,7 +19,6 @@ package org.apache.commons.geometry.spherical.twod; import org.apache.commons.geometry.core.partitioning.AbstractSubHyperplane; import org.apache.commons.geometry.core.partitioning.Hyperplane; import org.apache.commons.geometry.core.partitioning.Region; -import org.apache.commons.geometry.euclidean.threed.Vector3D; import org.apache.commons.geometry.spherical.oned.Arc; import org.apache.commons.geometry.spherical.oned.ArcsSet; import org.apache.commons.geometry.spherical.oned.S1Point; @@ -50,7 +49,7 @@ public class SubCircle extends AbstractSubHyperplane<S2Point, S1Point> { final Circle thisCircle = (Circle) getHyperplane(); final Circle otherCircle = (Circle) hyperplane; - final double angle = Vector3D.angle(thisCircle.getPole(), otherCircle.getPole()); + final double angle = thisCircle.getPole().angle(otherCircle.getPole()); if (angle < thisCircle.getTolerance() || angle > Math.PI - thisCircle.getTolerance()) { // the two circles are aligned or opposite diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java index f056acb..f281988 100644 --- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java +++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java @@ -50,11 +50,11 @@ public class CircleTest { Circle circle = new Circle(S2Point.of(1.2, 2.5), S2Point.of(-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 * Math.PI).distance(circle.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(circle.getXAxis(), circle.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(circle.getXAxis(), circle.getPole()), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(circle.getPole(), circle.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, circle.getXAxis().angle(circle.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, circle.getXAxis().angle(circle.getPole()), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, circle.getPole().angle(circle.getYAxis()), 1.0e-10); Assert.assertEquals(0.0, - circle.getPole().distance(Vector3D.crossProduct(circle.getXAxis(), circle.getYAxis())), + circle.getPole().distance(circle.getXAxis().crossProduct(circle.getYAxis())), 1.0e-10); } @@ -64,20 +64,19 @@ 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 * Math.PI).distance(reversed.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(reversed.getXAxis(), reversed.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(reversed.getXAxis(), reversed.getPole()), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(reversed.getPole(), reversed.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, reversed.getXAxis().angle(reversed.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, reversed.getXAxis().angle(reversed.getPole()), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, reversed.getPole().angle(reversed.getYAxis()), 1.0e-10); Assert.assertEquals(0.0, - reversed.getPole().distance(Vector3D.crossProduct(reversed.getXAxis(), reversed.getYAxis())), + reversed.getPole().distance(reversed.getXAxis().crossProduct(reversed.getYAxis())), 1.0e-10); - Assert.assertEquals(0, Vector3D.angle(circle.getXAxis(), reversed.getXAxis()), 1.0e-10); - Assert.assertEquals(Math.PI, Vector3D.angle(circle.getYAxis(), reversed.getYAxis()), 1.0e-10); - Assert.assertEquals(Math.PI, Vector3D.angle(circle.getPole(), reversed.getPole()), 1.0e-10); + Assert.assertEquals(0, circle.getXAxis().angle(reversed.getXAxis()), 1.0e-10); + Assert.assertEquals(Math.PI, circle.getYAxis().angle(reversed.getYAxis()), 1.0e-10); + Assert.assertEquals(Math.PI, circle.getPole().angle(reversed.getPole()), 1.0e-10); Assert.assertTrue(circle.sameOrientationAs(circle)); Assert.assertFalse(circle.sameOrientationAs(reversed)); - } @Test @@ -86,14 +85,13 @@ public class CircleTest { Vector3D p = Vector3D.of(1, 2, -4); Vector3D samePhase = circle.getPointAt(circle.getPhase(p)); Assert.assertEquals(0.0, - Vector3D.angle(Vector3D.crossProduct(circle.getPole(), p), - Vector3D.crossProduct(circle.getPole(), samePhase)), + circle.getPole().crossProduct(p).angle( + circle.getPole().crossProduct(samePhase)), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(circle.getPole(), samePhase), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, circle.getPole().angle(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 * Math.PI, circle.getPhase(circle.getYAxis()), 1.0e-10); - } @Test @@ -113,7 +111,7 @@ public class CircleTest { Math.sin(alpha), circle.getYAxis()); Vector3D q = circle.toSpace(S1Point.of(alpha)).getVector(); Assert.assertEquals(0.0, p.distance(q), 1.0e-10); - Assert.assertEquals(0.5 * Math.PI, Vector3D.angle(circle.getPole(), q), 1.0e-10); + Assert.assertEquals(0.5 * Math.PI, circle.getPole().angle(q), 1.0e-10); } } diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java index 1051ea2..9c9f891 100644 --- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java +++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java @@ -478,7 +478,7 @@ public class SphericalPolygonsSetTest { ++count; for (int i = 0; i < Math.ceil(v.getOutgoing().getLength() / step); ++i) { Vector3D p = v.getOutgoing().getPointAt(i * step); - Assert.assertTrue(Vector3D.angle(p, enclosingCenter) <= enclosing.getRadius()); + Assert.assertTrue(p.angle(enclosingCenter) <= enclosing.getRadius()); } } } @@ -500,7 +500,7 @@ public class SphericalPolygonsSetTest { ++count; for (int i = 0; i < Math.ceil(v.getOutgoing().getLength() / step); ++i) { Vector3D p = v.getOutgoing().getPointAt(i * step); - Assert.assertTrue(Vector3D.angle(p, continentalCenter) <= continentalInscribed.getRadius()); + Assert.assertTrue(p.angle(continentalCenter) <= continentalInscribed.getRadius()); } } } @@ -515,7 +515,7 @@ public class SphericalPolygonsSetTest { ++count; for (int i = 0; i < Math.ceil(v.getOutgoing().getLength() / step); ++i) { Vector3D p = v.getOutgoing().getPointAt(i * step); - Assert.assertTrue(Vector3D.angle(p, corsicaCenter) <= corsicaInscribed.getRadius()); + Assert.assertTrue(p.angle(corsicaCenter) <= corsicaInscribed.getRadius()); } } }
