You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/02/10 10:31:06 UTC

[commons-geometry] branch master updated (1f334d1 -> 5f7d21a)

This is an automated email from the ASF dual-hosted git repository.

erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git.


    from 1f334d1  Merge branch 'GEOMETRY-42__matt'
     new 0ccee17  GEOMETRY-41: Adding equals(EuclideanVector, DoublePrecisionContext) and isZero(DoublePrecisionContext) methods to EuclideanVector and subclasses
     new f6de918  GEOMETRY-11: using shorter and more consistent method names for DoublePrecisionContext
     new 5f7d21a  Merge branch 'GEOMETRY-41__matt'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../core/precision/DoublePrecisionContext.java     | 16 ++---
 .../core/precision/DoublePrecisionContextTest.java | 80 +++++++++++-----------
 .../EpsilonDoublePrecisionContextTest.java         | 12 ++--
 .../geometry/euclidean/EuclideanVector.java        | 30 ++++++++
 .../commons/geometry/euclidean/oned/Vector1D.java  |  7 ++
 .../commons/geometry/euclidean/threed/Line.java    |  4 +-
 .../commons/geometry/euclidean/threed/Plane.java   | 10 +--
 .../geometry/euclidean/threed/PolyhedronsSet.java  |  6 +-
 .../geometry/euclidean/threed/Vector3D.java        |  9 +++
 .../commons/geometry/euclidean/twod/Line.java      |  6 +-
 .../geometry/euclidean/twod/PolygonsSet.java       | 12 ++--
 .../commons/geometry/euclidean/twod/Vector2D.java  |  8 +++
 .../geometry/euclidean/oned/Vector1DTest.java      | 44 ++++++++++++
 .../geometry/euclidean/threed/Vector3DTest.java    | 62 +++++++++++++++++
 .../geometry/euclidean/twod/Vector2DTest.java      | 52 ++++++++++++++
 .../euclidean/twod/hull/MonotoneChain.java         |  6 +-
 .../commons/geometry/spherical/oned/ArcsSet.java   |  2 +-
 .../commons/geometry/spherical/twod/Edge.java      |  2 +-
 .../geometry/spherical/twod/EdgesBuilder.java      |  2 +-
 .../spherical/twod/SphericalPolygonsSet.java       |  4 +-
 .../commons/geometry/spherical/twod/SubCircle.java |  2 +-
 21 files changed, 295 insertions(+), 81 deletions(-)


[commons-geometry] 01/03: GEOMETRY-41: Adding equals(EuclideanVector, DoublePrecisionContext) and isZero(DoublePrecisionContext) methods to EuclideanVector and subclasses

Posted by er...@apache.org.
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 0ccee1783e8ae72941f3d79e88b9a8e59548fc89
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Tue Feb 5 23:29:58 2019 -0500

    GEOMETRY-41: Adding equals(EuclideanVector, DoublePrecisionContext) and isZero(DoublePrecisionContext) methods to EuclideanVector and subclasses
---
 .../geometry/euclidean/EuclideanVector.java        | 30 +++++++++++
 .../commons/geometry/euclidean/oned/Vector1D.java  |  7 +++
 .../geometry/euclidean/threed/Vector3D.java        |  9 ++++
 .../commons/geometry/euclidean/twod/Vector2D.java  |  8 +++
 .../geometry/euclidean/oned/Vector1DTest.java      | 44 +++++++++++++++
 .../geometry/euclidean/threed/Vector3DTest.java    | 62 ++++++++++++++++++++++
 .../geometry/euclidean/twod/Vector2DTest.java      | 52 ++++++++++++++++++
 7 files changed, 212 insertions(+)

diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java
index 00edec6..f767f97 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import org.apache.commons.geometry.core.Point;
 import org.apache.commons.geometry.core.Vector;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
+import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
 import org.apache.commons.geometry.euclidean.internal.Vectors;
 
 /** Abstract base class for Euclidean vectors <em>and</em> points. See
@@ -67,6 +68,35 @@ public abstract class EuclideanVector<V extends EuclideanVector<V>>
      */
     public abstract V lerp(V v, double t);
 
+    /** Return true if the current instance and given vector are considered equal as evaluated by the
+     * given precision context.
+     *
+     * <p>Equality is determined by comparing each pair of components in turn from the two
+     * vectors. If all components evaluate as equal, then the vectors are considered equal. If any are
+     * not equal, then the vectors are not considered equal. Note that this approach means that the
+     * calculated distance between two "equal" vectors may be as much as <code>&radic;(n * eps<sup>2</sup>)</code>,
+     * where {@code n} is the number of components in the vector and {@code eps} is the maximum epsilon
+     * value allowed by the precision context.
+     * @param v vector to check for equality
+     * @param precision precision context used to determine floating point equality
+     * @return true if the current instance is considered equal to the given vector when using
+     *      the given precision context; otherwise false
+     */
+    public abstract boolean equals(V v, DoublePrecisionContext precision);
+
+    /** Return true if the current instance is considered equal to the zero vector as evaluated by the
+     * given precision context. This is a convenience method equivalent to
+     * {@code vec.equals(vec.getZero(), precision)}.
+     *
+     * @param precision precision context used to determine floating point equality
+     * @return true if the current instance is considered equal to the zero vector when using
+     *      the given precision context; otherwise false
+     * @see #equals(EuclideanVector, DoublePrecisionContext)
+     */
+    public boolean isZero(final DoublePrecisionContext precision) {
+        return equals(getZero(), precision);
+    }
+
     /** Return the vector norm value, throwing an {@link IllegalNormException} if the value
      * is not real (ie, NaN or infinite) or zero.
      * @return the vector norm value, guaranteed to be real and non-zero
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 6556ca0..67a683a 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
@@ -19,6 +19,7 @@ package org.apache.commons.geometry.euclidean.oned;
 import org.apache.commons.geometry.core.Geometry;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
+import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
 import org.apache.commons.geometry.euclidean.EuclideanVector;
 import org.apache.commons.geometry.euclidean.internal.Vectors;
 import org.apache.commons.numbers.arrays.LinearCombination;
@@ -219,6 +220,12 @@ public class Vector1D extends EuclideanVector<Vector1D> {
         return transform.apply(this);
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(final Vector1D vec, final DoublePrecisionContext precision) {
+        return precision.areEqual(x, vec.x);
+    }
+
     /**
      * Get a hashCode for the vector.
      * <p>All NaN values have the same hash code.</p>
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 b59793a..e350ef7 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
@@ -20,6 +20,7 @@ package org.apache.commons.geometry.euclidean.threed;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
 import org.apache.commons.geometry.core.internal.DoubleFunction3N;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
+import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
 import org.apache.commons.geometry.euclidean.MultiDimensionalEuclideanVector;
 import org.apache.commons.geometry.euclidean.internal.Vectors;
 import org.apache.commons.numbers.arrays.LinearCombination;
@@ -370,6 +371,14 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
         return transform.apply(this);
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(final Vector3D vec, final DoublePrecisionContext precision) {
+        return precision.areEqual(x, vec.x) &&
+                precision.areEqual(y, vec.y) &&
+                precision.areEqual(z, vec.z);
+    }
+
     /**
      * Get a hashCode for the vector.
      * <p>All NaN values have the same hash code.</p>
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 08b4f1f..582f66f 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
@@ -19,6 +19,7 @@ package org.apache.commons.geometry.euclidean.twod;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
 import org.apache.commons.geometry.core.internal.DoubleFunction2N;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
+import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
 import org.apache.commons.geometry.euclidean.MultiDimensionalEuclideanVector;
 import org.apache.commons.geometry.euclidean.internal.Vectors;
 import org.apache.commons.numbers.arrays.LinearCombination;
@@ -319,6 +320,13 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
         return transform.apply(this);
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(final Vector2D vec, final DoublePrecisionContext precision) {
+        return precision.areEqual(x, vec.x) &&
+                precision.areEqual(y, vec.y);
+    }
+
     /**
      * Get a hashCode for the 2D coordinates.
      * <p>
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 8aa06b7..e3b015d 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
@@ -21,6 +21,8 @@ import java.util.regex.Pattern;
 import org.apache.commons.geometry.core.Geometry;
 import org.apache.commons.geometry.core.GeometryTestUtils;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
+import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
+import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
 import org.apache.commons.numbers.core.Precision;
 import org.junit.Assert;
 import org.junit.Test;
@@ -464,6 +466,48 @@ public class Vector1DTest {
     }
 
     @Test
+    public void testPrecisionEquals() {
+        // arrange
+        DoublePrecisionContext smallEps = new EpsilonDoublePrecisionContext(1e-6);
+        DoublePrecisionContext largeEps = new EpsilonDoublePrecisionContext(1e-1);
+
+        Vector1D vec = Vector1D.of(1);
+
+        // act/assert
+        Assert.assertTrue(vec.equals(vec, smallEps));
+        Assert.assertTrue(vec.equals(vec, largeEps));
+
+        Assert.assertTrue(vec.equals(Vector1D.of(1.0000007), smallEps));
+        Assert.assertTrue(vec.equals(Vector1D.of(1.0000007), largeEps));
+
+        Assert.assertFalse(vec.equals(Vector1D.of(1.004), smallEps));
+        Assert.assertTrue(vec.equals(Vector1D.of(1.004), largeEps));
+
+        Assert.assertFalse(vec.equals(Vector1D.of(2), smallEps));
+        Assert.assertFalse(vec.equals(Vector1D.of(-2), largeEps));
+    }
+
+    @Test
+    public void testIsZero() {
+        // arrange
+        DoublePrecisionContext smallEps = new EpsilonDoublePrecisionContext(1e-6);
+        DoublePrecisionContext largeEps = new EpsilonDoublePrecisionContext(1e-1);
+
+        // act/assert
+        Assert.assertTrue(Vector1D.of(0.0).isZero(smallEps));
+        Assert.assertTrue(Vector1D.of(-0.0).isZero(largeEps));
+
+        Assert.assertTrue(Vector1D.of(1e-7).isZero(smallEps));
+        Assert.assertTrue(Vector1D.of(-1e-7).isZero(largeEps));
+
+        Assert.assertFalse(Vector1D.of(1e-2).isZero(smallEps));
+        Assert.assertTrue(Vector1D.of(-1e-2).isZero(largeEps));
+
+        Assert.assertFalse(Vector1D.of(0.2).isZero(smallEps));
+        Assert.assertFalse(Vector1D.of(-0.2).isZero(largeEps));
+    }
+
+    @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/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index c6243d5..95f6077 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
@@ -22,6 +22,8 @@ import java.util.regex.Pattern;
 import org.apache.commons.geometry.core.Geometry;
 import org.apache.commons.geometry.core.GeometryTestUtils;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
+import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
+import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
 import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
 import org.apache.commons.numbers.core.Precision;
 import org.apache.commons.rng.UniformRandomProvider;
@@ -934,6 +936,66 @@ public class Vector3DTest {
     }
 
     @Test
+    public void testPrecisionEquals() {
+        // arrange
+        DoublePrecisionContext smallEps = new EpsilonDoublePrecisionContext(1e-6);
+        DoublePrecisionContext largeEps = new EpsilonDoublePrecisionContext(1e-1);
+
+        Vector3D vec = Vector3D.of(1, -2, 3);
+
+        // act/assert
+        Assert.assertTrue(vec.equals(vec, smallEps));
+        Assert.assertTrue(vec.equals(vec, largeEps));
+
+        Assert.assertTrue(vec.equals(Vector3D.of(1.0000007, -2.0000009, 3.0000009), smallEps));
+        Assert.assertTrue(vec.equals(Vector3D.of(1.0000007, -2.0000009, 3.0000009), largeEps));
+
+        Assert.assertFalse(vec.equals(Vector3D.of(1.004, -2, 3), smallEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(1, -2.004, 3), smallEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(1, -2, 2.999), smallEps));
+        Assert.assertTrue(vec.equals(Vector3D.of(1.004, -2.004, 2.999), largeEps));
+
+        Assert.assertFalse(vec.equals(Vector3D.of(2, -2, 3), smallEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(1, -3, 3), smallEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(1, -2, 4), smallEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(2, -3, 4), smallEps));
+
+        Assert.assertFalse(vec.equals(Vector3D.of(2, -2, 3), largeEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(1, -3, 3), largeEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(1, -2, 4), largeEps));
+        Assert.assertFalse(vec.equals(Vector3D.of(2, -3, 4), largeEps));
+    }
+
+    @Test
+    public void testIsZero() {
+        // arrange
+        DoublePrecisionContext smallEps = new EpsilonDoublePrecisionContext(1e-6);
+        DoublePrecisionContext largeEps = new EpsilonDoublePrecisionContext(1e-1);
+
+        // act/assert
+        Assert.assertTrue(Vector3D.of(0.0, -0.0, 0.0).isZero(smallEps));
+        Assert.assertTrue(Vector3D.of(-0.0, 0.0, -0.0).isZero(largeEps));
+
+        Assert.assertTrue(Vector3D.of(-1e-7, 1e-7, -1e-8).isZero(smallEps));
+        Assert.assertTrue(Vector3D.of(1e-7, -1e-7, 1e-8).isZero(largeEps));
+
+        Assert.assertFalse(Vector3D.of(1e-2, 0.0, 0.0).isZero(smallEps));
+        Assert.assertFalse(Vector3D.of(0.0, 1e-2, 0.0).isZero(smallEps));
+        Assert.assertFalse(Vector3D.of(0.0, 0.0, 1e-2).isZero(smallEps));
+        Assert.assertTrue(Vector3D.of(1e-2, -1e-2, 1e-2).isZero(largeEps));
+
+        Assert.assertFalse(Vector3D.of(0.2, 0.0, 0.0).isZero(smallEps));
+        Assert.assertFalse(Vector3D.of(0.0, 0.2, 0.0).isZero(smallEps));
+        Assert.assertFalse(Vector3D.of(0.0, 0.0, 0.2).isZero(smallEps));
+        Assert.assertFalse(Vector3D.of(0.2, 0.2, 0.2).isZero(smallEps));
+
+        Assert.assertFalse(Vector3D.of(0.2, 0.0, 0.0).isZero(largeEps));
+        Assert.assertFalse(Vector3D.of(0.0, 0.2, 0.0).isZero(largeEps));
+        Assert.assertFalse(Vector3D.of(0.0, 0.0, 0.2).isZero(largeEps));
+        Assert.assertFalse(Vector3D.of(0.2, 0.2, 0.2).isZero(largeEps));
+    }
+
+    @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/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index 5a4c268..76564b4 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
@@ -21,6 +21,8 @@ import java.util.regex.Pattern;
 import org.apache.commons.geometry.core.Geometry;
 import org.apache.commons.geometry.core.GeometryTestUtils;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
+import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
+import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
 import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
 import org.apache.commons.numbers.core.Precision;
 import org.junit.Assert;
@@ -741,6 +743,56 @@ public class Vector2DTest {
     }
 
     @Test
+    public void testPrecisionEquals() {
+        // arrange
+        DoublePrecisionContext smallEps = new EpsilonDoublePrecisionContext(1e-6);
+        DoublePrecisionContext largeEps = new EpsilonDoublePrecisionContext(1e-1);
+
+        Vector2D vec = Vector2D.of(1, -2);
+
+        // act/assert
+        Assert.assertTrue(vec.equals(vec, smallEps));
+        Assert.assertTrue(vec.equals(vec, largeEps));
+
+        Assert.assertTrue(vec.equals(Vector2D.of(1.0000007, -2.0000009), smallEps));
+        Assert.assertTrue(vec.equals(Vector2D.of(1.0000007, -2.0000009), largeEps));
+
+        Assert.assertFalse(vec.equals(Vector2D.of(1.004, -2), smallEps));
+        Assert.assertFalse(vec.equals(Vector2D.of(1, -2.004), smallEps));
+        Assert.assertTrue(vec.equals(Vector2D.of(1.004, -2.004), largeEps));
+
+        Assert.assertFalse(vec.equals(Vector2D.of(1, -3), smallEps));
+        Assert.assertFalse(vec.equals(Vector2D.of(2, -2), smallEps));
+        Assert.assertFalse(vec.equals(Vector2D.of(1, -3), largeEps));
+        Assert.assertFalse(vec.equals(Vector2D.of(2, -2), largeEps));
+    }
+
+    @Test
+    public void testIsZero() {
+        // arrange
+        DoublePrecisionContext smallEps = new EpsilonDoublePrecisionContext(1e-6);
+        DoublePrecisionContext largeEps = new EpsilonDoublePrecisionContext(1e-1);
+
+        // act/assert
+        Assert.assertTrue(Vector2D.of(0.0, -0.0).isZero(smallEps));
+        Assert.assertTrue(Vector2D.of(-0.0, 0.0).isZero(largeEps));
+
+        Assert.assertTrue(Vector2D.of(-1e-7, 1e-7).isZero(smallEps));
+        Assert.assertTrue(Vector2D.of(1e-7, 1e-7).isZero(largeEps));
+
+        Assert.assertFalse(Vector2D.of(1e-2, 0.0).isZero(smallEps));
+        Assert.assertFalse(Vector2D.of(0.0, 1e-2).isZero(smallEps));
+        Assert.assertTrue(Vector2D.of(1e-2, -1e-2).isZero(largeEps));
+
+        Assert.assertFalse(Vector2D.of(0.2, 0.0).isZero(smallEps));
+        Assert.assertFalse(Vector2D.of(0.0, 0.2).isZero(smallEps));
+        Assert.assertFalse(Vector2D.of(0.2, 0.2).isZero(smallEps));
+        Assert.assertFalse(Vector2D.of(-0.2, 0.0).isZero(largeEps));
+        Assert.assertFalse(Vector2D.of(0.0, -0.2).isZero(largeEps));
+        Assert.assertFalse(Vector2D.of(-0.2, -0.2).isZero(largeEps));
+    }
+
+    @Test
     public void testHashCode() {
         // arrange
         Vector2D u = Vector2D.of(1, 1);


[commons-geometry] 02/03: GEOMETRY-11: using shorter and more consistent method names for DoublePrecisionContext

Posted by er...@apache.org.
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 f6de918dd4aff1b4291d5cf81f77807aad0ec413
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Fri Feb 8 18:47:43 2019 -0500

    GEOMETRY-11: using shorter and more consistent method names for DoublePrecisionContext
---
 .../core/precision/DoublePrecisionContext.java     | 16 ++---
 .../core/precision/DoublePrecisionContextTest.java | 80 +++++++++++-----------
 .../EpsilonDoublePrecisionContextTest.java         | 12 ++--
 .../commons/geometry/euclidean/oned/Vector1D.java  |  2 +-
 .../commons/geometry/euclidean/threed/Line.java    |  4 +-
 .../commons/geometry/euclidean/threed/Plane.java   | 10 +--
 .../geometry/euclidean/threed/PolyhedronsSet.java  |  6 +-
 .../geometry/euclidean/threed/Vector3D.java        |  6 +-
 .../commons/geometry/euclidean/twod/Line.java      |  6 +-
 .../geometry/euclidean/twod/PolygonsSet.java       | 12 ++--
 .../commons/geometry/euclidean/twod/Vector2D.java  |  4 +-
 .../euclidean/twod/hull/MonotoneChain.java         |  6 +-
 .../commons/geometry/spherical/oned/ArcsSet.java   |  2 +-
 .../commons/geometry/spherical/twod/Edge.java      |  2 +-
 .../geometry/spherical/twod/EdgesBuilder.java      |  2 +-
 .../spherical/twod/SphericalPolygonsSet.java       |  4 +-
 .../commons/geometry/spherical/twod/SubCircle.java |  2 +-
 17 files changed, 89 insertions(+), 87 deletions(-)

diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/precision/DoublePrecisionContext.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/precision/DoublePrecisionContext.java
index 1d36953..6773837 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/precision/DoublePrecisionContext.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/precision/DoublePrecisionContext.java
@@ -31,18 +31,18 @@ public abstract class DoublePrecisionContext implements Comparator<Double>, Seri
      * @param b second value
      * @return true if the given values are considered equal
      */
-    public boolean areEqual(final double a, final double b) {
+    public boolean eq(final double a, final double b) {
         return compare(a, b) == 0;
     }
 
     /** Return true if the given value is considered equal to zero. This is
-     * equivalent {@code context.areEqual(n, 0.0)} but with a more explicit
+     * equivalent {@code context.eq(n, 0.0)} but with a more explicit
      * method name.
      * @param n the number to compare to zero
      * @return true if the argument is considered equal to zero.
      */
-    public boolean isZero(final double n) {
-        return areEqual(n, 0.0);
+    public boolean eqZero(final double n) {
+        return eq(n, 0.0);
     }
 
     /**
@@ -51,7 +51,7 @@ public abstract class DoublePrecisionContext implements Comparator<Double>, Seri
      * @param b second value
      * @return true if {@code a < b}
      */
-    public boolean isLessThan(final double a, final double b) {
+    public boolean lt(final double a, final double b) {
         return compare(a, b) < 0;
     }
 
@@ -61,7 +61,7 @@ public abstract class DoublePrecisionContext implements Comparator<Double>, Seri
      * @param b second value
      * @return true if {@code a <= b}
      */
-    public boolean isLessThanOrEqual(final double a, final double b) {
+    public boolean lte(final double a, final double b) {
         return compare(a, b) <= 0;
     }
 
@@ -71,7 +71,7 @@ public abstract class DoublePrecisionContext implements Comparator<Double>, Seri
      * @param b second value
      * @return true if {@code a > b}
      */
-    public boolean isGreaterThan(final double a, final double b) {
+    public boolean gt(final double a, final double b) {
         return compare(a, b) > 0;
     }
 
@@ -81,7 +81,7 @@ public abstract class DoublePrecisionContext implements Comparator<Double>, Seri
      * @param b second value
      * @return true if {@code a >= b}
      */
-    public boolean isGreaterThanOrEqual(final double a, final double b) {
+    public boolean gte(final double a, final double b) {
         return compare(a, b) >= 0;
     }
 
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java
index f203e6d..80d9f8d 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java
@@ -25,72 +25,72 @@ public class DoublePrecisionContextTest {
     private StubContext ctx = new StubContext();
 
     @Test
-    public void testAreEqual() {
+    public void testEq() {
         // act/assert
-        Assert.assertTrue(ctx.areEqual(0.0, 0.0));
-        Assert.assertTrue(ctx.areEqual(1.0, 1.0));
-        Assert.assertTrue(ctx.areEqual(-1.0, -1.0));
+        Assert.assertTrue(ctx.eq(0.0, 0.0));
+        Assert.assertTrue(ctx.eq(1.0, 1.0));
+        Assert.assertTrue(ctx.eq(-1.0, -1.0));
 
-        Assert.assertFalse(ctx.areEqual(1.0, -1.0));
-        Assert.assertFalse(ctx.areEqual(1.0, Math.nextUp(1.0)));
-        Assert.assertFalse(ctx.areEqual(-1.0, Math.nextDown(1.0)));
+        Assert.assertFalse(ctx.eq(1.0, -1.0));
+        Assert.assertFalse(ctx.eq(1.0, Math.nextUp(1.0)));
+        Assert.assertFalse(ctx.eq(-1.0, Math.nextDown(1.0)));
     }
 
     @Test
-    public void testIsZero() {
+    public void testEqZero() {
         // act/assert
-        Assert.assertTrue(ctx.isZero(0.0));
+        Assert.assertTrue(ctx.eqZero(0.0));
 
-        Assert.assertFalse(ctx.isZero(Math.nextUp(0.0)));
-        Assert.assertFalse(ctx.isZero(Math.nextDown(-0.0)));
+        Assert.assertFalse(ctx.eqZero(Math.nextUp(0.0)));
+        Assert.assertFalse(ctx.eqZero(Math.nextDown(-0.0)));
     }
 
     @Test
-    public void testIsLessThan() {
+    public void testLt() {
         // act/assert
-        Assert.assertTrue(ctx.isLessThan(1, 2));
-        Assert.assertTrue(ctx.isLessThan(-2, -1));
+        Assert.assertTrue(ctx.lt(1, 2));
+        Assert.assertTrue(ctx.lt(-2, -1));
 
-        Assert.assertFalse(ctx.isLessThan(1, 1));
-        Assert.assertFalse(ctx.isLessThan(-1, -1));
-        Assert.assertFalse(ctx.isLessThan(2, 1));
-        Assert.assertFalse(ctx.isLessThan(-1, -2));
+        Assert.assertFalse(ctx.lt(1, 1));
+        Assert.assertFalse(ctx.lt(-1, -1));
+        Assert.assertFalse(ctx.lt(2, 1));
+        Assert.assertFalse(ctx.lt(-1, -2));
     }
 
     @Test
-    public void testIsLessThanOrEqual() {
+    public void testLte() {
         // act/assert
-        Assert.assertTrue(ctx.isLessThanOrEqual(1, 2));
-        Assert.assertTrue(ctx.isLessThanOrEqual(-2, -1));
-        Assert.assertTrue(ctx.isLessThanOrEqual(1, 1));
-        Assert.assertTrue(ctx.isLessThanOrEqual(-1, -1));
+        Assert.assertTrue(ctx.lte(1, 2));
+        Assert.assertTrue(ctx.lte(-2, -1));
+        Assert.assertTrue(ctx.lte(1, 1));
+        Assert.assertTrue(ctx.lte(-1, -1));
 
-        Assert.assertFalse(ctx.isLessThanOrEqual(2, 1));
-        Assert.assertFalse(ctx.isLessThanOrEqual(-1, -2));
+        Assert.assertFalse(ctx.lte(2, 1));
+        Assert.assertFalse(ctx.lte(-1, -2));
     }
 
     @Test
-    public void testIsGreaterThan() {
+    public void testGt() {
         // act/assert
-        Assert.assertTrue(ctx.isGreaterThan(2, 1));
-        Assert.assertTrue(ctx.isGreaterThan(-1, -2));
+        Assert.assertTrue(ctx.gt(2, 1));
+        Assert.assertTrue(ctx.gt(-1, -2));
 
-        Assert.assertFalse(ctx.isGreaterThan(1, 1));
-        Assert.assertFalse(ctx.isGreaterThan(-1, -1));
-        Assert.assertFalse(ctx.isGreaterThan(1, 2));
-        Assert.assertFalse(ctx.isGreaterThan(-2, -1));
+        Assert.assertFalse(ctx.gt(1, 1));
+        Assert.assertFalse(ctx.gt(-1, -1));
+        Assert.assertFalse(ctx.gt(1, 2));
+        Assert.assertFalse(ctx.gt(-2, -1));
     }
 
     @Test
-    public void testIsGreaterThanOrEqual() {
+    public void testGte() {
         // act/assert
-        Assert.assertTrue(ctx.isGreaterThanOrEqual(2, 1));
-        Assert.assertTrue(ctx.isGreaterThanOrEqual(-1, -2));
-        Assert.assertTrue(ctx.isGreaterThanOrEqual(1, 1));
-        Assert.assertTrue(ctx.isGreaterThanOrEqual(-1, -1));
+        Assert.assertTrue(ctx.gte(2, 1));
+        Assert.assertTrue(ctx.gte(-1, -2));
+        Assert.assertTrue(ctx.gte(1, 1));
+        Assert.assertTrue(ctx.gte(-1, -1));
 
-        Assert.assertFalse(ctx.isGreaterThanOrEqual(1, 2));
-        Assert.assertFalse(ctx.isGreaterThanOrEqual(-2, -1));
+        Assert.assertFalse(ctx.gte(1, 2));
+        Assert.assertFalse(ctx.gte(-2, -1));
     }
 
     @Test
@@ -119,6 +119,8 @@ public class DoublePrecisionContextTest {
 
     private static class StubContext extends DoublePrecisionContext {
 
+        private static final long serialVersionUID = 1L;
+
         @Override
         public double getMaxZero() {
             return 0.0;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
index b94052b..8bbe10d 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
@@ -126,13 +126,13 @@ public class EpsilonDoublePrecisionContextTest {
         double maxZero = ctx.getMaxZero();
 
         // act/assert
-        Assert.assertTrue(ctx.isZero(maxZero));
-        Assert.assertTrue(ctx.isZero(nextDown(maxZero, 1)));
-        Assert.assertFalse(ctx.isZero(nextUp(maxZero, 1)));
+        Assert.assertTrue(ctx.eqZero(maxZero));
+        Assert.assertTrue(ctx.eqZero(nextDown(maxZero, 1)));
+        Assert.assertFalse(ctx.eqZero(nextUp(maxZero, 1)));
 
-        Assert.assertTrue(ctx.isZero(-maxZero));
-        Assert.assertTrue(ctx.isZero(nextUp(-maxZero, 1)));
-        Assert.assertFalse(ctx.isZero(nextDown(-maxZero, 1)));
+        Assert.assertTrue(ctx.eqZero(-maxZero));
+        Assert.assertTrue(ctx.eqZero(nextUp(-maxZero, 1)));
+        Assert.assertFalse(ctx.eqZero(nextDown(-maxZero, 1)));
     }
 
     @Test
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 67a683a..07f3417 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
@@ -223,7 +223,7 @@ public class Vector1D extends EuclideanVector<Vector1D> {
     /** {@inheritDoc} */
     @Override
     public boolean equals(final Vector1D vec, final DoublePrecisionContext precision) {
-        return precision.areEqual(x, vec.x);
+        return precision.eq(x, vec.x);
     }
 
     /**
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
index b587eb2..a804725 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
@@ -158,7 +158,7 @@ public class Line implements Embedding<Vector3D, Vector1D> {
      */
     public boolean isSimilarTo(final Line line) {
         final double angle = direction.angle(line.direction);
-        return (precision.isZero(angle) || precision.areEqual(angle, Math.PI)) && contains(line.zero);
+        return (precision.eqZero(angle) || precision.eq(angle, Math.PI)) && contains(line.zero);
     }
 
     /** Check if the instance contains a point.
@@ -166,7 +166,7 @@ public class Line implements Embedding<Vector3D, Vector1D> {
      * @return true if p belongs to the line
      */
     public boolean contains(final Vector3D p) {
-        return precision.isZero(distance(p));
+        return precision.eqZero(distance(p));
     }
 
     /** Compute the distance between the instance and a point.
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
index 7bc7bc3..f390de6 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
@@ -277,8 +277,8 @@ public class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Vector2D
     public boolean isSimilarTo(final Plane plane) {
         final double angle = w.angle(plane.w);
 
-        return ((precision.isZero(angle)) && precision.areEqual(originOffset, plane.originOffset)) ||
-                ((precision.areEqual(angle, Math.PI)) && precision.areEqual(originOffset, -plane.originOffset));
+        return ((precision.eqZero(angle)) && precision.eq(originOffset, plane.originOffset)) ||
+                ((precision.eq(angle, Math.PI)) && precision.eq(originOffset, -plane.originOffset));
     }
 
     /** Rotate the plane around the specified point.
@@ -326,7 +326,7 @@ public class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Vector2D
     public Vector3D intersection(final Line line) {
         final Vector3D direction = line.getDirection();
         final double   dot       = w.dot(direction);
-        if (precision.isZero(dot)) {
+        if (precision.eqZero(dot)) {
             return null;
         }
         final Vector3D point = line.toSpace(Vector1D.ZERO);
@@ -341,7 +341,7 @@ public class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Vector2D
      */
     public Line intersection(final Plane other) {
         final Vector3D direction = w.cross(other.w);
-        if (precision.isZero(direction.norm())) {
+        if (precision.eqZero(direction.norm())) {
             return null;
         }
         final Vector3D point = intersection(this, other, new Plane(direction, precision));
@@ -412,7 +412,7 @@ public class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Vector2D
      * @return true if p belongs to the plane
      */
     public boolean contains(final Vector3D p) {
-        return precision.isZero(getOffset(p));
+        return precision.eqZero(getOffset(p));
     }
 
     /** Get the offset (oriented distance) of a parallel plane.
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
index 43d8ce6..6cdf088 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
@@ -151,7 +151,7 @@ public class PolyhedronsSet extends AbstractRegion<Vector3D, Vector2D> {
                                                       final double yMin, final double yMax,
                                                       final double zMin, final double zMax,
                                                       final DoublePrecisionContext precision) {
-        if (precision.areEqual(xMin, xMax) || precision.areEqual(yMin, yMax) || precision.areEqual(zMin, zMax)) {
+        if (precision.eq(xMin, xMax) || precision.eq(yMin, yMax) || precision.eq(zMin, zMax)) {
             // too thin box, build an empty polygons set
             return new BSPTree<>(Boolean.FALSE);
         }
@@ -181,7 +181,7 @@ public class PolyhedronsSet extends AbstractRegion<Vector3D, Vector2D> {
         for (int i = 0; i < vertices.size() - 1; ++i) {
             final Vector3D vi = vertices.get(i);
             for (int j = i + 1; j < vertices.size(); ++j) {
-                if (precision.isZero(vi.distance(vertices.get(j)))) {
+                if (precision.eqZero(vi.distance(vertices.get(j)))) {
                     throw new IllegalArgumentException("Vertices are too close near point " + vi);
                 }
             }
@@ -495,7 +495,7 @@ public class PolyhedronsSet extends AbstractRegion<Vector3D, Vector2D> {
 
         // establish search order
         final double offset = plane.getOffset(point);
-        final boolean in    = getPrecision().isZero(Math.abs(offset));
+        final boolean in    = getPrecision().eqZero(Math.abs(offset));
         final BSPTree<Vector3D> near;
         final BSPTree<Vector3D> far;
         if (offset < 0) {
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 e350ef7..232675c 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
@@ -374,9 +374,9 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
     /** {@inheritDoc} */
     @Override
     public boolean equals(final Vector3D vec, final DoublePrecisionContext precision) {
-        return precision.areEqual(x, vec.x) &&
-                precision.areEqual(y, vec.y) &&
-                precision.areEqual(z, vec.z);
+        return precision.eq(x, vec.x) &&
+                precision.eq(y, vec.y) &&
+                precision.eq(z, vec.z);
     }
 
     /**
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java
index c0bc87e..892b952 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java
@@ -231,7 +231,7 @@ public class Line implements Hyperplane<Vector2D>, Embedding<Vector2D, Vector1D>
      */
     public Vector2D intersection(final Line other) {
         final double d = LinearCombination.value(sin, other.cos, -other.sin, cos);
-        if (precision.isZero(d)) {
+        if (precision.eqZero(d)) {
             return null;
         }
         return Vector2D.of(LinearCombination.value(cos, other.originOffset, -other.cos, originOffset) / d,
@@ -311,7 +311,7 @@ public class Line implements Hyperplane<Vector2D>, Embedding<Vector2D, Vector1D>
      * @return true if p belongs to the line
      */
     public boolean contains(final Vector2D p) {
-        return precision.isZero(getOffset(p));
+        return precision.eqZero(getOffset(p));
     }
 
     /** Compute the distance between the instance and a point.
@@ -332,7 +332,7 @@ public class Line implements Hyperplane<Vector2D>, Embedding<Vector2D, Vector1D>
      * (they can have either the same or opposite orientations)
      */
     public boolean isParallelTo(final Line line) {
-        return precision.isZero(LinearCombination.value(sin, line.cos, -cos, line.sin));
+        return precision.eqZero(LinearCombination.value(sin, line.cos, -cos, line.sin));
     }
 
     /** Translate the line to force it passing by a point.
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java
index 119e456..2d43b1a 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java
@@ -154,7 +154,7 @@ public class PolygonsSet extends AbstractRegion<Vector2D, Vector1D> {
     private static Line[] boxBoundary(final double xMin, final double xMax,
                                       final double yMin, final double yMax,
                                       final DoublePrecisionContext precision) {
-        if (precision.areEqual(xMin, xMax) || precision.areEqual(yMin, yMax)) {
+        if (precision.eq(xMin, xMax) || precision.eq(yMin, yMax)) {
             // too thin box, build an empty polygons set
             return null;
         }
@@ -221,7 +221,7 @@ public class PolygonsSet extends AbstractRegion<Vector2D, Vector1D> {
             // check if another vertex also happens to be on this line
             for (final Vertex vertex : vArray) {
                 if (vertex != start && vertex != end &&
-                    precision.isZero(line.getOffset(vertex.getLocation()))) {
+                    precision.eqZero(line.getOffset(vertex.getLocation()))) {
                     vertex.bindWith(line);
                 }
             }
@@ -283,9 +283,9 @@ public class PolygonsSet extends AbstractRegion<Vector2D, Vector1D> {
             if (edge != inserted) {
                 final double startOffset = inserted.getLine().getOffset(edge.getStart().getLocation());
                 final double endOffset   = inserted.getLine().getOffset(edge.getEnd().getLocation());
-                Side startSide = precision.isZero(Math.abs(startOffset)) ?
+                Side startSide = precision.eqZero(Math.abs(startOffset)) ?
                                  Side.HYPER : ((startOffset < 0) ? Side.MINUS : Side.PLUS);
-                Side endSide   = precision.isZero(endOffset) ?
+                Side endSide   = precision.eqZero(endOffset) ?
                                  Side.HYPER : ((endOffset < 0) ? Side.MINUS : Side.PLUS);
                 switch (startSide) {
                     case PLUS:
@@ -781,7 +781,7 @@ public class PolygonsSet extends AbstractRegion<Vector2D, Vector1D> {
                         }
                     }
                 }
-                if (getPrecision().isZero(min)) {
+                if (getPrecision().eqZero(min)) {
                     // connect the two segments
                     segment.setNext(selectedNext);
                     selectedNext.setPrevious(segment);
@@ -1082,7 +1082,7 @@ public class PolygonsSet extends AbstractRegion<Vector2D, Vector1D> {
                     }
                 }
 
-                if (precision.isZero(min)) {
+                if (precision.eqZero(min)) {
                     return selected;
                 }
             }
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 582f66f..ccc7fe9 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
@@ -323,8 +323,8 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
     /** {@inheritDoc} */
     @Override
     public boolean equals(final Vector2D vec, final DoublePrecisionContext precision) {
-        return precision.areEqual(x, vec.x) &&
-                precision.areEqual(y, vec.y);
+        return precision.eq(x, vec.x) &&
+                precision.eq(y, vec.y);
     }
 
     /**
diff --git a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java
index 043b79f..80a1686 100644
--- a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java
+++ b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java
@@ -137,7 +137,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
         if (hull.size() == 1) {
             // ensure that we do not add an identical point
             final Vector2D p1 = hull.get(0);
-            if (precision.isZero(p1.distance(point))) {
+            if (precision.eqZero(p1.distance(point))) {
                 return;
             }
         }
@@ -148,11 +148,11 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
             final Vector2D p2 = hull.get(size - 1);
 
             final double offset = new Line(p1, p2, precision).getOffset(point);
-            if (precision.isZero(offset)) {
+            if (precision.eqZero(offset)) {
                 // the point is collinear to the line (p1, p2)
 
                 final double distanceToCurrent = p1.distance(point);
-                if (precision.isZero(distanceToCurrent) || precision.isZero(p2.distance(point))) {
+                if (precision.eqZero(distanceToCurrent) || precision.eqZero(p2.distance(point))) {
                     // the point is assumed to be identical to either p1 or p2
                     return;
                 }
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/ArcsSet.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/ArcsSet.java
index 01866f4..2e8cc23 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/ArcsSet.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/ArcsSet.java
@@ -818,7 +818,7 @@ public class ArcsSet extends AbstractRegion<S1Point, S1Point> implements Iterabl
                 final int    j  = (i + 1) % limits.size();
                 final double lA = limits.get(i);
                 final double lB = PlaneAngleRadians.normalize(limits.get(j), lA);
-                if (getPrecision().areEqual(lB, lA)) {
+                if (getPrecision().eq(lB, lA)) {
                     // the two limits are too close to each other, we remove both of them
                     if (j > 0) {
                         // regular case, the two entries are consecutive ones
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/Edge.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/Edge.java
index e662c41..fd0181e 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/Edge.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/Edge.java
@@ -206,7 +206,7 @@ public class Edge {
     private Vertex addSubEdge(final Vertex subStart, final Vertex subEnd, final double subLength,
                               final List<Edge> list, final Circle splitCircle) {
 
-        if (circle.getPrecision().isZero(subLength)) {
+        if (circle.getPrecision().eqZero(subLength)) {
             // the edge is too short, we ignore it
             return subStart;
         }
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 99c8814..6247eef 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
@@ -138,7 +138,7 @@ class EdgesBuilder implements BSPTreeVisitor<S2Point> {
 
         if (following == null) {
             final Vector3D previousStart = previous.getStart().getLocation().getVector();
-            if (precision.isZero(point.getVector().angle(previousStart))) {
+            if (precision.eqZero(point.getVector().angle(previousStart))) {
                 // the edge connects back to itself
                 return previous;
             }
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 ee7c29a..83df5a6 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
@@ -227,7 +227,7 @@ public class SphericalPolygonsSet extends AbstractRegion<S2Point, S1Point> {
             // check if another vertex also happens to be on this circle
             for (final Vertex vertex : vArray) {
                 if (vertex != start && vertex != end &&
-                    precision.isZero(circle.getOffset(vertex.getLocation()))) {
+                    precision.eqZero(circle.getOffset(vertex.getLocation()))) {
                     vertex.bindWith(circle);
                 }
             }
@@ -505,7 +505,7 @@ public class SphericalPolygonsSet extends AbstractRegion<S2Point, S1Point> {
         // convert to 3D sphere to spherical cap
         final double r = enclosing3D.getRadius();
         final double h = enclosing3D.getCenter().norm();
-        if (getPrecision().isZero(h)) {
+        if (getPrecision().eqZero(h)) {
             // the 3D sphere is centered on the unit sphere and covers it
             // fall back to a crude approximation, based only on outside convex cells
             EnclosingBall<S2Point> enclosingS2 =
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 58bdd27..bc8edca 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
@@ -53,7 +53,7 @@ public class SubCircle extends AbstractSubHyperplane<S2Point, S1Point> {
         final double angle = thisCircle.getPole().angle(otherCircle.getPole());
         final DoublePrecisionContext precision = thisCircle.getPrecision();
 
-        if (precision.isZero(angle) || precision.compare(angle, Math.PI) >= 0) {
+        if (precision.eqZero(angle) || precision.compare(angle, Math.PI) >= 0) {
             // the two circles are aligned or opposite
             return new SplitSubHyperplane<>(null, null);
         } else {


[commons-geometry] 03/03: Merge branch 'GEOMETRY-41__matt'

Posted by er...@apache.org.
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 5f7d21ac50533f8676483408d6a576bfe5e5fe26
Merge: 1f334d1 f6de918
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sun Feb 10 11:28:57 2019 +0100

    Merge branch 'GEOMETRY-41__matt'
    
    Closes #24.

 .../core/precision/DoublePrecisionContext.java     | 16 ++---
 .../core/precision/DoublePrecisionContextTest.java | 80 +++++++++++-----------
 .../EpsilonDoublePrecisionContextTest.java         | 12 ++--
 .../geometry/euclidean/EuclideanVector.java        | 30 ++++++++
 .../commons/geometry/euclidean/oned/Vector1D.java  |  7 ++
 .../commons/geometry/euclidean/threed/Line.java    |  4 +-
 .../commons/geometry/euclidean/threed/Plane.java   | 10 +--
 .../geometry/euclidean/threed/PolyhedronsSet.java  |  6 +-
 .../geometry/euclidean/threed/Vector3D.java        |  9 +++
 .../commons/geometry/euclidean/twod/Line.java      |  6 +-
 .../geometry/euclidean/twod/PolygonsSet.java       | 12 ++--
 .../commons/geometry/euclidean/twod/Vector2D.java  |  8 +++
 .../geometry/euclidean/oned/Vector1DTest.java      | 44 ++++++++++++
 .../geometry/euclidean/threed/Vector3DTest.java    | 62 +++++++++++++++++
 .../geometry/euclidean/twod/Vector2DTest.java      | 52 ++++++++++++++
 .../euclidean/twod/hull/MonotoneChain.java         |  6 +-
 .../commons/geometry/spherical/oned/ArcsSet.java   |  2 +-
 .../commons/geometry/spherical/twod/Edge.java      |  2 +-
 .../geometry/spherical/twod/EdgesBuilder.java      |  2 +-
 .../spherical/twod/SphericalPolygonsSet.java       |  4 +-
 .../commons/geometry/spherical/twod/SubCircle.java |  2 +-
 21 files changed, 295 insertions(+), 81 deletions(-)