commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [commons-geometry] 10/12: Indentation.
Date Thu, 28 Nov 2019 14:12:18 GMT
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 ff86e4d06bc0ff2dbe02d5f560d84b607d8ca1d0
Author: Gilles Sadowski <gilles@harfang.homelinux.org>
AuthorDate: Thu Nov 28 14:55:05 2019 +0100

    Indentation.
---
 .../threed/enclosing/SphereGenerator.java          | 56 +++++++++++-----------
 .../euclidean/twod/enclosing/DiskGenerator.java    | 33 ++++++-------
 2 files changed, 42 insertions(+), 47 deletions(-)

diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
index 0b28f16..14cebc5 100644
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
@@ -32,14 +32,12 @@ import org.apache.commons.numbers.fraction.BigFraction;
 /** Class generating an enclosing ball from its support points.
  */
 public class SphereGenerator implements SupportBallGenerator<Vector3D> {
-
     /** Base epsilon value. */
     private static final double BASE_EPS = 1e-10;
 
     /** {@inheritDoc} */
     @Override
     public EnclosingBall<Vector3D> ballOnSupport(final List<Vector3D> support)
{
-
         if (support.isEmpty()) {
             return new EnclosingBall<>(Vector3D.ZERO, Double.NEGATIVE_INFINITY);
         } else {
@@ -50,15 +48,15 @@ public class SphereGenerator implements SupportBallGenerator<Vector3D>
{
                 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),
-                                                                    vA, vB);
+                                               0.5 * vA.distance(vB),
+                                               vA, vB);
                 } else {
                     final Vector3D vC = support.get(2);
                     if (support.size() < 4) {
 
                         // delegate to 2D disk generator
                         final DoublePrecisionContext precision =
-                                new EpsilonDoublePrecisionContext(BASE_EPS * (norm1(vA) +
norm1(vB) + norm1(vC)));
+                            new EpsilonDoublePrecisionContext(BASE_EPS * (norm1(vA) + norm1(vB)
+ norm1(vC)));
                         final Plane p = Plane.fromPoints(vA, vB, vC, precision);
                         final EnclosingBall<Vector2D> disk =
                                 new DiskGenerator().ballOnSupport(Arrays.asList(p.toSubspace(vA),
@@ -112,22 +110,22 @@ public class SphereGenerator implements SupportBallGenerator<Vector3D>
{
                             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 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));
+                        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()),
-                                                                        vA, vB, vC, vD);
+                                                               centerY.doubleValue(),
+                                                               centerZ.doubleValue()),
+                                                   Math.sqrt(r2.doubleValue()),
+                                                   vA, vB, vC, vD);
                     }
                 }
             }
@@ -141,18 +139,18 @@ public class SphereGenerator implements SupportBallGenerator<Vector3D>
{
      * @return value of the minor computed has an exact fraction
      */
     private BigFraction minor(final BigFraction[] c1, final BigFraction[] c2, final BigFraction[]
c3) {
-        return      c2[0].multiply(c3[1]).multiply(c1[2].subtract(c1[3])).
-                add(c2[0].multiply(c3[2]).multiply(c1[3].subtract(c1[1]))).
-                add(c2[0].multiply(c3[3]).multiply(c1[1].subtract(c1[2]))).
-                add(c2[1].multiply(c3[0]).multiply(c1[3].subtract(c1[2]))).
-                add(c2[1].multiply(c3[2]).multiply(c1[0].subtract(c1[3]))).
-                add(c2[1].multiply(c3[3]).multiply(c1[2].subtract(c1[0]))).
-                add(c2[2].multiply(c3[0]).multiply(c1[1].subtract(c1[3]))).
-                add(c2[2].multiply(c3[1]).multiply(c1[3].subtract(c1[0]))).
-                add(c2[2].multiply(c3[3]).multiply(c1[0].subtract(c1[1]))).
-                add(c2[3].multiply(c3[0]).multiply(c1[2].subtract(c1[1]))).
-                add(c2[3].multiply(c3[1]).multiply(c1[0].subtract(c1[2]))).
-                add(c2[3].multiply(c3[2]).multiply(c1[1].subtract(c1[0])));
+        return c2[0].multiply(c3[1]).multiply(c1[2].subtract(c1[3])).
+            add(c2[0].multiply(c3[2]).multiply(c1[3].subtract(c1[1]))).
+            add(c2[0].multiply(c3[3]).multiply(c1[1].subtract(c1[2]))).
+            add(c2[1].multiply(c3[0]).multiply(c1[3].subtract(c1[2]))).
+            add(c2[1].multiply(c3[2]).multiply(c1[0].subtract(c1[3]))).
+            add(c2[1].multiply(c3[3]).multiply(c1[2].subtract(c1[0]))).
+            add(c2[2].multiply(c3[0]).multiply(c1[1].subtract(c1[3]))).
+            add(c2[2].multiply(c3[1]).multiply(c1[3].subtract(c1[0]))).
+            add(c2[2].multiply(c3[3]).multiply(c1[0].subtract(c1[1]))).
+            add(c2[3].multiply(c3[0]).multiply(c1[2].subtract(c1[1]))).
+            add(c2[3].multiply(c3[1]).multiply(c1[0].subtract(c1[2]))).
+            add(c2[3].multiply(c3[2]).multiply(c1[1].subtract(c1[0])));
     }
 
     /** Compute the L<sub>1</sub> vector norm for the given set of coordinates.
diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java
b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java
index 885e089..83c5f43 100644
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java
@@ -26,11 +26,9 @@ import org.apache.commons.numbers.fraction.BigFraction;
 /** Class generating an enclosing ball from its support points.
  */
 public class DiskGenerator implements SupportBallGenerator<Vector2D> {
-
     /** {@inheritDoc} */
     @Override
     public EnclosingBall<Vector2D> ballOnSupport(final List<Vector2D> support)
{
-
         if (support.isEmpty()) {
             return new EnclosingBall<>(Vector2D.ZERO, Double.NEGATIVE_INFINITY);
         } else {
@@ -41,8 +39,8 @@ public class DiskGenerator implements SupportBallGenerator<Vector2D>
{
                 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),
-                                                                    vA, vB);
+                                               0.5 * vA.distance(vB),
+                                               vA, vB);
                 } else {
                     final Vector2D vC = support.get(2);
                     // a disk is 2D can be defined as:
@@ -70,25 +68,25 @@ public class DiskGenerator implements SupportBallGenerator<Vector2D>
{
                         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())
+                        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 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));
+                    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()),
-                                                                    vA, vB, vC);
+                                                           centerY.doubleValue()),
+                                               Math.sqrt(r2.doubleValue()),
+                                               vA, vB, vC);
                 }
             }
         }
@@ -100,9 +98,8 @@ public class DiskGenerator implements SupportBallGenerator<Vector2D>
{
      * @return value of the minor computed has an exact fraction
      */
     private BigFraction minor(final BigFraction[] c1, final BigFraction[] c2) {
-        return      c2[0].multiply(c1[2].subtract(c1[1])).
-                add(c2[1].multiply(c1[0].subtract(c1[2]))).
-                add(c2[2].multiply(c1[1].subtract(c1[0])));
+        return c2[0].multiply(c1[2].subtract(c1[1])).
+            add(c2[1].multiply(c1[0].subtract(c1[2]))).
+            add(c2[2].multiply(c1[1].subtract(c1[0])));
     }
-
 }


Mime
View raw message