You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2020/02/18 00:42:11 UTC

[commons-geometry] branch master updated (ead4022 -> f84ae36)

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

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


    from ead4022  Add spot bugs exclusions.
     new 0880ae3  Allow 1 as a magic number
     new be3fbe9  Use final
     new 826ff88  Remove redundant field initialisers
     new f84ae36  Remove unnecessary else clauses.

The 4 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/partitioning/bsp/AbstractBSPTree.java     |   2 +-
 .../commons/geometry/enclosing/WelzlEncloser.java  |   2 +-
 .../euclidean/threed/SphereGenerator.java          | 164 ++++++++++-----------
 .../enclosing/euclidean/twod/DiskGenerator.java    | 113 +++++++-------
 .../euclidean/internal/AbstractPathConnector.java  |   8 +-
 .../geometry/euclidean/oned/OrientedPoint.java     |   2 +-
 .../geometry/euclidean/oned/RegionBSPTree1D.java   |  18 +--
 .../geometry/euclidean/threed/ConvexVolume.java    |   2 +-
 .../commons/geometry/euclidean/threed/Line3D.java  |   2 +-
 .../geometry/euclidean/threed/LinecastPoint3D.java |   2 +-
 .../commons/geometry/euclidean/threed/Plane.java   |  38 ++---
 .../geometry/euclidean/threed/RegionBSPTree3D.java |  28 ++--
 .../geometry/euclidean/threed/SubLine3D.java       |   2 +-
 .../geometry/euclidean/threed/Vector3D.java        |  10 +-
 .../threed/rotation/QuaternionRotation.java        |  10 +-
 .../euclidean/threed/shapes/Parallelepiped.java    |   1 -
 .../euclidean/twod/AbstractSegmentConnector.java   |   8 +-
 .../geometry/euclidean/twod/ConvexArea.java        |   8 +-
 .../twod/InteriorAngleSegmentConnector.java        |   4 +-
 .../commons/geometry/euclidean/twod/Line.java      |   2 +-
 .../geometry/euclidean/twod/LinecastPoint2D.java   |   2 +-
 .../commons/geometry/euclidean/twod/Polyline.java  |   8 +-
 .../geometry/euclidean/twod/RegionBSPTree2D.java   |  12 +-
 .../commons/geometry/euclidean/twod/Vector2D.java  |   6 +-
 .../twod/AbstractConvexHullGenerator2D.java        |   4 +-
 .../hull/euclidean/twod/AklToussaintHeuristic.java |   8 +-
 .../hull/euclidean/twod/MonotoneChain.java         |   2 +-
 .../geometry/spherical/oned/RegionBSPTree1S.java   |  18 +--
 .../spherical/twod/AbstractGreatArcConnector.java  |   8 +-
 .../geometry/spherical/twod/ConvexArea2S.java      |  10 +-
 .../geometry/spherical/twod/GreatArcPath.java      |   6 +-
 .../geometry/spherical/twod/GreatCircle.java       |   2 +-
 .../twod/InteriorAngleGreatArcConnector.java       |   4 +-
 .../geometry/spherical/twod/RegionBSPTree2S.java   |  10 +-
 src/main/resources/pmd/pmd-ruleset.xml             |   6 +
 35 files changed, 265 insertions(+), 267 deletions(-)


[commons-geometry] 02/04: Use final

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit be3fbe9b95856d196bcf3a8a2ad948345b40eb11
Author: Alex Herbert <a....@sussex.ac.uk>
AuthorDate: Tue Feb 18 00:33:56 2020 +0000

    Use final
---
 .../commons/geometry/enclosing/WelzlEncloser.java  |  2 +-
 .../euclidean/internal/AbstractPathConnector.java  |  6 ++--
 .../geometry/euclidean/oned/OrientedPoint.java     |  2 +-
 .../geometry/euclidean/oned/RegionBSPTree1D.java   | 10 +++---
 .../geometry/euclidean/threed/ConvexVolume.java    |  2 +-
 .../commons/geometry/euclidean/threed/Line3D.java  |  2 +-
 .../geometry/euclidean/threed/LinecastPoint3D.java |  2 +-
 .../commons/geometry/euclidean/threed/Plane.java   | 38 +++++++++++-----------
 .../geometry/euclidean/threed/RegionBSPTree3D.java | 28 ++++++++--------
 .../geometry/euclidean/threed/SubLine3D.java       |  2 +-
 .../geometry/euclidean/threed/Vector3D.java        | 10 +++---
 .../threed/rotation/QuaternionRotation.java        | 10 +++---
 .../euclidean/threed/shapes/Parallelepiped.java    |  1 -
 .../euclidean/twod/AbstractSegmentConnector.java   |  8 ++---
 .../geometry/euclidean/twod/ConvexArea.java        |  8 ++---
 .../twod/InteriorAngleSegmentConnector.java        |  4 +--
 .../commons/geometry/euclidean/twod/Line.java      |  2 +-
 .../geometry/euclidean/twod/LinecastPoint2D.java   |  2 +-
 .../commons/geometry/euclidean/twod/Polyline.java  |  8 ++---
 .../geometry/euclidean/twod/RegionBSPTree2D.java   | 12 +++----
 .../commons/geometry/euclidean/twod/Vector2D.java  |  6 ++--
 .../twod/AbstractConvexHullGenerator2D.java        |  4 +--
 .../hull/euclidean/twod/AklToussaintHeuristic.java |  8 ++---
 .../hull/euclidean/twod/MonotoneChain.java         |  2 +-
 .../geometry/spherical/oned/RegionBSPTree1S.java   | 18 +++++-----
 .../spherical/twod/AbstractGreatArcConnector.java  |  8 ++---
 .../geometry/spherical/twod/ConvexArea2S.java      | 10 +++---
 .../geometry/spherical/twod/GreatArcPath.java      |  6 ++--
 .../geometry/spherical/twod/GreatCircle.java       |  2 +-
 .../twod/InteriorAngleGreatArcConnector.java       |  4 +--
 .../geometry/spherical/twod/RegionBSPTree2S.java   | 10 +++---
 31 files changed, 118 insertions(+), 119 deletions(-)

diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/WelzlEncloser.java b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/WelzlEncloser.java
index 45f4547..9f9f772 100755
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/WelzlEncloser.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/WelzlEncloser.java
@@ -94,7 +94,7 @@ public class WelzlEncloser<P extends Point<P>> implements Encloser<P> {
             // recurse search, restricted to the small subset containing support and farthest point
             support.clear();
             support.add(farthest);
-            EnclosingBall<P> savedBall = ball;
+            final EnclosingBall<P> savedBall = ball;
             ball = moveToFrontBall(extreme, extreme.size(), support);
             if (precision.lt(ball.getRadius(), savedBall.getRadius())) {
                 // this should never happen
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java
index 1ab732d..cb94308 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java
@@ -99,7 +99,7 @@ public abstract class AbstractPathConnector<E extends AbstractPathConnector.Conn
             followForwardConnections(segment);
         }
 
-        List<E> rootEntries = new ArrayList<>();
+        final List<E> rootEntries = new ArrayList<>();
         E root;
         for (final E segment : pathElements) {
             root = segment.exportPath();
@@ -167,7 +167,7 @@ public abstract class AbstractPathConnector<E extends AbstractPathConnector.Conn
             final E searchKey = element.getConnectionSearchKey();
 
             // search up
-            for (E candidate : pathElements.tailSet(searchKey)) {
+            for (final E candidate : pathElements.tailSet(searchKey)) {
                 if (!addPossibleConnection(element, candidate) &&
                         !element.shouldContinueConnectionSearch(candidate, true)) {
                     break;
@@ -175,7 +175,7 @@ public abstract class AbstractPathConnector<E extends AbstractPathConnector.Conn
             }
 
             // search down
-            for (E candidate : pathElementsDescending.tailSet(searchKey, false)) {
+            for (final E candidate : pathElementsDescending.tailSet(searchKey, false)) {
                 if (!addPossibleConnection(element, candidate) &&
                         !element.shouldContinueConnectionSearch(candidate, false)) {
                     break;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java
index 4973dca..704c0ab 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java
@@ -222,7 +222,7 @@ public final class OrientedPoint extends AbstractHyperplane<Vector1D>
             return false;
         }
 
-        OrientedPoint other = (OrientedPoint) obj;
+        final OrientedPoint other = (OrientedPoint) obj;
 
         return Objects.equals(this.point, other.point) &&
                 this.positiveFacing == other.positiveFacing &&
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
index b326213..fe19261 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
@@ -57,7 +57,7 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
      * @see #copy(org.apache.commons.geometry.core.partitioning.bsp.BSPTree)
      */
     public RegionBSPTree1D copy() {
-        RegionBSPTree1D result = RegionBSPTree1D.empty();
+        final RegionBSPTree1D result = RegionBSPTree1D.empty();
         result.copy(this);
 
         return result;
@@ -183,7 +183,7 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
         BoundaryPair start = null;
         BoundaryPair end = null;
 
-        for (BoundaryPair current : boundaryPairs) {
+        for (final BoundaryPair current : boundaryPairs) {
             if (start == null) {
                 start = current;
                 end = current;
@@ -239,7 +239,7 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
      *      insides node's convex region
      */
     private void visitInsideIntervals(final BiConsumer<OrientedPoint, OrientedPoint> visitor) {
-        for (RegionNode1D node : nodes()) {
+        for (final RegionNode1D node : nodes()) {
             if (node.isInside()) {
                 node.visitNodeInterval(visitor);
             }
@@ -255,7 +255,7 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
     /** {@inheritDoc} */
     @Override
     protected RegionSizeProperties<Vector1D> computeRegionSizeProperties() {
-        RegionSizePropertiesVisitor visitor = new RegionSizePropertiesVisitor();
+        final RegionSizePropertiesVisitor visitor = new RegionSizePropertiesVisitor();
 
         visitInsideIntervals(visitor);
 
@@ -309,7 +309,7 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
      * @return a new instance constructed from the given collection of intervals
      */
     public static RegionBSPTree1D from(final Iterable<Interval> intervals) {
-        RegionBSPTree1D tree = new RegionBSPTree1D(false);
+        final RegionBSPTree1D tree = new RegionBSPTree1D(false);
 
         for (final Interval interval : intervals) {
             tree.add(interval);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java
index ac1a702..6631054 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java
@@ -108,7 +108,7 @@ public final class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Ve
         }
 
         if (volumeSum > 0) {
-            double size = volumeSum / 3.0;
+            final double size = volumeSum / 3.0;
 
             // Since the volume we used when adding together the facet contributions
             // was 3x the actual pyramid size, we'll multiply by 1/4 here instead
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line3D.java
index 5eb1f0b..c44d9ff 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line3D.java
@@ -347,7 +347,7 @@ public final class Line3D implements Embedding<Vector3D, Vector1D> {
         if (!(obj instanceof Line3D)) {
             return false;
         }
-        Line3D other = (Line3D) obj;
+        final Line3D other = (Line3D) obj;
         return this.origin.equals(other.origin) &&
                 this.direction.equals(other.direction) &&
                 this.precision.equals(other.precision);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/LinecastPoint3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/LinecastPoint3D.java
index cc1e6e4..35f5d66 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/LinecastPoint3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/LinecastPoint3D.java
@@ -105,7 +105,7 @@ public class LinecastPoint3D extends AbstractLinecastPoint<Vector3D, Vector3D.Un
     private static boolean containsEq(final LinecastPoint3D pt, final List<LinecastPoint3D> list) {
         final DoublePrecisionContext precision = pt.getLine().getPrecision();
 
-        for (LinecastPoint3D listPt : list) {
+        for (final LinecastPoint3D listPt : list) {
             if (listPt.eq(pt, precision)) {
                 return true;
             }
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 e094856..e124c58 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
@@ -162,12 +162,12 @@ public final class Plane extends AbstractHyperplane<Vector3D>
      * @return the projection of the given line onto the plane.
      */
     public Line3D project(final Line3D line) {
-        Vector3D direction = line.getDirection();
-        Vector3D projection = w.multiply(direction.dot(w) * (1 / w.normSq()));
+        final Vector3D direction = line.getDirection();
+        final Vector3D projection = w.multiply(direction.dot(w) * (1 / w.normSq()));
 
-        Vector3D projectedLineDirection = direction.subtract(projection);
-        Vector3D p1 = project(line.getOrigin());
-        Vector3D p2 = p1.add(projectedLineDirection);
+        final Vector3D projectedLineDirection = direction.subtract(projection);
+        final Vector3D p1 = project(line.getOrigin());
+        final Vector3D p2 = p1.add(projectedLineDirection);
 
         return Line3D.fromPoints(p1, p2, getPrecision());
     }
@@ -300,10 +300,10 @@ public final class Plane extends AbstractHyperplane<Vector3D>
      * @return a new plane
      */
     public Plane translate(final Vector3D translation) {
-        Vector3D p = getOrigin().add(translation);
-        Vector3D normal = this.w;
-        Vector3D wTmp = normal.normalize();
-        double originOffsetTmp = -p.dot(wTmp);
+        final Vector3D p = getOrigin().add(translation);
+        final Vector3D normal = this.w;
+        final Vector3D wTmp = normal.normalize();
+        final double originOffsetTmp = -p.dot(wTmp);
 
         return new Plane(this.u, this.v, wTmp, originOffsetTmp, getPrecision());
     }
@@ -538,7 +538,7 @@ public final class Plane extends AbstractHyperplane<Vector3D>
             return false;
         }
 
-        Plane other = (Plane) obj;
+        final Plane other = (Plane) obj;
 
         return Objects.equals(this.u, other.u) &&
                 Objects.equals(this.v, other.v) &&
@@ -576,10 +576,10 @@ public final class Plane extends AbstractHyperplane<Vector3D>
      */
     public static Plane fromPointAndPlaneVectors(final Vector3D p, final Vector3D u, final Vector3D v,
             final DoublePrecisionContext precision) {
-        Vector3D uNorm = u.normalize();
-        Vector3D vNorm = uNorm.orthogonal(v);
-        Vector3D wNorm = uNorm.cross(vNorm).normalize();
-        double originOffset = -p.dot(wNorm);
+        final Vector3D uNorm = u.normalize();
+        final Vector3D vNorm = uNorm.orthogonal(v);
+        final Vector3D wNorm = uNorm.cross(vNorm).normalize();
+        final double originOffset = -p.dot(wNorm);
 
         return new Plane(uNorm, vNorm, wNorm, originOffset, precision);
     }
@@ -607,11 +607,11 @@ public final class Plane extends AbstractHyperplane<Vector3D>
      */
     public static Plane fromPointAndNormal(final Vector3D p, final Vector3D normal,
             final DoublePrecisionContext precision) {
-        Vector3D w = normal.normalize();
-        double originOffset = -p.dot(w);
+        final Vector3D w = normal.normalize();
+        final double originOffset = -p.dot(w);
 
-        Vector3D u = w.orthogonal();
-        Vector3D v = w.cross(u);
+        final Vector3D u = w.orthogonal();
+        final Vector3D v = w.cross(u);
 
         return new Plane(u, v, w, originOffset, precision);
     }
@@ -656,7 +656,7 @@ public final class Plane extends AbstractHyperplane<Vector3D>
 
         final Iterator<Vector3D> it = pts.iterator();
 
-        Vector3D startPt = it.next();
+        final Vector3D startPt = it.next();
 
         Vector3D u = null;
         Vector3D w = null;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
index 39a478f..3c424d1 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
@@ -57,7 +57,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
      * @see #copy(org.apache.commons.geometry.core.partitioning.bsp.BSPTree)
      */
     public RegionBSPTree3D copy() {
-        RegionBSPTree3D result = RegionBSPTree3D.empty();
+        final RegionBSPTree3D result = RegionBSPTree3D.empty();
         result.copy(this);
 
         return result;
@@ -112,7 +112,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
             }
         } else {
             // recurse
-            Split<ConvexVolume> split = nodeVolume.split(node.getCutHyperplane());
+            final Split<ConvexVolume> split = nodeVolume.split(node.getCutHyperplane());
 
             toConvexRecursive(node.getMinus(), split.getMinus(), result);
             toConvexRecursive(node.getPlus(), split.getPlus(), result);
@@ -164,7 +164,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
             return new RegionSizeProperties<>(0, null);
         }
 
-        RegionSizePropertiesVisitor visitor = new RegionSizePropertiesVisitor();
+        final RegionSizePropertiesVisitor visitor = new RegionSizePropertiesVisitor();
         accept(visitor);
 
         return visitor.getRegionSizeProperties();
@@ -196,7 +196,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
      * @return a new tree instance constructed from the given boundaries
      */
     public static RegionBSPTree3D from(final Iterable<Facet> boundaries) {
-        RegionBSPTree3D tree = RegionBSPTree3D.full();
+        final RegionBSPTree3D tree = RegionBSPTree3D.full();
         tree.insert(boundaries);
 
         return tree;
@@ -209,7 +209,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
      *      given source
      */
     public static RegionBSPTree3D from(final BoundarySource<Facet> boundarySrc) {
-        RegionBSPTree3D tree = RegionBSPTree3D.full();
+        final RegionBSPTree3D tree = RegionBSPTree3D.full();
         tree.insert(boundarySrc);
 
         return tree;
@@ -237,7 +237,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
             RegionNode3D parent;
 
             while ((parent = child.getParent()) != null) {
-                Split<ConvexVolume> split = volume.split(parent.getCutHyperplane());
+                final Split<ConvexVolume> split = volume.split(parent.getCutHyperplane());
 
                 volume = child.isMinus() ? split.getMinus() : split.getPlus();
 
@@ -305,7 +305,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
         @Override
         public Result visit(final RegionNode3D node) {
             if (node.isInternal()) {
-                RegionCutBoundary<Vector3D> boundary = node.getCutBoundary();
+                final RegionCutBoundary<Vector3D> boundary = node.getCutBoundary();
                 addFacetContribution(boundary.getOutsideFacing(), false);
                 addFacetContribution(boundary.getInsideFacing(), true);
             }
@@ -345,17 +345,17 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
          * @param reverse if true, the facet contribution is reversed before being added to the total.
          */
         private void addFacetContribution(final SubHyperplane<Vector3D> boundary, boolean reverse) {
-            SubPlane subplane = (SubPlane) boundary;
-            RegionBSPTree2D base = subplane.getSubspaceRegion();
+            final SubPlane subplane = (SubPlane) boundary;
+            final RegionBSPTree2D base = subplane.getSubspaceRegion();
 
-            double area = base.getSize();
-            Vector2D baseBarycenter = base.getBarycenter();
+            final double area = base.getSize();
+            final Vector2D baseBarycenter = base.getBarycenter();
 
             if (Double.isInfinite(area)) {
                 volumeSum = Double.POSITIVE_INFINITY;
             } else if (baseBarycenter != null) {
-                Plane plane = subplane.getPlane();
-                Vector3D facetBarycenter = plane.toSpace(base.getBarycenter());
+                final Plane plane = subplane.getPlane();
+                final Vector3D facetBarycenter = plane.toSpace(base.getBarycenter());
 
                 // the volume here is actually 3x the actual pyramid volume; we'll apply
                 // the final scaling all at once at the end
@@ -452,7 +452,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
                     } else if (linecastSegment.contains(pt)) {
                         // we've potentially found a new linecast point; add it to the list of potential
                         // results
-                        LinecastPoint3D potentialResult = computeLinecastPoint(pt, node);
+                        final LinecastPoint3D potentialResult = computeLinecastPoint(pt, node);
                         if (potentialResult != null) {
                             results.add(potentialResult);
 
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine3D.java
index 740931e..925da52 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine3D.java
@@ -86,7 +86,7 @@ public final class SubLine3D extends AbstractSubLine3D<RegionBSPTree1D> {
         final Line3D line = getLine();
         final List<Segment3D> segments = new ArrayList<>(intervals.size());
 
-        for (Interval interval : intervals) {
+        for (final Interval interval : intervals) {
             segments.add(Segment3D.fromInterval(line, interval));
         }
 
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 0961718..2982ea8 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
@@ -292,13 +292,13 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
      */
     @Override
     public double angle(final Vector3D v) {
-        double normProduct = getCheckedNorm() * v.getCheckedNorm();
+        final double normProduct = getCheckedNorm() * v.getCheckedNorm();
 
-        double dot = dot(v);
-        double threshold = normProduct * 0.99;
+        final double dot = dot(v);
+        final double threshold = normProduct * 0.99;
         if ((dot < -threshold) || (dot > threshold)) {
             // the vectors are almost aligned, compute using the sine
-            Vector3D cross = cross(v);
+            final Vector3D cross = cross(v);
             if (dot >= 0) {
                 return Math.asin(cross.norm() / normProduct);
             }
@@ -339,7 +339,7 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
      */
     @Override
     public Vector3D.Unit orthogonal() {
-        double threshold = 0.6 * getCheckedNorm();
+        final double threshold = 0.6 * getCheckedNorm();
 
         double inverse;
         if (Math.abs(x) <= threshold) {
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java
index dc351ed..807f0e2 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java
@@ -287,7 +287,7 @@ public final class QuaternionRotation implements Rotation3D {
             throw new IllegalArgumentException("Axis sequence cannot be null");
         }
 
-        double[] angles = getAngles(frame, axes);
+        final double[] angles = getAngles(frame, axes);
 
         return new AxisAngleSequence(frame, axes, angles[0], angles[1], angles[2]);
     }
@@ -328,7 +328,7 @@ public final class QuaternionRotation implements Rotation3D {
             return false;
         }
 
-        QuaternionRotation other = (QuaternionRotation) obj;
+        final QuaternionRotation other = (QuaternionRotation) obj;
         return Objects.equals(this.quat, other.quat);
     }
 
@@ -347,7 +347,7 @@ public final class QuaternionRotation implements Rotation3D {
      */
     private double[] getAngles(final AxisReferenceFrame frame, final AxisSequence axes) {
 
-        AxisSequenceType sequenceType = axes.getType();
+        final AxisSequenceType sequenceType = axes.getType();
 
         final Vector3D axis1 = axes.getAxis1();
         final Vector3D axis2 = axes.getAxis2();
@@ -605,8 +605,8 @@ public final class QuaternionRotation implements Rotation3D {
      */
     public static QuaternionRotation createVectorRotation(final Vector3D u, final Vector3D v) {
 
-        double normProduct  = Vectors.checkedNorm(u) * Vectors.checkedNorm(v);
-        double dot = u.dot(v);
+        final double normProduct  = Vectors.checkedNorm(u) * Vectors.checkedNorm(v);
+        final double dot = u.dot(v);
 
         if (dot < ANTIPARALLEL_DOT_THRESHOLD * normProduct) {
             // Special case where u1 = -u2:
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/shapes/Parallelepiped.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/shapes/Parallelepiped.java
index e2355fa..ccf1ba5 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/shapes/Parallelepiped.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/shapes/Parallelepiped.java
@@ -20,7 +20,6 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
-import org.apache.commons.geometry.euclidean.threed.Facet;
 import org.apache.commons.geometry.euclidean.threed.Vector3D;
 
 /** Class containing utility methods for constructing parallelepipeds. Parallelepipeds
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnector.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnector.java
index aca9b94..e6d21b3 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnector.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnector.java
@@ -47,7 +47,7 @@ public abstract class AbstractSegmentConnector
      * @see #add(Segment)
      */
     public void add(final Iterable<Segment> segments) {
-        for (Segment segment : segments) {
+        for (final Segment segment : segments) {
             add(segment);
         }
     }
@@ -63,9 +63,9 @@ public abstract class AbstractSegmentConnector
      * @see #connectAll()
      */
     public void connect(final Iterable<Segment> segments) {
-        List<ConnectableSegment> newEntries = new ArrayList<>();
+        final List<ConnectableSegment> newEntries = new ArrayList<>();
 
-        for (Segment segment : segments) {
+        for (final Segment segment : segments) {
             newEntries.add(new ConnectableSegment(segment));
         }
 
@@ -104,7 +104,7 @@ public abstract class AbstractSegmentConnector
         final List<ConnectableSegment> roots = computePathRoots();
         final List<Polyline> paths = new ArrayList<>(roots.size());
 
-        for (ConnectableSegment root : roots) {
+        for (final ConnectableSegment root : roots) {
             paths.add(toPolyline(root));
         }
 
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java
index f65f4fa..b9ad8c0 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java
@@ -111,7 +111,7 @@ public final class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vect
 
         double quadrilateralAreaSum = 0.0;
 
-        for (Segment segment : getBoundaries()) {
+        for (final Segment segment : getBoundaries()) {
             if (segment.isInfinite()) {
                 return Double.POSITIVE_INFINITY;
             }
@@ -125,7 +125,7 @@ public final class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vect
     /** {@inheritDoc} */
     @Override
     public Vector2D getBarycenter() {
-        List<Segment> boundaries = getBoundaries();
+        final List<Segment> boundaries = getBoundaries();
 
         double quadrilateralAreaSum = 0.0;
         double scaledSumX = 0.0;
@@ -135,7 +135,7 @@ public final class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vect
         Vector2D startPoint;
         Vector2D endPoint;
 
-        for (Segment seg : boundaries) {
+        for (final Segment seg : boundaries) {
             if (seg.isInfinite()) {
                 // infinite => no barycenter
                 return null;
@@ -230,7 +230,7 @@ public final class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vect
         Vector2D prev = null;
         Vector2D cur = null;
 
-        for (Vector2D vertex : vertices) {
+        for (final Vector2D vertex : vertices) {
             cur = vertex;
 
             if (first == null) {
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnector.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnector.java
index 67f6e2d..d43f0c4 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnector.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnector.java
@@ -44,8 +44,8 @@ public abstract class InteriorAngleSegmentConnector extends AbstractSegmentConne
         double selectedInteriorAngle = Double.POSITIVE_INFINITY;
         ConnectableSegment selected = null;
 
-        for (ConnectableSegment candidate : outgoing) {
-            double interiorAngle = PlaneAngleRadians.PI - segmentLine.angle(candidate.getSegment().getLine());
+        for (final ConnectableSegment candidate : outgoing) {
+            final double interiorAngle = PlaneAngleRadians.PI - segmentLine.angle(candidate.getSegment().getLine());
 
             if (selected == null || isBetterAngle(interiorAngle, selectedInteriorAngle)) {
                 selectedInteriorAngle = interiorAngle;
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 a893206..9ca8807 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
@@ -468,7 +468,7 @@ public final class Line extends AbstractHyperplane<Vector2D>
             return false;
         }
 
-        Line other = (Line) obj;
+        final Line other = (Line) obj;
 
         return Objects.equals(this.direction, other.direction) &&
                 Double.compare(this.originOffset, other.originOffset) == 0 &&
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LinecastPoint2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LinecastPoint2D.java
index d175330..1088b1d 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LinecastPoint2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LinecastPoint2D.java
@@ -104,7 +104,7 @@ public class LinecastPoint2D extends AbstractLinecastPoint<Vector2D, Vector2D.Un
     private static boolean containsEq(final LinecastPoint2D pt, final List<LinecastPoint2D> list) {
         final DoublePrecisionContext precision = pt.getLine().getPrecision();
 
-        for (LinecastPoint2D listPt : list) {
+        for (final LinecastPoint2D listPt : list) {
             if (listPt.eq(pt, precision)) {
                 return true;
             }
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java
index 9e0d926..b5b28c6 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Polyline.java
@@ -118,7 +118,7 @@ public class Polyline implements BoundarySource2D, Linecastable2D {
         }
 
         // add end points
-        for (Segment seg : segments) {
+        for (final Segment seg : segments) {
             pt = seg.getEndPoint();
             if (pt != null) {
                 vertices.add(pt);
@@ -368,9 +368,9 @@ public class Polyline implements BoundarySource2D, Linecastable2D {
      * @throws IllegalStateException if the segments do not form a connected polyline
      */
     public static Polyline fromSegments(final Collection<Segment> segments) {
-        Builder builder = builder(null);
+        final Builder builder = builder(null);
 
-        for (Segment segment : segments) {
+        for (final Segment segment : segments) {
             builder.append(segment);
         }
 
@@ -556,7 +556,7 @@ public class Polyline implements BoundarySource2D, Linecastable2D {
          * @see #append(Vector2D)
          */
         public Builder appendVertices(final Collection<Vector2D> vertices) {
-            for (Vector2D vertex : vertices) {
+            for (final Vector2D vertex : vertices) {
                 append(vertex);
             }
 
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java
index 68146ee..77d74fc 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java
@@ -60,7 +60,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
      * @see #copy(org.apache.commons.geometry.core.partitioning.bsp.BSPTree)
      */
     public RegionBSPTree2D copy() {
-        RegionBSPTree2D result = RegionBSPTree2D.empty();
+        final RegionBSPTree2D result = RegionBSPTree2D.empty();
         result.copy(this);
 
         return result;
@@ -133,7 +133,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
             }
         } else {
             // recurse
-            Split<ConvexArea> split = nodeArea.split(node.getCutHyperplane());
+            final Split<ConvexArea> split = nodeArea.split(node.getCutHyperplane());
 
             toConvexRecursive(node.getMinus(), split.getMinus(), result);
             toConvexRecursive(node.getPlus(), split.getPlus(), result);
@@ -206,7 +206,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
         Vector2D endPoint;
         double signedArea;
 
-        for (Segment segment : boundaries()) {
+        for (final Segment segment : boundaries()) {
 
             if (segment.isInfinite()) {
                 // at least on boundary is infinite, meaning that
@@ -280,7 +280,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
      * @return a new tree instance constructed from the given boundaries
      */
     public static RegionBSPTree2D from(final Iterable<Segment> boundaries) {
-        RegionBSPTree2D tree = RegionBSPTree2D.full();
+        final RegionBSPTree2D tree = RegionBSPTree2D.full();
         tree.insert(boundaries);
 
         return tree;
@@ -321,7 +321,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
             RegionNode2D parent;
 
             while ((parent = child.getParent()) != null) {
-                Split<ConvexArea> split = area.split(parent.getCutHyperplane());
+                final Split<ConvexArea> split = area.split(parent.getCutHyperplane());
 
                 area = child.isMinus() ? split.getMinus() : split.getPlus();
 
@@ -436,7 +436,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
                     } else if (linecastSegment.contains(pt)) {
                         // we've potentially found a new linecast point; add it to the list of potential
                         // results
-                        LinecastPoint2D potentialResult = computeLinecastPoint(pt, node);
+                        final LinecastPoint2D potentialResult = computeLinecastPoint(pt, node);
                         if (potentialResult != null) {
                             results.add(potentialResult);
 
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 a2e3869..369a90e 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
@@ -244,10 +244,10 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
      */
     @Override
     public double angle(final Vector2D v) {
-        double normProduct = getCheckedNorm() * v.getCheckedNorm();
+        final double normProduct = getCheckedNorm() * v.getCheckedNorm();
 
-        double dot = dot(v);
-        double threshold = normProduct * 0.9999;
+        final double dot = dot(v);
+        final double threshold = normProduct * 0.9999;
         if ((dot < -threshold) || (dot > threshold)) {
             // the vectors are almost aligned, compute using the sine
             final double n = Math.abs(LinearCombination.value(x, v.y, -y, v.x));
diff --git a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AbstractConvexHullGenerator2D.java b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AbstractConvexHullGenerator2D.java
index 7770fdb..fd5abd3 100644
--- a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AbstractConvexHullGenerator2D.java
+++ b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AbstractConvexHullGenerator2D.java
@@ -94,14 +94,14 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
      * @return {@code true} if the vertices form a convex hull, {@code false} otherwise
      */
     private boolean isConvex(final Collection<Vector2D> vertices) {
-        int size = vertices.size();
+        final int size = vertices.size();
 
         if (size < 3) {
             // 1 or 2 points always define a convex set
             return true;
         }
 
-        Iterator<Vector2D> it = vertices.iterator();
+        final Iterator<Vector2D> it = vertices.iterator();
 
         Vector2D p1 = it.next();
         Vector2D p2 = it.next();
diff --git a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AklToussaintHeuristic.java b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AklToussaintHeuristic.java
index eae5055..1ea9694 100644
--- a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AklToussaintHeuristic.java
+++ b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/AklToussaintHeuristic.java
@@ -57,7 +57,7 @@ public final class AklToussaintHeuristic {
         Vector2D maxX = null;
         Vector2D minY = null;
         Vector2D maxY = null;
-        for (Vector2D p : points) {
+        for (final Vector2D p : points) {
             if (minX == null || p.getX() < minX.getX()) {
                 minX = p;
             }
@@ -102,8 +102,8 @@ public final class AklToussaintHeuristic {
      * @return the quadrilateral
      */
     private static List<Vector2D> buildQuadrilateral(final Vector2D... points) {
-        List<Vector2D> quadrilateral = new ArrayList<>();
-        for (Vector2D p : points) {
+        final List<Vector2D> quadrilateral = new ArrayList<>();
+        for (final Vector2D p : points) {
             if (!quadrilateral.contains(p)) {
                 quadrilateral.add(p);
             }
@@ -120,7 +120,7 @@ public final class AklToussaintHeuristic {
     private static boolean insideQuadrilateral(final Vector2D point,
                                                final List<Vector2D> quadrilateralPoints) {
 
-        Vector2D v0 = point;
+        final Vector2D v0 = point;
         Vector2D v1 = quadrilateralPoints.get(0);
         Vector2D v2 = quadrilateralPoints.get(1);
 
diff --git a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChain.java b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChain.java
index 844bb31..4d7bfce 100644
--- a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChain.java
+++ b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChain.java
@@ -80,7 +80,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
 
         // build lower hull
         final List<Vector2D> lowerHull = new ArrayList<>();
-        for (Vector2D p : pointsSortedByXAxis) {
+        for (final Vector2D p : pointsSortedByXAxis) {
             updateHull(p, lowerHull);
         }
 
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
index 2baeeb2..180424c 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
@@ -60,7 +60,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
      * @see #copy(org.apache.commons.geometry.core.partitioning.bsp.BSPTree)
      */
     public RegionBSPTree1S copy() {
-        RegionBSPTree1S result = RegionBSPTree1S.empty();
+        final RegionBSPTree1S result = RegionBSPTree1S.empty();
         result.copy(this);
 
         return result;
@@ -97,7 +97,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
 
             setEmpty();
 
-            for (AngularInterval interval : intervals) {
+            for (final AngularInterval interval : intervals) {
                 union(interval.transform(transform).toTree());
             }
         }
@@ -130,7 +130,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
         // Handle the special case where the cut is on the azimuth equivalent to zero.
         // In this case, it is not possible for any points to lie between it and zero.
         if (!isEmpty() && splitter.classify(Point1S.ZERO) == HyperplaneLocation.ON) {
-            CutAngle cut = (CutAngle) splitter;
+            final CutAngle cut = (CutAngle) splitter;
             if (cut.isPositiveFacing()) {
                 return new Split<>(null, copy());
             } else {
@@ -161,8 +161,8 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
         final boolean zeroOnPlusSide = splitter.getPrecision()
                 .lte(plusPole.distance(Point1S.ZERO), PlaneAngleRadians.PI_OVER_TWO);
 
-        Split<RegionBSPTree1S> firstSplit = split(splitter);
-        Split<RegionBSPTree1S> secondSplit = split(opposite);
+        final Split<RegionBSPTree1S> firstSplit = split(splitter);
+        final Split<RegionBSPTree1S> secondSplit = split(opposite);
 
         RegionBSPTree1S minus = RegionBSPTree1S.empty();
         RegionBSPTree1S plus = RegionBSPTree1S.empty();
@@ -204,7 +204,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
         }
 
         final List<BoundaryPair> insideBoundaryPairs = new ArrayList<>();
-        for (RegionNode1S node : nodes()) {
+        for (final RegionNode1S node : nodes()) {
             if (node.isInside()) {
                 insideBoundaryPairs.add(getNodeBoundaryPair(node));
             }
@@ -212,7 +212,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
 
         insideBoundaryPairs.sort(BOUNDARY_PAIR_COMPARATOR);
 
-        int boundaryPairCount = insideBoundaryPairs.size();
+        final int boundaryPairCount = insideBoundaryPairs.size();
 
         // Find the index of the first boundary pair that is not connected to pair before it.
         // This will be our start point for merging intervals together.
@@ -277,7 +277,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
         CutAngle min = start.getMin();
         CutAngle max = end.getMax();
 
-        DoublePrecisionContext precision = (min != null) ? min.getPrecision() : max.getPrecision();
+        final DoublePrecisionContext precision = (min != null) ? min.getPrecision() : max.getPrecision();
 
         // flip the hyperplanes if needed since there's no
         // guarantee that the inside will be on the minus side
@@ -347,7 +347,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
 
         double intervalSize;
 
-        for (AngularInterval interval : toIntervals()) {
+        for (final AngularInterval interval : toIntervals()) {
             intervalSize = interval.getSize();
 
             size += intervalSize;
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcConnector.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcConnector.java
index c8edd5d..70d9c5d 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcConnector.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcConnector.java
@@ -47,7 +47,7 @@ public abstract class AbstractGreatArcConnector
      * @see #add(GreatArc)
      */
     public void add(final Iterable<GreatArc> arcs) {
-        for (GreatArc segment : arcs) {
+        for (final GreatArc segment : arcs) {
             add(segment);
         }
     }
@@ -63,9 +63,9 @@ public abstract class AbstractGreatArcConnector
      * @see #connectAll()
      */
     public void connect(final Iterable<GreatArc> arcs) {
-        List<ConnectableGreatArc> newEntries = new ArrayList<>();
+        final List<ConnectableGreatArc> newEntries = new ArrayList<>();
 
-        for (GreatArc segment : arcs) {
+        for (final GreatArc segment : arcs) {
             newEntries.add(new ConnectableGreatArc(segment));
         }
 
@@ -102,7 +102,7 @@ public abstract class AbstractGreatArcConnector
         final List<ConnectableGreatArc> roots = computePathRoots();
         final List<GreatArcPath> paths = new ArrayList<>(roots.size());
 
-        for (ConnectableGreatArc root : roots) {
+        for (final ConnectableGreatArc root : roots) {
             paths.add(toPath(root));
         }
 
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
index 4c56473..8e3c0a0 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
@@ -128,7 +128,7 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
     /** {@inheritDoc} */
     @Override
     public Point2S getBarycenter() {
-        Vector3D weighted = getWeightedBarycenterVector();
+        final Vector3D weighted = getWeightedBarycenterVector();
         return weighted == null ? null : Point2S.from(weighted);
     }
 
@@ -141,14 +141,14 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
      *  <em>The Centroid and Inertia Tensor for a Spherical Triangle</em> - John E. Brock</a>
      */
     Vector3D getWeightedBarycenterVector() {
-        List<GreatArc> arcs = getBoundaries();
+        final List<GreatArc> arcs = getBoundaries();
         switch (arcs.size()) {
         case 0:
             // full space; no barycenter
             return null;
         case 1:
             // hemisphere; barycenter is the pole of the hemisphere
-            GreatArc singleArc = arcs.get(0);
+            final GreatArc singleArc = arcs.get(0);
             return singleArc.getCircle().getPole().withNorm(singleArc.getSize());
         default:
             // 2 or more sides; use an extension of the approach outlined here:
@@ -156,7 +156,7 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
             // In short, the barycenter is the sum of the pole vectors of each side
             // multiplied by their arc lengths.
             Vector3D barycenter = Vector3D.ZERO;
-            for (GreatArc arc : getBoundaries()) {
+            for (final GreatArc arc : getBoundaries()) {
                 barycenter = barycenter.add(arc.getCircle().getPole().withNorm(arc.getSize()));
             }
             return barycenter;
@@ -235,7 +235,7 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
         Point2S prev = null;
         Point2S cur = null;
 
-        for (Point2S vertex : vertices) {
+        for (final Point2S vertex : vertices) {
             cur = vertex;
 
             if (first == null) {
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java
index cf10762..65834df 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArcPath.java
@@ -110,7 +110,7 @@ public final class GreatArcPath implements BoundarySource2S {
         }
 
         // add end points
-        for (GreatArc arc : arcs) {
+        for (final GreatArc arc : arcs) {
             pt = arc.getEndPoint();
             if (pt != null) {
                 vertices.add(pt);
@@ -206,7 +206,7 @@ public final class GreatArcPath implements BoundarySource2S {
      */
     public static GreatArcPath fromArcs(final Collection<GreatArc> arcs) {
         final Builder builder = builder(null);
-        for (GreatArc arc : arcs) {
+        for (final GreatArc arc : arcs) {
             builder.append(arc);
         }
 
@@ -398,7 +398,7 @@ public final class GreatArcPath implements BoundarySource2S {
          * @see #append(Point2S)
          */
         public Builder appendVertices(final Collection<Point2S> vertices) {
-            for (Point2S vertex : vertices) {
+            for (final Point2S vertex : vertices) {
                 append(vertex);
             }
 
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircle.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircle.java
index c1ffffb..135c660 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircle.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircle.java
@@ -346,7 +346,7 @@ public final class GreatCircle extends AbstractHyperplane<Point2S>
             return false;
         }
 
-        GreatCircle other = (GreatCircle) obj;
+        final GreatCircle other = (GreatCircle) obj;
 
         return Objects.equals(this.pole, other.pole) &&
                 Objects.equals(this.u, other.u) &&
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnector.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnector.java
index d33828b..2066185 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnector.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnector.java
@@ -45,8 +45,8 @@ public abstract class InteriorAngleGreatArcConnector extends AbstractGreatArcCon
         double selectedInteriorAngle = Double.POSITIVE_INFINITY;
         ConnectableGreatArc selected = null;
 
-        for (ConnectableGreatArc candidate : outgoing) {
-            double interiorAngle = PlaneAngleRadians.PI - circle.angle(candidate.getArc().getCircle(),
+        for (final ConnectableGreatArc candidate : outgoing) {
+            final double interiorAngle = PlaneAngleRadians.PI - circle.angle(candidate.getArc().getCircle(),
                     incoming.getArc().getEndPoint());
 
             if (selected == null || isBetterAngle(interiorAngle, selectedInteriorAngle)) {
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java
index b304186..c62e920 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java
@@ -61,7 +61,7 @@ public class RegionBSPTree2S extends AbstractRegionBSPTree<Point2S, RegionBSPTre
      * @see #copy(org.apache.commons.geometry.core.partitioning.bsp.BSPTree)
      */
     public RegionBSPTree2S copy() {
-        RegionBSPTree2S result = RegionBSPTree2S.empty();
+        final RegionBSPTree2S result = RegionBSPTree2S.empty();
         result.copy(this);
 
         return result;
@@ -127,7 +127,7 @@ public class RegionBSPTree2S extends AbstractRegionBSPTree<Point2S, RegionBSPTre
             }
         } else {
             // recurse
-            Split<ConvexArea2S> split = nodeArea.split(node.getCutHyperplane());
+            final Split<ConvexArea2S> split = nodeArea.split(node.getCutHyperplane());
 
             toConvexRecursive(node.getMinus(), split.getMinus(), result);
             toConvexRecursive(node.getPlus(), split.getPlus(), result);
@@ -167,7 +167,7 @@ public class RegionBSPTree2S extends AbstractRegionBSPTree<Point2S, RegionBSPTre
         double sizeSum = 0;
         Vector3D barycenterVector = Vector3D.ZERO;
 
-        for (ConvexArea2S area : areas) {
+        for (final ConvexArea2S area : areas) {
             sizeSum += area.getSize();
             barycenterVector = barycenterVector.add(area.getWeightedBarycenterVector());
         }
@@ -222,7 +222,7 @@ public class RegionBSPTree2S extends AbstractRegionBSPTree<Point2S, RegionBSPTre
      * @return a new tree instance constructed from the given boundaries
      */
     public static RegionBSPTree2S from(final Iterable<GreatArc> boundaries) {
-        RegionBSPTree2S tree = RegionBSPTree2S.full();
+        final RegionBSPTree2S tree = RegionBSPTree2S.full();
         tree.insert(boundaries);
 
         return tree;
@@ -263,7 +263,7 @@ public class RegionBSPTree2S extends AbstractRegionBSPTree<Point2S, RegionBSPTre
             RegionNode2S parent;
 
             while ((parent = child.getParent()) != null) {
-                Split<ConvexArea2S> split = area.split(parent.getCutHyperplane());
+                final Split<ConvexArea2S> split = area.split(parent.getCutHyperplane());
 
                 area = child.isMinus() ? split.getMinus() : split.getPlus();
 


[commons-geometry] 03/04: Remove redundant field initialisers

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 826ff8836ed8bb805abb67c3ec775bf7750a1aad
Author: Alex Herbert <a....@sussex.ac.uk>
AuthorDate: Tue Feb 18 00:37:17 2020 +0000

    Remove redundant field initialisers
---
 .../commons/geometry/core/partitioning/bsp/AbstractBSPTree.java   | 2 +-
 .../geometry/euclidean/internal/AbstractPathConnector.java        | 2 +-
 .../apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java   | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java
index 060f995..b5c23b8 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java
@@ -51,7 +51,7 @@ public abstract class AbstractBSPTree<P extends Point<P>, N extends AbstractBSPT
      * a structural change occurs in the tree and is used to determine when cached values
      * must be recomputed.
      */
-    private int version = 0;
+    private int version;
 
     /** {@inheritDoc} */
     @Override
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java
index cb94308..fee4343 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/AbstractPathConnector.java
@@ -278,7 +278,7 @@ public abstract class AbstractPathConnector<E extends AbstractPathConnector.Conn
         private E previous;
 
         /** Flag set to true when this element has exported its value to a path. */
-        private boolean exported = false;
+        private boolean exported;
 
         /** Return true if the instance is connected to another element's start point.
          * @return true if the instance has a next element
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
index fe19261..6d4ca39 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
@@ -502,16 +502,16 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
      */
     private static final class RegionSizePropertiesVisitor implements BiConsumer<OrientedPoint, OrientedPoint> {
         /** Number of inside intervals visited. */
-        private int count = 0;
+        private int count;
 
         /** Total computed size of all inside regions. */
-        private double size = 0;
+        private double size;
 
         /** Raw sum of the barycenters of each inside interval. */
-        private double rawBarycenterSum = 0;
+        private double rawBarycenterSum;
 
         /** The sum of the barycenter of each inside interval, scaled by the size of the interval. */
-        private double scaledBarycenterSum = 0;
+        private double scaledBarycenterSum;
 
         /** {@inheritDoc} */
         @Override


[commons-geometry] 01/04: Allow 1 as a magic number

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0880ae35e30767dc121f4175f0432b4e7d802ada
Author: Alex Herbert <a....@sussex.ac.uk>
AuthorDate: Tue Feb 18 00:28:38 2020 +0000

    Allow 1 as a magic number
---
 src/main/resources/pmd/pmd-ruleset.xml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/main/resources/pmd/pmd-ruleset.xml b/src/main/resources/pmd/pmd-ruleset.xml
index 92d8907..0307f27 100644
--- a/src/main/resources/pmd/pmd-ruleset.xml
+++ b/src/main/resources/pmd/pmd-ruleset.xml
@@ -62,4 +62,10 @@
     <!-- <exclude name="..." /> -->
   </rule>
 
+  <rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
+    <properties>
+      <property name="ignoreMagicNumbers" value="-1,0,1" />
+    </properties>
+  </rule>
+
 </ruleset>


[commons-geometry] 04/04: Remove unnecessary else clauses.

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f84ae36d8f3c7c048c7cf33797bf432721906e2d
Author: Alex Herbert <a....@sussex.ac.uk>
AuthorDate: Tue Feb 18 00:40:22 2020 +0000

    Remove unnecessary else clauses.
---
 .../euclidean/threed/SphereGenerator.java          | 164 ++++++++++-----------
 .../enclosing/euclidean/twod/DiskGenerator.java    | 113 +++++++-------
 2 files changed, 135 insertions(+), 142 deletions(-)

diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGenerator.java b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGenerator.java
index 698c46b..2902818 100644
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGenerator.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGenerator.java
@@ -48,93 +48,89 @@ public class SphereGenerator implements SupportBallGenerator<Vector3D> {
     public EnclosingBall<Vector3D> ballOnSupport(final List<Vector3D> support) {
         if (support.isEmpty()) {
             return new EnclosingBall<>(Vector3D.ZERO, Double.NEGATIVE_INFINITY, Collections.emptyList());
-        } else {
-            final Vector3D vA = support.get(0);
-            if (support.size() < 2) {
-                return new EnclosingBall<>(vA, 0, Arrays.asList(vA));
-            } else {
-                final Vector3D vB = support.get(1);
-                if (support.size() < 3) {
-                    return new EnclosingBall<>(Vector3D.linearCombination(0.5, vA, 0.5, vB),
-                                               0.5 * vA.distance(vB),
-                                               Arrays.asList(vA, vB));
-                } else {
-                    final Vector3D vC = support.get(2);
-                    if (support.size() < 4) {
-                        final Plane p = Plane.fromPoints(vA, vB, vC, precision);
-                        final EnclosingBall<Vector2D> disk =
-                                new DiskGenerator().ballOnSupport(Arrays.asList(p.toSubspace(vA),
-                                                                                p.toSubspace(vB),
-                                                                                p.toSubspace(vC)));
+        }
+        final Vector3D vA = support.get(0);
+        if (support.size() < 2) {
+            return new EnclosingBall<>(vA, 0, Arrays.asList(vA));
+        }
+        final Vector3D vB = support.get(1);
+        if (support.size() < 3) {
+            return new EnclosingBall<>(Vector3D.linearCombination(0.5, vA, 0.5, vB),
+                                       0.5 * vA.distance(vB),
+                                       Arrays.asList(vA, vB));
+        } 
+        final Vector3D vC = support.get(2);
+        if (support.size() < 4) {
+            final Plane p = Plane.fromPoints(vA, vB, vC, precision);
+            final EnclosingBall<Vector2D> disk =
+                    new DiskGenerator().ballOnSupport(Arrays.asList(p.toSubspace(vA),
+                                                                    p.toSubspace(vB),
+                                                                    p.toSubspace(vC)));
 
-                        // convert back to 3D
-                        return new EnclosingBall<>(p.toSpace(disk.getCenter()),
-                                                                        disk.getRadius(),
-                                                                        Arrays.asList(vA, vB, vC));
+            // convert back to 3D
+            return new EnclosingBall<>(p.toSpace(disk.getCenter()),
+                                                            disk.getRadius(),
+                                                            Arrays.asList(vA, vB, vC));
 
-                    } else {
-                        final Vector3D vD = support.get(3);
-                        // a sphere is 3D can be defined as:
-                        // (1)   (x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 = r^2
-                        // which can be written:
-                        // (2)   (x^2 + y^2 + z^2) - 2 x_0 x - 2 y_0 y - 2 z_0 z + (x_0^2 + y_0^2 + z_0^2 - r^2) = 0
-                        // or simply:
-                        // (3)   (x^2 + y^2 + z^2) + a x + b y + c z + d = 0
-                        // with sphere center coordinates -a/2, -b/2, -c/2
-                        // If the sphere exists, a b, c and d are a non zero solution to
-                        // [ (x^2  + y^2  + z^2)    x    y   z    1 ]   [ 1 ]   [ 0 ]
-                        // [ (xA^2 + yA^2 + zA^2)   xA   yA  zA   1 ]   [ a ]   [ 0 ]
-                        // [ (xB^2 + yB^2 + zB^2)   xB   yB  zB   1 ] * [ b ] = [ 0 ]
-                        // [ (xC^2 + yC^2 + zC^2)   xC   yC  zC   1 ]   [ c ]   [ 0 ]
-                        // [ (xD^2 + yD^2 + zD^2)   xD   yD  zD   1 ]   [ d ]   [ 0 ]
-                        // So the determinant of the matrix is zero. Computing this determinant
-                        // by expanding it using the minors m_ij of first row leads to
-                        // (4)   m_11 (x^2 + y^2 + z^2) - m_12 x + m_13 y - m_14 z + m_15 = 0
-                        // So by identifying equations (2) and (4) we get the coordinates
-                        // of center as:
-                        //      x_0 = +m_12 / (2 m_11)
-                        //      y_0 = -m_13 / (2 m_11)
-                        //      z_0 = +m_14 / (2 m_11)
-                        // Note that the minors m_11, m_12, m_13 and m_14 all have the last column
-                        // filled with 1.0, hence simplifying the computation
-                        final BigFraction[] c2 = new BigFraction[] {
-                            BigFraction.from(vA.getX()), BigFraction.from(vB.getX()),
-                            BigFraction.from(vC.getX()), BigFraction.from(vD.getX())
-                        };
-                        final BigFraction[] c3 = new BigFraction[] {
-                            BigFraction.from(vA.getY()), BigFraction.from(vB.getY()),
-                            BigFraction.from(vC.getY()), BigFraction.from(vD.getY())
-                        };
-                        final BigFraction[] c4 = new BigFraction[] {
-                            BigFraction.from(vA.getZ()), BigFraction.from(vB.getZ()),
-                            BigFraction.from(vC.getZ()), BigFraction.from(vD.getZ())
-                        };
-                        final BigFraction[] c1 = new BigFraction[] {
-                            c2[0].multiply(c2[0]).add(c3[0].multiply(c3[0])).add(c4[0].multiply(c4[0])),
-                            c2[1].multiply(c2[1]).add(c3[1].multiply(c3[1])).add(c4[1].multiply(c4[1])),
-                            c2[2].multiply(c2[2]).add(c3[2].multiply(c3[2])).add(c4[2].multiply(c4[2])),
-                            c2[3].multiply(c2[3]).add(c3[3].multiply(c3[3])).add(c4[3].multiply(c4[3]))
-                        };
-                        final BigFraction twoM11 = minor(c2, c3, c4).multiply(2);
-                        final BigFraction m12 = minor(c1, c3, c4);
-                        final BigFraction m13 = minor(c1, c2, c4);
-                        final BigFraction m14 = minor(c1, c2, c3);
-                        final BigFraction centerX = m12.divide(twoM11);
-                        final BigFraction centerY = m13.divide(twoM11).negate();
-                        final BigFraction centerZ = m14.divide(twoM11);
-                        final BigFraction dx = c2[0].subtract(centerX);
-                        final BigFraction dy = c3[0].subtract(centerY);
-                        final BigFraction dz = c4[0].subtract(centerZ);
-                        final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz));
-                        return new EnclosingBall<>(Vector3D.of(centerX.doubleValue(),
-                                                               centerY.doubleValue(),
-                                                               centerZ.doubleValue()),
-                                                   Math.sqrt(r2.doubleValue()),
-                                                   Arrays.asList(vA, vB, vC, vD));
-                    }
-                }
-            }
         }
+        final Vector3D vD = support.get(3);
+        // a sphere is 3D can be defined as:
+        // (1)   (x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 = r^2
+        // which can be written:
+        // (2)   (x^2 + y^2 + z^2) - 2 x_0 x - 2 y_0 y - 2 z_0 z + (x_0^2 + y_0^2 + z_0^2 - r^2) = 0
+        // or simply:
+        // (3)   (x^2 + y^2 + z^2) + a x + b y + c z + d = 0
+        // with sphere center coordinates -a/2, -b/2, -c/2
+        // If the sphere exists, a b, c and d are a non zero solution to
+        // [ (x^2  + y^2  + z^2)    x    y   z    1 ]   [ 1 ]   [ 0 ]
+        // [ (xA^2 + yA^2 + zA^2)   xA   yA  zA   1 ]   [ a ]   [ 0 ]
+        // [ (xB^2 + yB^2 + zB^2)   xB   yB  zB   1 ] * [ b ] = [ 0 ]
+        // [ (xC^2 + yC^2 + zC^2)   xC   yC  zC   1 ]   [ c ]   [ 0 ]
+        // [ (xD^2 + yD^2 + zD^2)   xD   yD  zD   1 ]   [ d ]   [ 0 ]
+        // So the determinant of the matrix is zero. Computing this determinant
+        // by expanding it using the minors m_ij of first row leads to
+        // (4)   m_11 (x^2 + y^2 + z^2) - m_12 x + m_13 y - m_14 z + m_15 = 0
+        // So by identifying equations (2) and (4) we get the coordinates
+        // of center as:
+        //      x_0 = +m_12 / (2 m_11)
+        //      y_0 = -m_13 / (2 m_11)
+        //      z_0 = +m_14 / (2 m_11)
+        // Note that the minors m_11, m_12, m_13 and m_14 all have the last column
+        // filled with 1.0, hence simplifying the computation
+        final BigFraction[] c2 = {
+            BigFraction.from(vA.getX()), BigFraction.from(vB.getX()),
+            BigFraction.from(vC.getX()), BigFraction.from(vD.getX())
+        };
+        final BigFraction[] c3 = {
+            BigFraction.from(vA.getY()), BigFraction.from(vB.getY()),
+            BigFraction.from(vC.getY()), BigFraction.from(vD.getY())
+        };
+        final BigFraction[] c4 = {
+            BigFraction.from(vA.getZ()), BigFraction.from(vB.getZ()),
+            BigFraction.from(vC.getZ()), BigFraction.from(vD.getZ())
+        };
+        final BigFraction[] c1 = {
+            c2[0].multiply(c2[0]).add(c3[0].multiply(c3[0])).add(c4[0].multiply(c4[0])),
+            c2[1].multiply(c2[1]).add(c3[1].multiply(c3[1])).add(c4[1].multiply(c4[1])),
+            c2[2].multiply(c2[2]).add(c3[2].multiply(c3[2])).add(c4[2].multiply(c4[2])),
+            c2[3].multiply(c2[3]).add(c3[3].multiply(c3[3])).add(c4[3].multiply(c4[3]))
+        };
+        final BigFraction twoM11 = minor(c2, c3, c4).multiply(2);
+        final BigFraction m12 = minor(c1, c3, c4);
+        final BigFraction m13 = minor(c1, c2, c4);
+        final BigFraction m14 = minor(c1, c2, c3);
+        final BigFraction centerX = m12.divide(twoM11);
+        final BigFraction centerY = m13.divide(twoM11).negate();
+        final BigFraction centerZ = m14.divide(twoM11);
+        final BigFraction dx = c2[0].subtract(centerX);
+        final BigFraction dy = c3[0].subtract(centerY);
+        final BigFraction dz = c4[0].subtract(centerZ);
+        final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz));
+        return new EnclosingBall<>(Vector3D.of(centerX.doubleValue(),
+                                               centerY.doubleValue(),
+                                               centerZ.doubleValue()),
+                                   Math.sqrt(r2.doubleValue()),
+                                   Arrays.asList(vA, vB, vC, vD));
     }
 
     /** Compute a dimension 4 minor, when 4<sup>th</sup> column is known to be filled with 1.0.
diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGenerator.java b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGenerator.java
index d6f50e6..053caaf 100644
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGenerator.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGenerator.java
@@ -34,65 +34,62 @@ public class DiskGenerator implements SupportBallGenerator<Vector2D> {
     public EnclosingBall<Vector2D> ballOnSupport(final List<Vector2D> support) {
         if (support.isEmpty()) {
             return new EnclosingBall<>(Vector2D.ZERO, Double.NEGATIVE_INFINITY, Collections.emptyList());
-        } else {
-            final Vector2D vA = support.get(0);
-            if (support.size() < 2) {
-                return new EnclosingBall<>(vA, 0, Arrays.asList(vA));
-            } else {
-                final Vector2D vB = support.get(1);
-                if (support.size() < 3) {
-                    return new EnclosingBall<>(Vector2D.linearCombination(0.5, vA, 0.5, vB),
-                                               0.5 * vA.distance(vB),
-                                               Arrays.asList(vA, vB));
-                } else {
-                    final Vector2D vC = support.get(2);
-                    // a disk is 2D can be defined as:
-                    // (1)   (x - x_0)^2 + (y - y_0)^2 = r^2
-                    // which can be written:
-                    // (2)   (x^2 + y^2) - 2 x_0 x - 2 y_0 y + (x_0^2 + y_0^2 - r^2) = 0
-                    // or simply:
-                    // (3)   (x^2 + y^2) + a x + b y + c = 0
-                    // with disk center coordinates -a/2, -b/2
-                    // If the disk exists, a, b and c are a non-zero solution to
-                    // [ (x^2  + y^2 )   x    y   1 ]   [ 1 ]   [ 0 ]
-                    // [ (xA^2 + yA^2)   xA   yA  1 ]   [ a ]   [ 0 ]
-                    // [ (xB^2 + yB^2)   xB   yB  1 ] * [ b ] = [ 0 ]
-                    // [ (xC^2 + yC^2)   xC   yC  1 ]   [ c ]   [ 0 ]
-                    // So the determinant of the matrix is zero. Computing this determinant
-                    // by expanding it using the minors m_ij of first row leads to
-                    // (4)   m_11 (x^2 + y^2) - m_12 x + m_13 y - m_14 = 0
-                    // So by identifying equations (2) and (4) we get the coordinates
-                    // of center as:
-                    //      x_0 = +m_12 / (2 m_11)
-                    //      y_0 = -m_13 / (2 m_11)
-                    // Note that the minors m_11, m_12 and m_13 all have the last column
-                    // filled with 1.0, hence simplifying the computation
-                    final BigFraction[] c2 = new BigFraction[] {
-                        BigFraction.from(vA.getX()), BigFraction.from(vB.getX()), BigFraction.from(vC.getX())
-                    };
-                    final BigFraction[] c3 = new BigFraction[] {
-                        BigFraction.from(vA.getY()), BigFraction.from(vB.getY()), BigFraction.from(vC.getY())
-                    };
-                    final BigFraction[] c1 = new BigFraction[] {
-                        c2[0].multiply(c2[0]).add(c3[0].multiply(c3[0])),
-                        c2[1].multiply(c2[1]).add(c3[1].multiply(c3[1])),
-                        c2[2].multiply(c2[2]).add(c3[2].multiply(c3[2]))
-                    };
-                    final BigFraction twoM11 = minor(c2, c3).multiply(2);
-                    final BigFraction m12 = minor(c1, c3);
-                    final BigFraction m13 = minor(c1, c2);
-                    final BigFraction centerX = m12.divide(twoM11);
-                    final BigFraction centerY = m13.divide(twoM11).negate();
-                    final BigFraction dx = c2[0].subtract(centerX);
-                    final BigFraction dy = c3[0].subtract(centerY);
-                    final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy));
-                    return new EnclosingBall<>(Vector2D.of(centerX.doubleValue(),
-                                                           centerY.doubleValue()),
-                                               Math.sqrt(r2.doubleValue()),
-                                               Arrays.asList(vA, vB, vC));
-                }
-            }
+        } 
+        final Vector2D vA = support.get(0);
+        if (support.size() < 2) {
+            return new EnclosingBall<>(vA, 0, Arrays.asList(vA));
+        } 
+        final Vector2D vB = support.get(1);
+        if (support.size() < 3) {
+            return new EnclosingBall<>(Vector2D.linearCombination(0.5, vA, 0.5, vB),
+                                       0.5 * vA.distance(vB),
+                                       Arrays.asList(vA, vB));
         }
+        final Vector2D vC = support.get(2);
+        // a disk is 2D can be defined as:
+        // (1)   (x - x_0)^2 + (y - y_0)^2 = r^2
+        // which can be written:
+        // (2)   (x^2 + y^2) - 2 x_0 x - 2 y_0 y + (x_0^2 + y_0^2 - r^2) = 0
+        // or simply:
+        // (3)   (x^2 + y^2) + a x + b y + c = 0
+        // with disk center coordinates -a/2, -b/2
+        // If the disk exists, a, b and c are a non-zero solution to
+        // [ (x^2  + y^2 )   x    y   1 ]   [ 1 ]   [ 0 ]
+        // [ (xA^2 + yA^2)   xA   yA  1 ]   [ a ]   [ 0 ]
+        // [ (xB^2 + yB^2)   xB   yB  1 ] * [ b ] = [ 0 ]
+        // [ (xC^2 + yC^2)   xC   yC  1 ]   [ c ]   [ 0 ]
+        // So the determinant of the matrix is zero. Computing this determinant
+        // by expanding it using the minors m_ij of first row leads to
+        // (4)   m_11 (x^2 + y^2) - m_12 x + m_13 y - m_14 = 0
+        // So by identifying equations (2) and (4) we get the coordinates
+        // of center as:
+        //      x_0 = +m_12 / (2 m_11)
+        //      y_0 = -m_13 / (2 m_11)
+        // Note that the minors m_11, m_12 and m_13 all have the last column
+        // filled with 1.0, hence simplifying the computation
+        final BigFraction[] c2 = {
+            BigFraction.from(vA.getX()), BigFraction.from(vB.getX()), BigFraction.from(vC.getX())
+        };
+        final BigFraction[] c3 = {
+            BigFraction.from(vA.getY()), BigFraction.from(vB.getY()), BigFraction.from(vC.getY())
+        };
+        final BigFraction[] c1 = {
+            c2[0].multiply(c2[0]).add(c3[0].multiply(c3[0])),
+            c2[1].multiply(c2[1]).add(c3[1].multiply(c3[1])),
+            c2[2].multiply(c2[2]).add(c3[2].multiply(c3[2]))
+        };
+        final BigFraction twoM11 = minor(c2, c3).multiply(2);
+        final BigFraction m12 = minor(c1, c3);
+        final BigFraction m13 = minor(c1, c2);
+        final BigFraction centerX = m12.divide(twoM11);
+        final BigFraction centerY = m13.divide(twoM11).negate();
+        final BigFraction dx = c2[0].subtract(centerX);
+        final BigFraction dy = c3[0].subtract(centerY);
+        final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy));
+        return new EnclosingBall<>(Vector2D.of(centerX.doubleValue(),
+                                               centerY.doubleValue()),
+                                   Math.sqrt(r2.doubleValue()),
+                                   Arrays.asList(vA, vB, vC));
     }
 
     /** Compute a dimension 3 minor, when 3<sup>d</sup> column is known to be filled with 1.0.