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 3f7be19626e2a828ca4595deb6dac4f767f73ce4
Merge: b7f391a adbdc69
Author: Matt Juntunen <matt.juntu...@hotmail.com>
AuthorDate: Thu Sep 13 22:34:19 2018 -0400

    merging with master

 .../geometry/core/internal/SimpleTupleFormat.java    | 20 ++++++++++----------
 .../geometry/enclosing/WelzlEncloser3DTest.java      |  2 +-
 .../commons/geometry/euclidean/oned/Point1D.java     |  2 +-
 .../commons/geometry/euclidean/oned/Vector1D.java    | 11 +++++------
 .../commons/geometry/euclidean/threed/Line.java      |  2 +-
 .../commons/geometry/euclidean/threed/Plane.java     |  4 ++--
 .../commons/geometry/euclidean/threed/Point3D.java   |  2 +-
 .../commons/geometry/euclidean/threed/Rotation.java  |  4 ++--
 .../commons/geometry/euclidean/threed/SubLine.java   |  2 +-
 .../commons/geometry/euclidean/threed/Vector3D.java  | 16 ++++++++--------
 .../commons/geometry/euclidean/twod/NestedLoops.java |  4 ++--
 .../commons/geometry/euclidean/twod/Point2D.java     |  2 +-
 .../commons/geometry/euclidean/twod/Vector2D.java    | 14 +++++++-------
 .../geometry/euclidean/twod/hull/ConvexHull2D.java   |  2 +-
 .../commons/geometry/spherical/oned/S1Point.java     |  2 +-
 .../geometry/spherical/twod/EdgesBuilder.java        |  2 +-
 .../commons/geometry/spherical/twod/S2Point.java     |  2 +-
 .../spherical/twod/SphericalPolygonsSet.java         |  4 ++--
 18 files changed, 48 insertions(+), 49 deletions(-)

diff --cc 
commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
index c5d455d,10fabed..26df5d1
--- 
a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
+++ 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
@@@ -17,10 -17,10 +17,9 @@@
  package org.apache.commons.geometry.euclidean.oned;
  
  import org.apache.commons.geometry.core.Geometry;
- import org.apache.commons.geometry.core.exception.IllegalNormException;
  import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
 -import org.apache.commons.geometry.core.internal.Vectors;
  import org.apache.commons.geometry.euclidean.EuclideanVector;
 -import org.apache.commons.geometry.euclidean.internal.ZeroNormException;
 +import org.apache.commons.geometry.euclidean.internal.Vectors;
  import org.apache.commons.numbers.arrays.LinearCombination;
  
  /** This class represents a vector in one-dimensional Euclidean space.
@@@ -154,10 -159,15 +153,10 @@@ public final class Vector1D extends Car
  
      /** {@inheritDoc} */
      @Override
-     public Vector1D normalize() throws IllegalNormException {
+     public Vector1D normalize() {
 -        final double x = getX();
 -        if (x > 0.0) {
 -            return ONE;
 -        }
 -        else if (x < 0.0) {
 -            return MINUS_ONE;
 -        }
 -        throw new ZeroNormException();
 +        Vectors.checkFiniteNonZeroNorm(getNorm());
 +
 +        return (getX() > 0.0) ? ONE : MINUS_ONE;
      }
  
      /** {@inheritDoc} */
@@@ -200,9 -210,10 +199,9 @@@
       * <p>For the one-dimensional case, this method simply returns the 
current instance.</p>
       */
      @Override
-     public Vector1D project(final Vector1D base) throws IllegalNormException {
+     public Vector1D project(final Vector1D base) {
 -        if (base.getX() == 0) {
 -            throw new ZeroNormException(ZeroNormException.INVALID_BASE);
 -        }
 +        Vectors.checkFiniteNonZeroNorm(base.getNorm());
 +
          return this;
      }
  
@@@ -210,9 -221,10 +209,9 @@@
       * <p>For the one-dimensional case, this method simply returns the zero 
vector.</p>
       */
      @Override
-     public Vector1D reject(final Vector1D base) throws IllegalNormException {
+     public Vector1D reject(final Vector1D base) {
 -        if (base.getX() == 0) {
 -            throw new ZeroNormException(ZeroNormException.INVALID_BASE);
 -        }
 +        Vectors.checkFiniteNonZeroNorm(base.getNorm());
 +
          return Vector1D.ZERO;
      }
  
@@@ -221,10 -233,7 +220,10 @@@
       * the same sign and {@code pi} if they are opposite.</p>
       */
      @Override
-     public double angle(final Vector1D v) throws IllegalNormException {
+     public double angle(final Vector1D v) {
 +        Vectors.checkFiniteNonZeroNorm(getNorm());
 +        Vectors.checkFiniteNonZeroNorm(v.getNorm());
 +
          final double sig1 = Math.signum(getX());
          final double sig2 = Math.signum(v.getX());
  
diff --cc 
commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
index d8de801,75b797a..5c5317c
--- 
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
@@@ -188,8 -188,8 +188,8 @@@ public final class Vector3D extends Car
  
      /** {@inheritDoc} */
      @Override
-     public Vector3D normalize() throws IllegalNormException {
+     public Vector3D normalize() {
 -        return scalarMultiply(1.0 / getNonZeroNorm());
 +        return scalarMultiply(1.0 / getFiniteNonZeroNorm());
      }
  
      /** Get a vector orthogonal to the instance.
@@@ -205,11 -205,10 +205,11 @@@
       *   Vector3D j = Vector3D.crossProduct(k, i);
       * </code></pre>
       * @return a new normalized vector orthogonal to the instance
 -     * @exception IllegalStateException if the norm of the instance is zero
 +     * @exception IllegalNormException if the norm of the instance is zero, 
NaN,
 +     *  or infinite
       */
-     public Vector3D orthogonal() throws IllegalNormException {
+     public Vector3D orthogonal() {
 -        double threshold = 0.6 * getNonZeroNorm();
 +        double threshold = 0.6 * getFiniteNonZeroNorm();
  
          final double x = getX();
          final double y = getY();
@@@ -234,8 -233,8 +234,8 @@@
       * other.</p>
       */
      @Override
-     public double angle(Vector3D v) throws IllegalNormException {
+     public double angle(Vector3D v) {
 -        double normProduct = getNonZeroNorm() * v.getNonZeroNorm();
 +        double normProduct = getFiniteNonZeroNorm() * 
v.getFiniteNonZeroNorm();
  
          double dot = dotProduct(v);
          double threshold = normProduct * 0.9999;
@@@ -383,13 -382,17 +383,13 @@@
          return false;
      }
  
 -    /** Returns the vector norm, throwing an IllegalStateException if the 
norm is zero.
 -     * @return the non-zero norm value
 -     * @throws IllegalStateException if the norm is zero
 +    /** Returns the vector norm, throwing an IllegalNormException if the norm 
is zero,
 +     * NaN, or infinite.
 +     * @return the finite, non-zero norm value
 +     * @throws IllegalNormException if the norm is zero, NaN, or infinite
       */
-     private double getFiniteNonZeroNorm() throws IllegalNormException {
 -    private double getNonZeroNorm() {
 -        final double n = getNorm();
 -        if (n == 0) {
 -            throw new ZeroNormException();
 -        }
 -
 -        return n;
++    private double getFiniteNonZeroNorm() {
 +        return Vectors.checkFiniteNonZeroNorm(getNorm());
      }
  
      /** Returns a component of the current instance relative to the given base
@@@ -401,14 -404,17 +401,14 @@@
       *      is returned.
       * @return The projection or rejection of this instance relative to 
{@code base},
       *      depending on the value of {@code reject}.
 -     * @throws IllegalStateException if {@code base} has a zero norm
 +     * @throws IllegalNormException if {@code base} has a zero, NaN, or 
infinite norm
       */
-     private Vector3D getComponent(Vector3D base, boolean reject) throws 
IllegalNormException {
+     private Vector3D getComponent(Vector3D base, boolean reject) {
          final double aDotB = dotProduct(base);
  
 -        final double baseMagSq = base.getNormSq();
 -        if (baseMagSq == 0.0) {
 -            throw new ZeroNormException(ZeroNormException.INVALID_BASE);
 -        }
 +        final double baseMag = Vectors.checkFiniteNonZeroNorm(base.getNorm());
  
 -        final double scale = aDotB / baseMagSq;
 +        final double scale = aDotB / (baseMag * baseMag);
  
          final double projX = scale * base.getX();
          final double projY = scale * base.getY();
diff --cc 
commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
index 298d052,95313ae..1d7be1c
--- 
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
@@@ -171,8 -171,8 +171,8 @@@ public final class Vector2D extends Car
  
      /** {@inheritDoc} */
      @Override
-     public Vector2D normalize() throws IllegalNormException {
+     public Vector2D normalize() {
 -        return scalarMultiply(1.0 / getNonZeroNorm());
 +        return scalarMultiply(1.0 / getFiniteNonZeroNorm());
      }
  
      /** {@inheritDoc} */
@@@ -231,8 -231,8 +231,8 @@@
       * other.</p>
       */
      @Override
-     public double angle(Vector2D v) throws IllegalNormException {
+     public double angle(Vector2D v) {
 -        double normProduct = getNonZeroNorm() * v.getNonZeroNorm();
 +        double normProduct = getFiniteNonZeroNorm() * 
v.getFiniteNonZeroNorm();
  
          double dot = dotProduct(v);
          double threshold = normProduct * 0.9999;
@@@ -328,13 -328,17 +328,13 @@@
          return false;
      }
  
 -    /** Returns the vector norm, throwing an IllegalStateException if the 
norm is zero.
 -     * @return the non-zero norm value
 -     * @throws IllegalStateException if the norm is zero
 +    /** Returns the vector norm, throwing an IllegalNormException if the norm 
is zero,
 +     * NaN, or infinite.
 +     * @return the finite, non-zero norm value
 +     * @throws IllegalNormException if the norm is zero, NaN, or infinite
       */
-     private double getFiniteNonZeroNorm() throws IllegalNormException {
 -    private double getNonZeroNorm() {
 -        final double n = getNorm();
 -        if (n == 0) {
 -            throw new ZeroNormException();
 -        }
 -
 -        return n;
++    private double getFiniteNonZeroNorm() {
 +        return Vectors.checkFiniteNonZeroNorm(getNorm());
      }
  
      /** Returns a component of the current instance relative to the given base
@@@ -346,14 -350,17 +346,14 @@@
       *      is returned.
       * @return The projection or rejection of this instance relative to 
{@code base},
       *      depending on the value of {@code reject}.
 -     * @throws IllegalStateException if {@code base} has a zero norm
 +     * @throws IllegalNormException if {@code base} has a zero, NaN, or 
infinite norm
       */
-     private Vector2D getComponent(Vector2D base, boolean reject) throws 
IllegalNormException {
+     private Vector2D getComponent(Vector2D base, boolean reject) {
          final double aDotB = dotProduct(base);
  
 -        final double baseMagSq = base.getNormSq();
 -        if (baseMagSq == 0.0) {
 -            throw new ZeroNormException(ZeroNormException.INVALID_BASE);
 -        }
 +        final double baseMag = Vectors.checkFiniteNonZeroNorm(base.getNorm());
  
 -        final double scale = aDotB / baseMagSq;
 +        final double scale = aDotB / (baseMag * baseMag);
  
          final double projX = scale * base.getX();
          final double projY = scale * base.getY();

Reply via email to