This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit b87f6399edf6a037440190492c16415cd892efd5 Author: Andreas <andreas.goss1...@gmail.com> AuthorDate: Sat Aug 12 20:27:15 2023 +0200 GEOMETRY-144 Cases are not needed since the given Collection of points is a PointSet. --- .../geometry/euclidean/twod/hull/ConvexHull2D.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHull2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHull2D.java index 62ec349e..1ae6381f 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHull2D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHull2D.java @@ -378,11 +378,6 @@ public final class ConvexHull2D implements ConvexHull<Vector2D> { hullVertices.add(upperHull.get(idx)); } - // special case: if the lower and upper hull may contain only 1 point if all are identical - if (hullVertices.isEmpty() && !lowerHull.isEmpty()) { - hullVertices.add(lowerHull.get(0)); - } - return hullVertices; } @@ -401,14 +396,10 @@ public final class ConvexHull2D implements ConvexHull<Vector2D> { final double offset = Lines.fromPoints(p1, p2, precision).offset(point); if (precision.eqZero(offset)) { // the point is collinear to the line (p1, p2) + // Calculate distance to both points. + final double distanceToCurrent = p1.distance(point); + final double distanceToLast = p1.distance(p2); - final double distanceToCurrent = p1.distance(point); - if (precision.eqZero(distanceToCurrent) || precision.eqZero(p2.distance(point))) { - // the point is assumed to be identical to either p1 or p2 - return; - } - - final double distanceToLast = p1.distance(p2); if (includeCollinearPoints) { final int index = distanceToCurrent < distanceToLast ? size - 1 : size; hull.add(index, point);