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

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

commit 357ccafadeb9e072ddad9ea83b9e8e36541f677d
Author: Gilles Sadowski <gil...@harfang.homelinux.org>
AuthorDate: Fri Jul 26 13:38:59 2019 +0200

    Formatting nits.
---
 .../commons/geometry/euclidean/threed/Plane.java   | 58 ++++++++-----
 .../geometry/euclidean/threed/PolyhedronsSet.java  | 99 +++++++++++-----------
 2 files changed, 84 insertions(+), 73 deletions(-)

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 0be47cd..031cdb5 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
@@ -84,17 +84,18 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
      * @throws IllegalArgumentException if the provided vectors are collinear
      */
     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);
     }
 
     /**
      * Build a plane from a normal.
      * Chooses origin as point on plane.
-     * @param normal    normal direction to the plane
+     * @param normal normal direction to the plane
      * @param precision precision context used to compare floating point values
      * @return a new plane
      * @throws IllegalNormException if the norm of the given values is zero, 
NaN, or infinite.
@@ -106,17 +107,18 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
     /**
      * Build a plane from a point and a normal.
      *
-     * @param p         point belonging to the plane
-     * @param normal    normal direction to the plane
+     * @param p point belonging to the plane
+     * @param normal normal direction to the plane
      * @param precision precision context used to compare floating point values
      * @return a new plane
      * @throws IllegalNormException if the norm of the given values is zero, 
NaN, or infinite.
      */
     public static Plane fromPointAndNormal(final Vector3D p, final Vector3D 
normal, final DoublePrecisionContext precision) {
-        Vector3D w = normal.normalize();
-        double originOffset = -p.dot(w);
-        Vector3D u = w.orthogonal();
-        Vector3D v = w.cross(u);
+        final Vector3D w = normal.normalize();
+        final double originOffset = -p.dot(w);
+        final Vector3D u = w.orthogonal();
+        final Vector3D v = w.cross(u);
+
         return new Plane(u, v, w, originOffset, precision);
     }
 
@@ -126,9 +128,9 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
      * The plane is oriented in the direction of {@code (p2-p1) ^ (p3-p1)}
      * </p>
      *
-     * @param p1        first point belonging to the plane
-     * @param p2        second point belonging to the plane
-     * @param p3        third point belonging to the plane
+     * @param p1 first point belonging to the plane
+     * @param p2 second point belonging to the plane
+     * @param p3 third point belonging to the plane
      * @param precision precision context used to compare floating point values
      * @return a new plane
      * @throws GeometryException if the points do not define a unique plane
@@ -172,9 +174,9 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
 
         Vector3D cross = null;
         double crossNorm;
-        double crossSumX = 0.0;
-        double crossSumY = 0.0;
-        double crossSumZ = 0.0;
+        double crossSumX = 0;
+        double crossSumY = 0;
+        double crossSumZ = 0;
 
         boolean nonPlanar = false;
 
@@ -216,7 +218,9 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
             }
         }
 
-        if (u == null || w == null || nonPlanar) {
+        if (u == null ||
+            w == null ||
+            nonPlanar) {
             throw new GeometryException("Points do not define a plane: " + 
pts);
         }
 
@@ -342,6 +346,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
         Vector3D projectedLineDirection = direction.subtract(projection);
         Vector3D p1 = project(line.getOrigin());
         Vector3D p2 = p1.add(projectedLineDirection);
+
         return new Line(p1,p2, precision);
     }
 
@@ -370,6 +375,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
         Vector3D vTmp = tmp;
         Vector3D wTmp = this.w.negate();
         double originOffsetTmp = -this.originOffset;
+
         return new Plane(uTmp, vTmp, wTmp, originOffsetTmp, this.precision);
     }
 
@@ -422,6 +428,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
      */
     public boolean contains(final Plane plane) {
         final double angle = w.angle(plane.w);
+
         return ((precision.eqZero(angle)) && precision.eq(originOffset, 
plane.originOffset)) ||
                 ((precision.eq(angle, Math.PI)) && precision.eq(originOffset, 
-plane.originOffset));
     }
@@ -446,6 +453,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
         double originOffsetTmp = -p.dot(wTmp);
         Vector3D uTmp = rotation.apply(this.u);
         Vector3D vTmp = rotation.apply(this.v);
+
         return new Plane(uTmp, vTmp, wTmp, originOffsetTmp, this.precision);
     }
 
@@ -463,6 +471,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
         Vector3D normal = this.w;
         Vector3D wTmp = normal.normalize();
         double originOffsetTmp = -p.dot(wTmp);
+
         return new Plane(this.u, this.v, wTmp, originOffsetTmp, 
this.precision);
     }
 
@@ -481,6 +490,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
         }
         final Vector3D point = line.toSpace(Vector1D.ZERO);
         final double k = -(originOffset + w.dot(point)) / dot;
+
         return Vector3D.linearCombination(1.0, point, k, direction);
     }
 
@@ -497,6 +507,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
             return null;
         }
         final Vector3D point = intersection(this, other, 
Plane.fromNormal(direction, precision));
+
         return new Line(point, point.add(direction), precision);
     }
 
@@ -537,10 +548,10 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
         }
 
         final double r = 1.0 / determinant;
+
         return Vector3D.of((-a23 * d1 - (c1 * b3 - c3 * b1) * d2 - (c2 * b1 - 
c1 * b2) * d3) * r,
                 (-b23 * d1 - (c3 * a1 - c1 * a3) * d2 - (c1 * a2 - c2 * a1) * 
d3) * r,
                 (-c23 * d1 - (b1 * a3 - b3 * a1) * d2 - (b2 * a1 - b1 * a2) * 
d3) * r);
-
     }
 
     /**
@@ -582,7 +593,8 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
     public boolean contains(final Line line) {
         Vector3D origin = line.getOrigin();
         Vector3D direction = line.getDirection();
-        return contains(origin) && areCoplanar(u, v, direction, precision);
+        return contains(origin) &&
+            areCoplanar(u, v, direction, precision);
     }
 
     /** Check, if the line is parallel to the instance.
@@ -591,7 +603,7 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
      */
     public boolean isParallel(final Line line) {
         final Vector3D direction = line.getDirection();
-        final double   dot       = w.dot(direction);
+        final double dot = w.dot(direction);
         if (precision.eqZero(dot)) {
             return true;
         }
@@ -623,7 +635,9 @@ public final class Plane implements Hyperplane<Vector3D>, 
Embedding<Vector3D, Ve
      * @return offset of the plane
      */
     public double getOffset(final Plane plane) {
-        return originOffset + (sameOrientationAs(plane) ? -plane.originOffset 
: plane.originOffset);
+        return originOffset + (sameOrientationAs(plane) ?
+                               -plane.originOffset :
+                               plane.originOffset);
     }
 
     /**
diff --git 
a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
index 995c9a9..27bd7f2 100644
--- 
a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
+++ 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
@@ -151,18 +151,20 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
                                                       final double yMin, final 
double yMax,
                                                       final double zMin, final 
double zMax,
                                                       final 
DoublePrecisionContext precision) {
-        if (precision.eq(xMin, xMax) || precision.eq(yMin, yMax) || 
precision.eq(zMin, zMax)) {
+        if (precision.eq(xMin, xMax) ||
+            precision.eq(yMin, yMax) ||
+            precision.eq(zMin, zMax)) {
             // too thin box, build an empty polygons set
             return new BSPTree<>(Boolean.FALSE);
         }
-        final Plane pxMin = Plane.fromPointAndNormal(Vector3D.of(xMin, 0,    
0),   Vector3D.MINUS_X, precision);
-        final Plane pxMax = Plane.fromPointAndNormal(Vector3D.of(xMax, 0,    
0),   Vector3D.PLUS_X,  precision);
-        final Plane pyMin = Plane.fromPointAndNormal(Vector3D.of(0,    yMin, 
0),   Vector3D.MINUS_Y, precision);
-        final Plane pyMax = Plane.fromPointAndNormal(Vector3D.of(0,    yMax, 
0),   Vector3D.PLUS_Y,  precision);
-        final Plane pzMin = Plane.fromPointAndNormal(Vector3D.of(0,    0,   
zMin), Vector3D.MINUS_Z, precision);
-        final Plane pzMax = Plane.fromPointAndNormal(Vector3D.of(0,    0,   
zMax), Vector3D.PLUS_Z,  precision);
+        final Plane pxMin = Plane.fromPointAndNormal(Vector3D.of(xMin, 0, 0), 
Vector3D.MINUS_X, precision);
+        final Plane pxMax = Plane.fromPointAndNormal(Vector3D.of(xMax, 0, 0), 
Vector3D.PLUS_X,  precision);
+        final Plane pyMin = Plane.fromPointAndNormal(Vector3D.of(0, yMin, 0), 
Vector3D.MINUS_Y, precision);
+        final Plane pyMax = Plane.fromPointAndNormal(Vector3D.of(0, yMax, 0), 
Vector3D.PLUS_Y,  precision);
+        final Plane pzMin = Plane.fromPointAndNormal(Vector3D.of(0, 0, zMin), 
Vector3D.MINUS_Z, precision);
+        final Plane pzMax = Plane.fromPointAndNormal(Vector3D.of(0, 0, zMax), 
Vector3D.PLUS_Z,  precision);
         final Region<Vector3D> boundary =
-        new RegionFactory<Vector3D>().buildConvex(pxMin, pxMax, pyMin, pyMax, 
pzMin, pzMax);
+            new RegionFactory<Vector3D>().buildConvex(pxMin, pxMax, pyMin, 
pyMax, pzMin, pzMax);
         return boundary.getTree(false);
     }
 
@@ -174,8 +176,8 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
      * @exception IllegalArgumentException if some basic sanity checks fail
      */
     private static List<SubHyperplane<Vector3D>> buildBoundary(final 
List<Vector3D> vertices,
-                                                                  final 
List<int[]> facets,
-                                                                  final 
DoublePrecisionContext precision) {
+                                                               final 
List<int[]> facets,
+                                                               final 
DoublePrecisionContext precision) {
 
         // check vertices distances
         for (int i = 0; i < vertices.size() - 1; ++i) {
@@ -218,7 +220,7 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
 
         for (final int[] facet : facets) {
 
-            for (int i=0; i<facet.length; ++i) {
+            for (int i = 0; i < facet.length; ++i) {
                 facetVertices.add(vertices.get(facet[i]));
             }
 
@@ -226,7 +228,7 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
 
             // convert to subspace points
             final Vector2D[] two2Points = new Vector2D[facet.length];
-            for (int i=0 ; i<facet.length; ++i) {
+            for (int i = 0 ; i < facet.length; ++i) {
                 two2Points[i] = plane.toSubSpace(facetVertices.get(i));
             }
 
@@ -237,7 +239,6 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
         }
 
         return boundary;
-
     }
 
     /** Find the facets that reference each edges.
@@ -269,7 +270,8 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
             for (final int v : facets.get(f)) {
                 // vertex v is referenced by facet f
                 int k = 0;
-                while (k < maxFacets && references[v][k] >= 0) {
+                while (k < maxFacets &&
+                       references[v][k] >= 0) {
                     ++k;
                 }
                 references[v][k] = f;
@@ -277,7 +279,6 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
         }
 
         return references;
-
     }
 
     /** Find the successors of all vertices among all facets they belong to.
@@ -305,7 +306,8 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
                 // look for vertex v
                 final int[] facet = facets.get(references[v][k]);
                 int i = 0;
-                while (i < facet.length && facet[i] != v) {
+                while (i < facet.length &&
+                       facet[i] != v) {
                     ++i;
                 }
 
@@ -318,7 +320,6 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
                         throw new 
IllegalArgumentException(MessageFormat.format("Facet orientation mismatch 
around edge joining points {0} and {1}", start, end));
                     }
                 }
-
             }
         }
 
@@ -337,7 +338,7 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
     protected void computeGeometricalProperties() {
         // check simple cases first
         if (isEmpty()) {
-            setSize(0.0);
+            setSize(0);
             setBarycenter(Vector3D.NaN);
         }
         else if (isFull()) {
@@ -393,7 +394,7 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
          */
         public double getSize() {
             // apply the 1/3 pyramid volume scaling factor
-            return volumeSum / 3.0;
+            return volumeSum / 3;
         }
 
         /** Returns the computed barycenter. This is the volume-weighted 
average
@@ -430,8 +431,7 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
 
         /** {@inheritDoc} */
         @Override
-        public void visitLeafNode(final BSPTree<Vector3D> node) {
-        }
+        public void visitLeafNode(final BSPTree<Vector3D> node) {}
 
         /** Add the contribution of a boundary facet.
          * @param facet boundary facet
@@ -491,11 +491,11 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
         }
         final BSPTree<Vector3D> minus = node.getMinus();
         final BSPTree<Vector3D> plus  = node.getPlus();
-        final Plane                plane = (Plane) cut.getHyperplane();
+        final Plane plane = (Plane) cut.getHyperplane();
 
         // establish search order
         final double offset = plane.getOffset(point);
-        final boolean in    = getPrecision().eqZero(Math.abs(offset));
+        final boolean in = getPrecision().eqZero(Math.abs(offset));
         final BSPTree<Vector3D> near;
         final BSPTree<Vector3D> far;
         if (offset < 0) {
@@ -512,7 +512,8 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
 
             // only return the facet here if it exists and intersects the plane
             // (ie, is not parallel it)
-            if (facet != null && plane.intersection(line) != null) {
+            if (facet != null &&
+                plane.intersection(line) != null) {
                 return facet;
             }
         }
@@ -526,7 +527,8 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
         if (!in) {
             // search in the cut hyperplane
             final Vector3D hit3D = plane.intersection(line);
-            if (hit3D != null && line.getAbscissa(hit3D) > 
line.getAbscissa(point)) {
+            if (hit3D != null &&
+                line.getAbscissa(hit3D) > line.getAbscissa(point)) {
                 final SubHyperplane<Vector3D> facet = boundaryFacet(hit3D, 
node);
                 if (facet != null) {
                     return facet;
@@ -592,7 +594,7 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
          * @param rotation vectorial rotation
          */
         RotationTransform(final Vector3D center, final QuaternionRotation 
rotation) {
-            this.center   = center;
+            this.center = center;
             this.rotation = rotation;
         }
 
@@ -612,26 +614,25 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
         /** {@inheritDoc} */
         @Override
         public SubHyperplane<Vector2D> apply(final SubHyperplane<Vector2D> sub,
-                                                final Hyperplane<Vector3D> 
original,
-                                                final Hyperplane<Vector3D> 
transformed) {
+                                             final Hyperplane<Vector3D> 
original,
+                                             final Hyperplane<Vector3D> 
transformed) {
             if (original != cachedOriginal) {
                 // we have changed hyperplane, reset the in-hyperplane 
transform
 
                 final Plane    oPlane = (Plane) original;
                 final Plane    tPlane = (Plane) transformed;
-                final Vector3D p00    = oPlane.getOrigin();
-                final Vector3D p10    = oPlane.toSpace(Vector2D.of(1.0, 0.0));
-                final Vector3D p01    = oPlane.toSpace(Vector2D.of(0.0, 1.0));
-                final Vector2D tP00   = tPlane.toSubSpace(apply(p00));
-                final Vector2D tP10   = tPlane.toSubSpace(apply(p10));
-                final Vector2D tP01   = tPlane.toSubSpace(apply(p01));
+                final Vector3D p00 = oPlane.getOrigin();
+                final Vector3D p10 = oPlane.toSpace(Vector2D.of(1.0, 0.0));
+                final Vector3D p01 = oPlane.toSpace(Vector2D.of(0.0, 1.0));
+                final Vector2D tP00 = tPlane.toSubSpace(apply(p00));
+                final Vector2D tP10 = tPlane.toSubSpace(apply(p10));
+                final Vector2D tP01 = tPlane.toSubSpace(apply(p01));
 
                 cachedOriginal  = (Plane) original;
                 cachedTransform =
-                        
org.apache.commons.geometry.euclidean.twod.Line.getTransform(
-                                tP00.vectorTo(tP10),
-                                tP00.vectorTo(tP01),
-                                tP00);
+                        
org.apache.commons.geometry.euclidean.twod.Line.getTransform(tP00.vectorTo(tP10),
+                                                                               
      tP00.vectorTo(tP01),
+                                                                               
      tP00);
             }
             return ((SubLine) sub).applyTransform(cachedTransform);
         }
@@ -681,27 +682,23 @@ public class PolyhedronsSet extends 
AbstractRegion<Vector3D, Vector2D> {
         /** {@inheritDoc} */
         @Override
         public SubHyperplane<Vector2D> apply(final SubHyperplane<Vector2D> sub,
-                                                final Hyperplane<Vector3D> 
original,
-                                                final Hyperplane<Vector3D> 
transformed) {
+                                             final Hyperplane<Vector3D> 
original,
+                                             final Hyperplane<Vector3D> 
transformed) {
             if (original != cachedOriginal) {
                 // we have changed hyperplane, reset the in-hyperplane 
transform
 
-                final Plane   oPlane = (Plane) original;
-                final Plane   tPlane = (Plane) transformed;
-                final Vector2D shift  = 
tPlane.toSubSpace(apply(oPlane.getOrigin()));
+                final Plane oPlane = (Plane) original;
+                final Plane tPlane = (Plane) transformed;
+                final Vector2D shift = 
tPlane.toSubSpace(apply(oPlane.getOrigin()));
 
-                cachedOriginal  = (Plane) original;
+                cachedOriginal = (Plane) original;
                 cachedTransform =
-                        
org.apache.commons.geometry.euclidean.twod.Line.getTransform(
-                                Vector2D.PLUS_X,
-                                Vector2D.PLUS_Y,
-                                shift);
+                    
org.apache.commons.geometry.euclidean.twod.Line.getTransform(Vector2D.PLUS_X,
+                                                                               
  Vector2D.PLUS_Y,
+                                                                               
  shift);
             }
 
             return ((SubLine) sub).applyTransform(cachedTransform);
-
         }
-
     }
-
 }

Reply via email to