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 edfea212a2766fbaa540d24cd5dad13af234fd5c Author: Andreas <andreas.goss1...@gmail.com> AuthorDate: Sat Aug 12 20:49:17 2023 +0200 GEOMETRY-144 Checkstyle fix. --- .../geometry/euclidean/twod/hull/ConvexHull2D.java | 13 ++-- .../euclidean/twod/hull/ConvexHullBuilderTest.java | 84 +++++++++++----------- 2 files changed, 48 insertions(+), 49 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 1ae6381f..e6084e7e 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 @@ -142,7 +142,7 @@ public final class ConvexHull2D implements ConvexHull<Vector2D> { /** Collection of all remaining candidates for a convex hull. */ private final PointSet<Vector2D> candidates; - /** Points are tested against this quadrilateral */ + /** Points are tested against this quadrilateral. */ private final List<Vector2D> quadrilateral; /** A precision context for comparing points. */ @@ -184,8 +184,8 @@ public final class ConvexHull2D implements ConvexHull<Vector2D> { buildQuadrilateral(minY, maxX, maxY, minX); // if the quadrilateral is not well formed, e.g. only 2 points, do not attempt to reduce if (quadrilateral.size() < 3) { - //Point cannot yet be dismissed. - candidates.add(point); + // Point cannot yet be dismissed. + candidates.add(point); return this; } @@ -237,7 +237,6 @@ public final class ConvexHull2D implements ConvexHull<Vector2D> { * coordinates). * * @param points the respective points with min/max x/y coordinate - * @return the quadrilateral */ private void buildQuadrilateral(final Vector2D... points) { quadrilateral.clear(); @@ -396,9 +395,9 @@ 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); + // Calculate distance to both points. + final double distanceToCurrent = p1.distance(point); + final double distanceToLast = p1.distance(p2); if (includeCollinearPoints) { final int index = distanceToCurrent < distanceToLast ? size - 1 : size; diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullBuilderTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullBuilderTest.java index 249ee015..cd82e59b 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullBuilderTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullBuilderTest.java @@ -232,39 +232,39 @@ class ConvexHullBuilderTest { @Test void testCollinearPointsIncludedColinearToFirstSide() { - // arrange - final Collection<Vector2D> points = new ArrayList<>(); - points.add(Vector2D.of(1, 1)); - points.add(Vector2D.of(2, 4)); - points.add(Vector2D.of(10, 1)); - points.add(Vector2D.of(1.5, 2.5)); - - // act - ConvexHull2D.Builder builder = createConvexHullGenerator(true); - builder.append(points); - final ConvexHull2D hull = builder.build(); - - // assert - checkConvexHull(points, hull, true); + // arrange + final Collection<Vector2D> points = new ArrayList<>(); + points.add(Vector2D.of(1, 1)); + points.add(Vector2D.of(2, 4)); + points.add(Vector2D.of(10, 1)); + points.add(Vector2D.of(1.5, 2.5)); + + // act + ConvexHull2D.Builder builder = createConvexHullGenerator(true); + builder.append(points); + final ConvexHull2D hull = builder.build(); + + // assert + checkConvexHull(points, hull, true); } @Test void testCollinearPointsExcludedColinearToFirstSide() { - // arrange - final Collection<Vector2D> points = new ArrayList<>(); - points.add(Vector2D.of(1, 1)); - points.add(Vector2D.of(2, 4)); - points.add(Vector2D.of(10, 1)); - points.add(Vector2D.of(1.5, 2.5)); - - // act - ConvexHull2D.Builder builder = createConvexHullGenerator(false); - builder.append(points); - final ConvexHull2D hull = builder.build(); - - points.remove(Vector2D.of(1.5, 2.5)); - // assert - checkConvexHull(points, hull, false); + // arrange + final Collection<Vector2D> points = new ArrayList<>(); + points.add(Vector2D.of(1, 1)); + points.add(Vector2D.of(2, 4)); + points.add(Vector2D.of(10, 1)); + points.add(Vector2D.of(1.5, 2.5)); + + // act + ConvexHull2D.Builder builder = createConvexHullGenerator(false); + builder.append(points); + final ConvexHull2D hull = builder.build(); + + points.remove(Vector2D.of(1.5, 2.5)); + // assert + checkConvexHull(points, hull, false); } @Test @@ -324,19 +324,19 @@ class ConvexHullBuilderTest { @Test void testOrderisIrrelevant() { - // arrange - final Collection<Vector2D> points = new ArrayList<>(); - points.add(Vector2D.of(0, 0)); - points.add(Vector2D.of(6, 6)); - points.add(Vector2D.of(3, 4)); - points.add(Vector2D.of(12, 0)); - - // act - generator.append(points); - final ConvexHull2D hull = generator.build(); - - // assert - checkConvexHull(points, hull); + // arrange + final Collection<Vector2D> points = new ArrayList<>(); + points.add(Vector2D.of(0, 0)); + points.add(Vector2D.of(6, 6)); + points.add(Vector2D.of(3, 4)); + points.add(Vector2D.of(12, 0)); + + // act + generator.append(points); + final ConvexHull2D hull = generator.build(); + + // assert + checkConvexHull(points, hull); } @Test