You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/12/13 13:39:04 UTC
[commons-geometry] 01/07: GEOMETRY-16: removing custom
GeometryException hierarchy and replacing with standard JDK exceptions
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 56139e84984eb5cd32a3d58406bf9e3219ab6ae1
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Thu Dec 12 21:40:45 2019 -0500
GEOMETRY-16: removing custom GeometryException hierarchy and replacing with standard JDK exceptions
---
.../org/apache/commons/geometry/core/Vector.java | 6 +-
.../geometry/core/exception/GeometryException.java | 34 -------
.../core/exception/GeometryValueException.java | 33 -------
.../core/exception/IllegalNormException.java | 40 --------
.../geometry/core/exception/package-info.java | 23 -----
.../AbstractConvexHyperplaneBoundedRegion.java | 5 +-
.../AbstractConvexHyperplaneBoundedRegionTest.java | 8 +-
.../euclidean/AbstractAffineTransformMatrix.java | 48 ++++++++-
.../geometry/euclidean/EuclideanVector.java | 8 +-
.../euclidean/MultiDimensionalEuclideanVector.java | 13 +--
.../exception/NonInvertibleTransformException.java | 35 -------
.../geometry/euclidean/exception/package-info.java | 23 -----
.../geometry/euclidean/internal/Vectors.java | 29 ++++--
.../euclidean/oned/AffineTransformMatrix1D.java | 23 +----
.../commons/geometry/euclidean/oned/Interval.java | 15 ++-
.../geometry/euclidean/oned/OrientedPoint.java | 10 +-
.../commons/geometry/euclidean/oned/Vector1D.java | 6 +-
.../euclidean/threed/AffineTransformMatrix3D.java | 23 +----
.../geometry/euclidean/threed/ConvexSubPlane.java | 8 +-
.../geometry/euclidean/threed/ConvexVolume.java | 10 +-
.../commons/geometry/euclidean/threed/Line3D.java | 5 +-
.../commons/geometry/euclidean/threed/Plane.java | 18 ++--
.../geometry/euclidean/threed/RegionBSPTree3D.java | 13 ++-
.../geometry/euclidean/threed/SubPlane.java | 9 +-
.../geometry/euclidean/threed/Vector3D.java | 8 +-
.../threed/rotation/QuaternionRotation.java | 24 ++---
.../euclidean/twod/AffineTransformMatrix2D.java | 23 +----
.../geometry/euclidean/twod/ConvexArea.java | 10 +-
.../commons/geometry/euclidean/twod/Line.java | 7 +-
.../geometry/euclidean/twod/RegionBSPTree2D.java | 13 ++-
.../commons/geometry/euclidean/twod/SubLine.java | 9 +-
.../commons/geometry/euclidean/twod/Vector2D.java | 12 +--
.../geometry/euclidean/internal/VectorsTest.java | 32 ++++--
.../oned/AffineTransformMatrix1DTest.java | 22 ++---
.../geometry/euclidean/oned/IntervalTest.java | 13 ++-
.../geometry/euclidean/oned/OrientedPointTest.java | 14 ++-
.../geometry/euclidean/oned/Vector1DTest.java | 61 ++++++------
.../threed/AffineTransformMatrix3DTest.java | 22 ++---
.../geometry/euclidean/threed/Line3DTest.java | 7 +-
.../geometry/euclidean/threed/PlaneTest.java | 34 +++----
.../euclidean/threed/RegionBSPTree3DTest.java | 21 ++--
.../geometry/euclidean/threed/Segment3DTest.java | 11 +--
.../geometry/euclidean/threed/SubPlaneTest.java | 5 +-
.../geometry/euclidean/threed/Vector3DTest.java | 109 ++++++++++-----------
.../threed/rotation/QuaternionRotationTest.java | 49 ++++-----
.../twod/AffineTransformMatrix2DTest.java | 22 ++---
.../geometry/euclidean/twod/ConvexAreaTest.java | 15 ++-
.../commons/geometry/euclidean/twod/LineTest.java | 12 +--
.../euclidean/twod/RegionBSPTree2DTest.java | 21 ++--
.../geometry/euclidean/twod/SegmentTest.java | 11 +--
.../geometry/euclidean/twod/SubLineTest.java | 11 +--
.../geometry/euclidean/twod/Vector2DTest.java | 109 ++++++++++-----------
.../euclidean/twod/hull/MonotoneChain.java | 20 ++--
.../geometry/spherical/oned/AngularInterval.java | 27 +++--
.../commons/geometry/spherical/oned/CutAngle.java | 5 +-
.../commons/geometry/spherical/oned/Point1S.java | 15 ++-
.../geometry/spherical/twod/ConvexArea2S.java | 10 +-
.../commons/geometry/spherical/twod/GreatArc.java | 4 +-
.../geometry/spherical/twod/GreatCircle.java | 15 ++-
.../geometry/spherical/twod/SubGreatCircle.java | 9 +-
.../spherical/oned/AngularIntervalTest.java | 57 ++++++-----
.../geometry/spherical/oned/CutAngleTest.java | 8 +-
.../geometry/spherical/oned/Point1STest.java | 20 ++--
.../geometry/spherical/twod/GreatArcTest.java | 7 +-
.../geometry/spherical/twod/GreatCircleTest.java | 17 ++--
.../spherical/twod/SubGreatCircleTest.java | 11 +--
66 files changed, 566 insertions(+), 811 deletions(-)
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Vector.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Vector.java
index c62abe7..65a009b 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Vector.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Vector.java
@@ -94,8 +94,7 @@ public interface Vector<V extends Vector<V>> extends Spatial {
/** Get a normalized vector aligned with the instance. The returned
* vector has a magnitude of 1.
* @return a new normalized vector
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm is
- * zero, NaN, or infinite
+ * @throws IllegalArgumentException if the norm is zero, NaN, or infinite
*/
V normalize();
@@ -130,8 +129,7 @@ public interface Vector<V extends Vector<V>> extends Spatial {
/** Compute the angular separation between two vectors in radians.
* @param v other vector
* @return angular separation between this instance and v in radians
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if either
- * vector has a zero, NaN, or infinite norm
+ * @throws IllegalArgumentException if either vector has a zero, NaN, or infinite norm
*/
double angle(V v);
}
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/GeometryException.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/GeometryException.java
deleted file mode 100644
index d37bef8..0000000
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/GeometryException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.geometry.core.exception;
-
-/** Base class for geometry exceptions. The semantics of this class
- * are intended to be similar to {@link java.lang.ArithmeticException}
- * but for geometric operations.
- */
-public class GeometryException extends RuntimeException {
-
- /** Serializable version identifier. */
- private static final long serialVersionUID = 20180909L;
-
- /** Simple constructor with error message.
- * @param msg exception message string
- */
- public GeometryException(String msg) {
- super(msg);
- }
-}
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/GeometryValueException.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/GeometryValueException.java
deleted file mode 100644
index 592045b..0000000
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/GeometryValueException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.geometry.core.exception;
-
-/** Exception thrown to indicate that a value used in a geometric operation
- * is not valid.
- */
-public class GeometryValueException extends GeometryException {
-
- /** Serializable version identifier. */
- private static final long serialVersionUID = 20190210L;
-
- /** Simple constructor with error message.
- * @param msg exception message string
- */
- public GeometryValueException(String msg) {
- super(msg);
- }
-}
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/IllegalNormException.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/IllegalNormException.java
deleted file mode 100644
index ad65322..0000000
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/IllegalNormException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.geometry.core.exception;
-
-/** Exception thrown when an illegal vector norm value is encountered
- * in an operation.
- */
-public class IllegalNormException extends GeometryValueException {
-
- /** Serializable version identifier. */
- private static final long serialVersionUID = 20180909L;
-
- /** Simple constructor accepting the illegal norm value.
- * @param norm the illegal norm value
- */
- public IllegalNormException(double norm) {
- super("Illegal norm: " + norm);
- }
-
- /** Constructor accepting an error message.
- * @param msg the error message
- */
- public IllegalNormException(String msg) {
- super(msg);
- }
-}
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/package-info.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/package-info.java
deleted file mode 100644
index 2b7d21b..0000000
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/exception/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *
- * <p>
- * This package contains specialized exception types used by this library.
- * </p>
- */
-package org.apache.commons.geometry.core.exception;
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java
index e1efb4b..bd08b63 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java
@@ -25,7 +25,6 @@ import java.util.function.Function;
import org.apache.commons.geometry.core.Point;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
/** Base class for convex hyperplane-bounded regions. This class provides generic implementations of many
* algorithms related to convex regions.
@@ -304,7 +303,7 @@ public abstract class AbstractConvexHyperplaneBoundedRegion<P extends Point<P>,
* bounded by the given collection of hyperplanes.
* @param bounds hyperplanes defining the convex region
* @return a list of convex subhyperplanes representing the boundaries of the convex region
- * @throws GeometryException if the given hyperplanes do not form a convex region
+ * @throws IllegalArgumentException if the given hyperplanes do not form a convex region
*/
public List<S> build(final Iterable<? extends Hyperplane<P>> bounds) {
@@ -365,7 +364,7 @@ public abstract class AbstractConvexHyperplaneBoundedRegion<P extends Point<P>,
}
if (notConvex || (outerIdx > 0 && boundaries.isEmpty())) {
- throw new GeometryException("Bounding hyperplanes do not produce a convex region: " + bounds);
+ throw new IllegalArgumentException("Bounding hyperplanes do not produce a convex region: " + bounds);
}
return boundaries;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
index f957acb..a33ce68 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
@@ -25,7 +25,6 @@ import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.Region;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partition.test.PartitionTestUtils;
import org.apache.commons.geometry.core.partition.test.TestLine;
import org.apache.commons.geometry.core.partition.test.TestLineSegment;
@@ -475,14 +474,14 @@ public class AbstractConvexHyperplaneBoundedRegionTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
StubRegion.fromBounds(Arrays.asList(TestLine.X_AXIS, TestLine.X_AXIS.reverse()));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
StubRegion.fromBounds(Arrays.asList(
TestLine.X_AXIS,
TestLine.Y_AXIS,
new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -1))));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -539,7 +538,8 @@ public class AbstractConvexHyperplaneBoundedRegionTest {
}
public static StubRegion fromBounds(Iterable<TestLine> boundingLines) {
- final List<TestLineSegment> segments = new ConvexRegionBoundaryBuilder<>(TestLineSegment.class).build(boundingLines);
+ final List<TestLineSegment> segments = new ConvexRegionBoundaryBuilder<>(TestLineSegment.class)
+ .build(boundingLines);
return segments.isEmpty() ? FULL : new StubRegion(segments);
}
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractAffineTransformMatrix.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractAffineTransformMatrix.java
index 8def150..7418b6a 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractAffineTransformMatrix.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractAffineTransformMatrix.java
@@ -16,6 +16,8 @@
*/
package org.apache.commons.geometry.euclidean;
+import org.apache.commons.geometry.euclidean.internal.Vectors;
+
/** Base class for affine transform matrices in Euclidean space.
*
* @param <V> Vector/point implementation type defining the space.
@@ -29,8 +31,7 @@ public abstract class AbstractAffineTransformMatrix<V extends EuclideanVector<V>
*
* @param vec the vector to transform
* @return the new, transformed unit vector
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the transformed vector coordinates
- * cannot be normalized
+ * @throws IllegalArgumentException if the transformed vector coordinates cannot be normalized
* @see #applyVector(EuclideanVector)
*/
public abstract V applyDirection(V vec);
@@ -48,4 +49,47 @@ public abstract class AbstractAffineTransformMatrix<V extends EuclideanVector<V>
public boolean preservesOrientation() {
return determinant() > 0.0;
}
+
+ /** Get the determinant of the instance for use in calculating the matrix
+ * inverse. An {@link IllegalStateException} is thrown if the determinant is
+ * NaN, infinite, or zero.
+ * @return the determinant of the matrix
+ * @throws IllegalStateException if the matrix determinant value is NaN, infinite,
+ * or zero
+ */
+ protected double getDeterminantForInverse() {
+ final double det = determinant();
+ if (!Vectors.isRealNonZero(det)) {
+ nonInvertibleTransform("matrix determinant is " + det);
+ }
+ return det;
+ }
+
+ /** Check that the given matrix element is valid for use in calculation of
+ * a matrix inverse, throwing an {@link IllegalStateException} if not.
+ * @param element matrix entry to check
+ * @throws IllegalStateException if the element is not valid for use
+ * in calculating a matrix inverse, ie if it is NaN or infinite.
+ */
+ protected void validateElementForInverse(final double element) {
+ if (!Double.isFinite(element)) {
+ nonInvertibleTransform("invalid matrix element: " + element);
+ }
+ }
+
+ /** Create an exception indicating that a transform matrix is not able
+ * to be inverted.
+ * @param msg message containing specific information for the failure
+ * @return an exception indicating that a transform matrix is not able
+ * to be inverted
+ */
+
+ /** Throw an exception indicating that the instance is not able to be inverted.
+ * @param msg message containing the specific reason that the matrix cannot
+ * be inverted
+ * @throws IllegalStateException containing the given error message
+ */
+ protected void nonInvertibleTransform(final String msg) {
+ throw new IllegalStateException("Transform is not invertible; " + msg);
+ }
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java
index 6695023..dee78b5 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanVector.java
@@ -45,7 +45,7 @@ public abstract class EuclideanVector<V extends EuclideanVector<V>>
* @param v the vector that the returned vector will be directed toward
* @return unit vector representing the direction of displacement <em>from</em> this vector
* <em>to</em> the given vector
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the vector pointing
+ * @throws IllegalArgumentException if the norm of the vector pointing
* from this instance to {@code v} is zero, NaN, or infinite
*/
public abstract V directionTo(V v);
@@ -91,12 +91,10 @@ public abstract class EuclideanVector<V extends EuclideanVector<V>>
return eq(getZero(), precision);
}
- /** Return the vector norm value, throwing an
- * {@link org.apache.commons.geometry.core.exception.IllegalNormException} if the value is not real
+ /** Return the vector norm value, throwing an {@link IllegalArgumentException} if the value is not real
* (ie, NaN or infinite) or zero.
* @return the vector norm value, guaranteed to be real and non-zero
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the vector norm is
- * zero, NaN, or infinite
+ * @throws IllegalArgumentException if the vector norm is zero, NaN, or infinite
*/
protected double getCheckedNorm() {
return Vectors.checkedNorm(this);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/MultiDimensionalEuclideanVector.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/MultiDimensionalEuclideanVector.java
index 85c1d27..213818d 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/MultiDimensionalEuclideanVector.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/MultiDimensionalEuclideanVector.java
@@ -31,8 +31,7 @@ public abstract class MultiDimensionalEuclideanVector<V extends MultiDimensional
* </code>
* @param base base vector
* @return the vector projection of the instance onto {@code base}
- * @exception org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the base vector is
- * zero, NaN, or infinite
+ * @exception IllegalArgumentException if the norm of the base vector is zero, NaN, or infinite
* @see #reject(MultiDimensionalEuclideanVector)
*/
public abstract V project(V base);
@@ -47,16 +46,14 @@ public abstract class MultiDimensionalEuclideanVector<V extends MultiDimensional
* </code>
* @param base base vector
* @return the vector rejection of the instance from {@code base}
- * @exception org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the base vector is
- * zero, NaN, or infinite
+ * @exception IllegalArgumentException if the norm of the base vector is zero, NaN, or infinite
* @see #project(MultiDimensionalEuclideanVector)
*/
public abstract V reject(V base);
/** Get a unit vector orthogonal to the instance.
* @return a unit vector orthogonal to the current instance
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the current instance
- * is zero, NaN, or infinite
+ * @throws IllegalArgumentException if the norm of the current instance is zero, NaN, or infinite
*/
public abstract V orthogonal();
@@ -66,8 +63,8 @@ public abstract class MultiDimensionalEuclideanVector<V extends MultiDimensional
* @param dir the direction to use for generating the orthogonal vector
* @return unit vector orthogonal to the current vector and pointing in the direction of
* {@code dir} that does not lie along the current vector
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if either vector norm is
- * zero, NaN or infinite, or the given vector is collinear with this vector.
+ * @throws IllegalArgumentException if either vector norm is zero, NaN or infinite, or the
+ * given vector is collinear with this vector.
*/
public abstract V orthogonal(V dir);
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/exception/NonInvertibleTransformException.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/exception/NonInvertibleTransformException.java
deleted file mode 100644
index 916c75c..0000000
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/exception/NonInvertibleTransformException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.geometry.euclidean.exception;
-
-import org.apache.commons.geometry.core.exception.GeometryException;
-
-/** Exception thrown when a transform matrix is not
- * able to be inverted.
- */
-public class NonInvertibleTransformException extends GeometryException {
-
- /** Serializable version identifier. */
- private static final long serialVersionUID = 20180927L;
-
- /** Simple constructor accepting an error message.
- * @param msg error message
- */
- public NonInvertibleTransformException(String msg) {
- super(msg);
- }
-}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/exception/package-info.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/exception/package-info.java
deleted file mode 100644
index d441d1d..0000000
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/exception/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *
- * <p>
- * This package provides exception types for Euclidean space.
- * </p>
- */
-package org.apache.commons.geometry.euclidean.exception;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/Vectors.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/Vectors.java
index 755eaeb..3e29b44 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/Vectors.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/internal/Vectors.java
@@ -17,7 +17,6 @@
package org.apache.commons.geometry.euclidean.internal;
import org.apache.commons.geometry.core.Vector;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
/** This class consists exclusively of static vector utility methods.
*/
@@ -36,33 +35,47 @@ public final class Vectors {
return Double.isFinite(value) && value != 0.0;
}
- /** Throws an {@link IllegalNormException} if the given norm value
+ /** Throws an {@link IllegalArgumentException} if the given norm value
* is not real (ie, not NaN or infinite) or zero. The argument is returned
* to allow this method to be called inline.
* @param norm vector norm value
* @return the validated norm value
- * @throws IllegalNormException if the given norm value is NaN, infinite,
- * or zero
+ * @throws IllegalArgumentException if the given norm value is NaN, infinite,
+ * or zero
*/
public static double checkedNorm(final double norm) {
if (!isRealNonZero(norm)) {
- throw new IllegalNormException(norm);
+ throw new IllegalArgumentException("Illegal norm: " + norm);
}
return norm;
}
- /** Returns the vector's norm value, throwing an {@link IllegalNormException} if the value
+ /** Returns the vector's norm value, throwing an {@link IllegalArgumentException} if the value
* is not real (ie, not NaN or infinite) or zero.
* @param vec vector to obtain the real, non-zero norm of
* @return the validated norm value
- * @throws IllegalNormException if the vector norm value is NaN, infinite,
- * or zero
+ * @throws IllegalArgumentException if the vector norm value is NaN, infinite,
+ * or zero
*/
public static double checkedNorm(final Vector<?> vec) {
return checkedNorm(vec.norm());
}
+ /** Attempt to normalize the given vector, returning null if the vector cannot be normalized
+ * due to the norm being NaN, infinite, or null.
+ * @param <V> Vector implementation type
+ * @param vec the vector to attempt to normalize
+ * @return the normalized vector if successful, otherwise null
+ */
+ public static <V extends Vector<V>> V tryNormalize(final V vec) {
+ final double norm = vec.norm();
+ if (isRealNonZero(norm)) {
+ return vec.normalize();
+ }
+ return null;
+ }
+
/** Get the L<sub>2</sub> norm (commonly known as the Euclidean norm) for the vector
* with the given components. This corresponds to the common notion of vector magnitude
* or length and is defined as the square root of the sum of the squares of all vector components.
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1D.java
index b8e124f..13d9255 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1D.java
@@ -18,8 +18,6 @@ package org.apache.commons.geometry.euclidean.oned;
import org.apache.commons.geometry.core.internal.DoubleFunction1N;
import org.apache.commons.geometry.euclidean.AbstractAffineTransformMatrix;
-import org.apache.commons.geometry.euclidean.exception.NonInvertibleTransformException;
-import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.numbers.core.Precision;
/** Class using a matrix to represent affine transformations in 1 dimensional Euclidean space.
@@ -209,15 +207,11 @@ public final class AffineTransformMatrix1D extends AbstractAffineTransformMatrix
/** Get a new transform representing the inverse of the current instance.
* @return inverse transform
- * @throws NonInvertibleTransformException if the transform matrix cannot be inverted
+ * @throws IllegalStateException if the transform matrix cannot be inverted
*/
public AffineTransformMatrix1D inverse() {
- final double det = this.m00;
-
- if (!Vectors.isRealNonZero(det)) {
- throw new NonInvertibleTransformException("Transform is not invertible; matrix determinant is " + det);
- }
+ final double det = getDeterminantForInverse();
validateElementForInverse(m01);
@@ -360,17 +354,4 @@ public final class AffineTransformMatrix1D extends AbstractAffineTransformMatrix
return new AffineTransformMatrix1D(c00, c01);
}
-
- /** Checks that the given matrix element is valid for use in calculation of
- * a matrix inverse. Throws a {@link NonInvertibleTransformException} if not.
- * @param element matrix entry to check
- * @throws NonInvertibleTransformException if the element is not valid for use
- * in calculating a matrix inverse, ie if it is NaN or infinite.
- */
- private static void validateElementForInverse(final double element) {
- if (!Double.isFinite(element)) {
- throw new NonInvertibleTransformException("Transform is not invertible; invalid matrix element: " +
- element);
- }
- }
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java
index 206f8c5..9d3470e 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java
@@ -20,7 +20,6 @@ import java.text.MessageFormat;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.HyperplaneBoundedRegion;
import org.apache.commons.geometry.core.partitioning.HyperplaneLocation;
@@ -356,7 +355,7 @@ public final class Interval implements HyperplaneBoundedRegion<Vector1D> {
* @param b second point location
* @param precision precision context used to compare floating point numbers
* @return a new interval representing the region between the given point locations
- * @throws GeometryException if either number is {@link Double#NaN NaN} or the numbers
+ * @throws IllegalArgumentException if either number is {@link Double#NaN NaN} or the numbers
* are both infinite and have the same sign
*/
public static Interval of(final double a, final double b, final DoublePrecisionContext precision) {
@@ -386,7 +385,7 @@ public final class Interval implements HyperplaneBoundedRegion<Vector1D> {
* @param b second point
* @param precision precision context used to compare floating point numbers
* @return a new interval representing the region between the given points
- * @throws GeometryException if either point is {@link Vector1D#isNaN() NaN} or the points
+ * @throws IllegalArgumentException if either point is {@link Vector1D#isNaN() NaN} or the points
* are both {@link Vector1D#isInfinite() infinite} and have the same sign
*/
public static Interval of(final Vector1D a, final Vector1D b, final DoublePrecisionContext precision) {
@@ -401,7 +400,7 @@ public final class Interval implements HyperplaneBoundedRegion<Vector1D> {
* @param a first hyperplane; may be null
* @param b second hyperplane; may be null
* @return a new interval representing the region between the given hyperplanes
- * @throws GeometryException if the hyperplanes have the same orientation or
+ * @throws IllegalArgumentException if the hyperplanes have the same orientation or
* do not form an interval (for example, if the positive-facing hyperplane is below
* the negative-facing hyperplane)
*/
@@ -413,13 +412,13 @@ public final class Interval implements HyperplaneBoundedRegion<Vector1D> {
if (a != null && b != null) {
// both hyperplanes are present, so validate then against each other
if (a.isPositiveFacing() == b.isPositiveFacing()) {
- throw new GeometryException(
+ throw new IllegalArgumentException(
MessageFormat.format("Invalid interval: hyperplanes have same orientation: {0}, {1}", a, b));
}
if (a.classify(b.getPoint()) == HyperplaneLocation.PLUS ||
b.classify(a.getPoint()) == HyperplaneLocation.PLUS) {
- throw new GeometryException(
+ throw new IllegalArgumentException(
MessageFormat.format("Invalid interval: hyperplanes do not form interval: {0}, {1}", a, b));
}
@@ -497,14 +496,14 @@ public final class Interval implements HyperplaneBoundedRegion<Vector1D> {
* must not be NaN and if infinite, must have opposite signs.
* @param a first value
* @param b second value
- * @throws GeometryException if either value is NaN or if both values are infinite
+ * @throws IllegalArgumentException if either value is NaN or if both values are infinite
* and have the same sign
*/
private static void validateIntervalValues(final double a, final double b) {
if (Double.isNaN(a) || Double.isNaN(b) ||
(Double.isInfinite(a) && Double.compare(a, b) == 0)) {
- throw new GeometryException(
+ throw new IllegalArgumentException(
MessageFormat.format("Invalid interval values: [{0}, {1}]", a, b));
}
}
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 63a1698..83e4c85 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
@@ -22,8 +22,6 @@ import java.util.Objects;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.internal.Equivalency;
import org.apache.commons.geometry.core.partitioning.AbstractHyperplane;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
@@ -282,13 +280,13 @@ public final class OrientedPoint extends AbstractHyperplane<Vector1D>
* @param direction the direction of the plus side of the hyperplane
* @param precision precision context used to compare floating point values
* @return a new instance oriented in the given direction
- * @throws GeometryValueException if the direction is zero as evaluated by the
+ * @throws IllegalArgumentException if the direction is zero as evaluated by the
* given precision context
*/
public static OrientedPoint fromPointAndDirection(final Vector1D point, final Vector1D direction,
final DoublePrecisionContext precision) {
if (direction.isZero(precision)) {
- throw new GeometryValueException("Oriented point direction cannot be zero");
+ throw new IllegalArgumentException("Oriented point direction cannot be zero");
}
final boolean positiveFacing = direction.getX() > 0;
@@ -520,13 +518,15 @@ public final class OrientedPoint extends AbstractHyperplane<Vector1D>
/** Validate the given subhyperplane lies on the same hyperplane.
* @param sub subhyperplane to validate
+ * @throws IllegalArgumentException if the argument does not lie on
+ * the same hyperplane as this instance
*/
private void validateHyperplane(final SubHyperplane<Vector1D> sub) {
final OrientedPoint baseHyper = base.getHyperplane();
final OrientedPoint inputHyper = (OrientedPoint) sub.getHyperplane();
if (!baseHyper.eq(inputHyper)) {
- throw new GeometryException("Argument is not on the same " +
+ throw new IllegalArgumentException("Argument is not on the same " +
"hyperplane. Expected " + baseHyper + " but was " +
inputHyper);
}
diff --git 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
index e4e921a..ba05189 100644
--- 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
@@ -420,8 +420,7 @@ public class Vector1D extends EuclideanVector<Vector1D> {
*
* @param x Vector coordinate.
* @return a vector whose norm is 1.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given value is
- * zero, NaN, or infinite
+ * @throws IllegalArgumentException if the norm of the given value is zero, NaN, or infinite
*/
public static Unit from(double x) {
Vectors.checkedNorm(Vectors.norm(x));
@@ -433,8 +432,7 @@ public class Vector1D extends EuclideanVector<Vector1D> {
*
* @param v Vector.
* @return a vector whose norm is 1.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given value is
- * zero, NaN, or infinite
+ * @throws IllegalArgumentException if the norm of the given value is zero, NaN, or infinite
*/
public static Unit from(Vector1D v) {
return v instanceof Unit ?
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3D.java
index a07fc2a..bbcef53 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3D.java
@@ -18,9 +18,7 @@ package org.apache.commons.geometry.euclidean.threed;
import org.apache.commons.geometry.core.internal.DoubleFunction3N;
import org.apache.commons.geometry.euclidean.AbstractAffineTransformMatrix;
-import org.apache.commons.geometry.euclidean.exception.NonInvertibleTransformException;
import org.apache.commons.geometry.euclidean.internal.Matrices;
-import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.geometry.euclidean.threed.rotation.QuaternionRotation;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.Precision;
@@ -327,18 +325,14 @@ public final class AffineTransformMatrix3D extends AbstractAffineTransformMatrix
/** Get a new transform representing the inverse of the current instance.
* @return inverse transform
- * @throws NonInvertibleTransformException if the transform matrix cannot be inverted
+ * @throws IllegalStateException if the transform matrix cannot be inverted
*/
public AffineTransformMatrix3D inverse() {
// Our full matrix is 4x4 but we can significantly reduce the amount of computations
// needed here since we know that our last row is [0 0 0 1].
- final double det = determinant();
-
- if (!Vectors.isRealNonZero(det)) {
- throw new NonInvertibleTransformException("Transform is not invertible; matrix determinant is " + det);
- }
+ final double det = getDeterminantForInverse();
// validate the remaining matrix elements that were not part of the determinant
validateElementForInverse(m03);
@@ -648,17 +642,4 @@ public final class AffineTransformMatrix3D extends AbstractAffineTransformMatrix
c20, c21, c22, c23
);
}
-
- /** Checks that the given matrix element is valid for use in calculation of
- * a matrix inverse. Throws a {@link NonInvertibleTransformException} if not.
- * @param element matrix entry to check
- * @throws NonInvertibleTransformException if the element is not valid for use
- * in calculating a matrix inverse, ie if it is NaN or infinite.
- */
- private static void validateElementForInverse(final double element) {
- if (!Double.isFinite(element)) {
- throw new NonInvertibleTransformException("Transform is not invertible; invalid matrix element: " +
- element);
- }
- }
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlane.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlane.java
index 51e0cf7..3d42a6d 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlane.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlane.java
@@ -114,8 +114,7 @@ public final class ConvexSubPlane extends AbstractSubPlane<ConvexArea>
* @param pts collection of points defining the convex subplane
* @param precision precision context used to compare floating point values
* @return a new instance defined by the given sequence of vertices
- * @throws IllegalArgumentException if fewer than 3 vertices are given
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the vertices do not define a
+ * @throws IllegalArgumentException if fewer than 3 vertices are given or the vertices do not define a
* unique plane
* @see #fromVertices(Collection, DoublePrecisionContext)
* @see #fromVertices(Collection, boolean, DoublePrecisionContext)
@@ -131,8 +130,7 @@ public final class ConvexSubPlane extends AbstractSubPlane<ConvexArea>
* @param pts collection of points defining the convex subplane
* @param precision precision context used to compare floating point values
* @return a new instance defined by the given sequence of vertices
- * @throws IllegalArgumentException if fewer than 3 vertices are given
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the vertices do not define a
+ * @throws IllegalArgumentException if fewer than 3 vertices are given or the vertices do not define a
* unique plane
* @see #fromVertexLoop(Collection, DoublePrecisionContext)
* @see #fromVertices(Collection, boolean, DoublePrecisionContext)
@@ -151,6 +149,8 @@ public final class ConvexSubPlane extends AbstractSubPlane<ConvexArea>
* the vertex sequence is taken as-is
* @param precision precision context used to compare floating point values
* @return a new convex subplane instance
+ * @throws IllegalArgumentException if fewer than 3 vertices are given or the vertices do not define a
+ * unique plane
* @see #fromVertexLoop(Collection, DoublePrecisionContext)
* @see #fromVertices(Collection, DoublePrecisionContext)
* @see Plane#fromPoints(Collection, DoublePrecisionContext)
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 269ba5a..74ded24 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
@@ -156,9 +156,8 @@ public final class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Ve
* @return a new convex volume instance representing the volume on the minus side of all
* of the bounding plane or an instance representing the full space if the collection
* is empty
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the given set of bounding
- * planes do not form a convex volume, meaning that there is no region that is on the minus side
- * of all of the bounding planes.
+ * @throws IllegalArgumentException if the given set of bounding planes do not form a convex volume,
+ * meaning that there is no region that is on the minus side of all of the bounding planes.
*/
public static ConvexVolume fromBounds(final Plane... planes) {
return fromBounds(Arrays.asList(planes));
@@ -172,9 +171,8 @@ public final class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Ve
* @return a new convex volume instance representing the volume on the minus side of all
* of the bounding plane or an instance representing the full space if the collection
* is empty
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the given set of bounding planes
- * do not form a convex volume, meaning that there is no region that is on the minus side of all of
- * the bounding planes.
+ * @throws IllegalArgumentException if the given set of bounding planes do not form a convex volume,
+ * meaning that there is no region that is on the minus side of all of the bounding planes.
*/
public static ConvexVolume fromBounds(final Iterable<Plane> boundingPlanes) {
final List<ConvexSubPlane> subplanes = new ConvexRegionBoundaryBuilder<>(ConvexSubPlane.class)
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 d1d5b2f..36cf00a 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
@@ -361,8 +361,7 @@ public final class Line3D implements Embedding<Vector3D, Vector1D> {
* @param precision floating point precision context
* @return a new line instance that contains both of the given point and that has
* a direction going from the first point to the second point
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the points lie too close to
- * create a non-zero direction vector
+ * @throws IllegalArgumentException if the points lie too close to reate a non-zero direction vector
*/
public static Line3D fromPoints(final Vector3D p1, final Vector3D p2,
final DoublePrecisionContext precision) {
@@ -375,7 +374,7 @@ public final class Line3D implements Embedding<Vector3D, Vector1D> {
* @param precision floating point precision context
* @return a new line instance that contains the given point and points in the
* given direction
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the direction cannot be normalized
+ * @throws IllegalArgumentException if the direction cannot be normalized
*/
public static Line3D fromPointAndDirection(final Vector3D pt, final Vector3D direction,
final DoublePrecisionContext precision) {
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 4fa7081..cf0873b 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
@@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.Objects;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.internal.Equivalency;
import org.apache.commons.geometry.core.partitioning.AbstractHyperplane;
import org.apache.commons.geometry.core.partitioning.EmbeddingHyperplane;
@@ -585,8 +584,7 @@ public final class Plane extends AbstractHyperplane<Vector3D>
* @param v v vector (on plane)
* @param precision precision context used to compare floating point values
* @return a new plane
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given
- * values is zero, NaN, or infinite.
+ * @throws IllegalArgumentException if the norm of the given values is zero, NaN, or infinite.
*/
public static Plane fromPointAndPlaneVectors(final Vector3D p, final Vector3D u, final Vector3D v,
final DoublePrecisionContext precision) {
@@ -604,8 +602,7 @@ public final class Plane extends AbstractHyperplane<Vector3D>
* @param normal normal direction to the plane
* @param precision precision context used to compare floating point values
* @return a new plane
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given
- * values is zero, NaN, or infinite.
+ * @throws IllegalArgumentException if the norm of the given values is zero, NaN, or infinite.
*/
public static Plane fromNormal(final Vector3D normal, final DoublePrecisionContext precision) {
return fromPointAndNormal(Vector3D.ZERO, normal, precision);
@@ -618,8 +615,7 @@ public final class Plane extends AbstractHyperplane<Vector3D>
* @param normal normal direction to the plane
* @param precision precision context used to compare floating point values
* @return a new plane
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given
- * values is zero, NaN, or infinite.
+ * @throws IllegalArgumentException 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) {
@@ -643,7 +639,7 @@ public final class Plane extends AbstractHyperplane<Vector3D>
* @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
+ * @throws IllegalArgumentException if the points do not define a unique plane
*/
public static Plane fromPoints(final Vector3D p1, final Vector3D p2, final Vector3D p3,
final DoublePrecisionContext precision) {
@@ -660,8 +656,8 @@ public final class Plane extends AbstractHyperplane<Vector3D>
* @param pts collection of sequenced points lying on the plane
* @param precision precision context used to compare floating point values
* @return a new plane containing the given points
- * @throws IllegalArgumentException if the given collection does not contain at least 3 points
- * @throws GeometryException if the points do not define a unique plane
+ * @throws IllegalArgumentException if the given collection does not contain at least 3 points or the
+ * points do not define a unique plane
*/
public static Plane fromPoints(final Collection<Vector3D> pts, final DoublePrecisionContext precision) {
@@ -730,7 +726,7 @@ public final class Plane extends AbstractHyperplane<Vector3D>
}
if (u == null || w == null || nonPlanar) {
- throw new GeometryException("Points do not define a plane: " + pts);
+ throw new IllegalArgumentException("Points do not define a plane: " + pts);
}
if (w.dot(Vector3D.of(crossSumX, crossSumY, crossSumZ)) < 0) {
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 bf9848d..a37be39 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
@@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SubHyperplane;
@@ -387,7 +386,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
* @param center the cube center point
* @param size the size of the cube
* @return this builder instance
- * @throws GeometryValueException if the width, height, or depth of the defined region is zero
+ * @throws IllegalArgumentException if the width, height, or depth of the defined region is zero
* as evaluated by the precision context.
*/
public Builder addCenteredCube(final Vector3D center, final double size) {
@@ -398,7 +397,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
* @param corner a corner of the cube
* @param size the size of the cube
* @return this builder instance
- * @throws GeometryValueException if the width, height, or depth of the defined region is zero
+ * @throws IllegalArgumentException if the width, height, or depth of the defined region is zero
* as evaluated by the precision context.
*/
public Builder addCube(final Vector3D corner, final double size) {
@@ -412,7 +411,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
* @param ySize size of the prism along the y-axis
* @param zSize size of the prism along the z-axis
* @return this builder instance
- * @throws GeometryValueException if the width, height, or depth of the defined region is zero
+ * @throws IllegalArgumentException if the width, height, or depth of the defined region is zero
* as evaluated by the precision context.
*/
public Builder addCenteredRect(final Vector3D center, final double xSize, final double ySize,
@@ -436,7 +435,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
* @param zDelta distance to move along the z axis to place the other points in the
* prism; this value may be negative.
* @return this builder instance
- * @throws GeometryValueException if the width, height, or depth of the defined region is zero
+ * @throws IllegalArgumentException if the width, height, or depth of the defined region is zero
* as evaluated by the precision context.
*/
public Builder addRect(final Vector3D pt, final double xDelta, final double yDelta, final double zDelta) {
@@ -451,7 +450,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
* @param a first corner point in the rectangular prism (opposite of {@code b})
* @param b second corner point in the rectangular prism (opposite of {@code a})
* @return this builder instance
- * @throws GeometryValueException if the width, height, or depth of the defined region is zero
+ * @throws IllegalArgumentException if the width, height, or depth of the defined region is zero
* as evaluated by the precision context.
*/
public Builder addRect(final Vector3D a, final Vector3D b) {
@@ -465,7 +464,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
final double maxZ = Math.max(a.getZ(), b.getZ());
if (precision.eq(minX, maxX) || precision.eq(minY, maxY) || precision.eq(minZ, maxZ)) {
- throw new GeometryValueException("Rectangular prism has zero size: " + a + ", " + b + ".");
+ throw new IllegalArgumentException("Rectangular prism has zero size: " + a + ", " + b + ".");
}
final Vector3D[] vertices = {
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java
index 562efed..e738536 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.Split;
@@ -115,7 +114,7 @@ public final class SubPlane extends AbstractSubPlane<RegionBSPTree2D> {
/** Add a convex subplane to this instance.
* @param subplane convex subplane to add
- * @throws GeometryException if the given convex subplane is not from
+ * @throws IllegalArgumentException if the given convex subplane is not from
* a plane equivalent to this instance
*/
public void add(final ConvexSubPlane subplane) {
@@ -126,7 +125,7 @@ public final class SubPlane extends AbstractSubPlane<RegionBSPTree2D> {
/** Add a subplane to this instance.
* @param subplane subplane to add
- * @throws GeometryException if the given convex subplane is not from
+ * @throws IllegalArgumentException if the given convex subplane is not from
* a plane equivalent to this instance
*/
public void add(final SubPlane subplane) {
@@ -138,14 +137,14 @@ public final class SubPlane extends AbstractSubPlane<RegionBSPTree2D> {
/** Validate that the given plane is equivalent to the plane
* defining this subplane.
* @param inputPlane plane to validate
- * @throws GeometryException if the given plane is not equivalent
+ * @throws IllegalArgumentException if the given plane is not equivalent
* to the plane for this instance
*/
private void validatePlane(final Plane inputPlane) {
final Plane plane = getPlane();
if (!plane.eq(inputPlane)) {
- throw new GeometryException("Argument is not on the same " +
+ throw new IllegalArgumentException("Argument is not on the same " +
"plane. Expected " + plane + " but was " +
inputPlane);
}
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 3beeba2..0961718 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
@@ -334,7 +334,7 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
* Vector3D j = k.cross(i);
* </code></pre>
* @return a unit vector orthogonal to the instance
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the instance
+ * @throws IllegalArgumentException if the norm of the instance
* is zero, NaN, or infinite
*/
@Override
@@ -453,7 +453,7 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
* @param <V> Vector implementation type
* @return The projection or rejection of this instance relative to {@code base},
* depending on the value of {@code reject}.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if {@code base} has a zero, NaN,
+ * @throws IllegalArgumentException if {@code base} has a zero, NaN,
* or infinite norm
*/
private <V extends Vector3D> V getComponent(Vector3D base, boolean reject, DoubleFunction3N<V> factory) {
@@ -630,7 +630,7 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
* @param y Vector coordinate.
* @param z Vector coordinate.
* @return a vector whose norm is 1.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given value
+ * @throws IllegalArgumentException if the norm of the given value
* is zero, NaN, or infinite
*/
public static Unit from(final double x, final double y, final double z) {
@@ -643,7 +643,7 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
*
* @param v Vector.
* @return a vector whose norm is 1.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given
+ * @throws IllegalArgumentException if the norm of the given
* value is zero, NaN, or infinite
*/
public static Unit from(final Vector3D v) {
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 16f4a0f..258a885 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
@@ -18,13 +18,11 @@ package org.apache.commons.geometry.euclidean.threed.rotation;
import java.util.Objects;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.core.internal.GeometryInternalError;
import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.geometry.euclidean.threed.AffineTransformMatrix3D;
import org.apache.commons.geometry.euclidean.threed.Vector3D;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.quaternion.Quaternion;
import org.apache.commons.numbers.quaternion.Slerp;
@@ -84,13 +82,10 @@ public final class QuaternionRotation implements Rotation3D {
*/
@Override
public Vector3D getAxis() {
- // the most straightforward way to check if we have a normalizable
- // vector is to just try to normalize it and see if we fail
- try {
- return Vector3D.Unit.from(quat.getX(), quat.getY(), quat.getZ());
- } catch (IllegalNormException exc) {
- return Vector3D.Unit.PLUS_X;
- }
+ final Vector3D axis = Vectors.tryNormalize(Vector3D.of(quat.getX(), quat.getY(), quat.getZ()));
+ return (axis != null) ?
+ axis :
+ Vector3D.Unit.PLUS_X;
}
/**
@@ -568,8 +563,7 @@ public final class QuaternionRotation implements Rotation3D {
* @param angle angle of rotation in radians
* @return a new instance representing the defined rotation
*
- * @throws IllegalNormException if the given axis cannot be normalized
- * @throws GeometryValueException if the angle is NaN or infinite
+ * @throws IllegalArgumentException if the given axis cannot be normalized or the angle is NaN or infinite
*/
public static QuaternionRotation fromAxisAngle(final Vector3D axis, final double angle) {
// reference formula:
@@ -577,7 +571,7 @@ public final class QuaternionRotation implements Rotation3D {
final Vector3D normAxis = axis.normalize();
if (!Double.isFinite(angle)) {
- throw new GeometryValueException("Invalid angle: " + angle);
+ throw new IllegalArgumentException("Invalid angle: " + angle);
}
final double halfAngle = 0.5 * angle;
@@ -603,7 +597,7 @@ public final class QuaternionRotation implements Rotation3D {
* @param u origin vector
* @param v target vector
* @return a new instance that rotates {@code u} to point in the direction of {@code v}
- * @throws IllegalNormException if either vector has a norm of zero, NaN, or infinity
+ * @throws IllegalArgumentException if either vector has a norm of zero, NaN, or infinity
*/
public static QuaternionRotation createVectorRotation(final Vector3D u, final Vector3D v) {
@@ -666,7 +660,7 @@ public final class QuaternionRotation implements Rotation3D {
* @param v1 first vector of the target basis
* @param v2 second vector of the target basis
* @return an instance that rotates the source basis to the target basis
- * @throws IllegalNormException if any of the input vectors cannot be normalized
+ * @throws IllegalArgumentException if any of the input vectors cannot be normalized
* or the vectors defining either basis are colinear
*/
public static QuaternionRotation createBasisRotation(final Vector3D u1, final Vector3D u2,
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2D.java
index 788e258..df0ad11 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2D.java
@@ -18,9 +18,7 @@ package org.apache.commons.geometry.euclidean.twod;
import org.apache.commons.geometry.core.internal.DoubleFunction2N;
import org.apache.commons.geometry.euclidean.AbstractAffineTransformMatrix;
-import org.apache.commons.geometry.euclidean.exception.NonInvertibleTransformException;
import org.apache.commons.geometry.euclidean.internal.Matrices;
-import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.Precision;
@@ -286,18 +284,14 @@ public final class AffineTransformMatrix2D extends AbstractAffineTransformMatrix
/** Get a new transform representing the inverse of the current instance.
* @return inverse transform
- * @throws NonInvertibleTransformException if the transform matrix cannot be inverted
+ * @throws IllegalStateException if the transform matrix cannot be inverted
*/
public AffineTransformMatrix2D inverse() {
// Our full matrix is 3x3 but we can significantly reduce the amount of computations
// needed here since we know that our last row is [0 0 1].
- final double det = determinant();
-
- if (!Vectors.isRealNonZero(det)) {
- throw new NonInvertibleTransformException("Transform is not invertible; matrix determinant is " + det);
- }
+ final double det = getDeterminantForInverse();
// validate the remaining matrix elements that were not part of the determinant
validateElementForInverse(m02);
@@ -561,17 +555,4 @@ public final class AffineTransformMatrix2D extends AbstractAffineTransformMatrix
c10, c11, c12
);
}
-
- /** Checks that the given matrix element is valid for use in calculation of
- * a matrix inverse. Throws a {@link NonInvertibleTransformException} if not.
- * @param element matrix entry to check
- * @throws NonInvertibleTransformException if the element is not valid for use
- * in calculating a matrix inverse, ie if it is NaN or infinite.
- */
- private static void validateElementForInverse(final double element) {
- if (!Double.isFinite(element)) {
- throw new NonInvertibleTransformException(
- "Transform is not invertible; invalid matrix element: " + element);
- }
- }
}
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 e272193..bc5acc3 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
@@ -263,9 +263,8 @@ public final class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vect
* @return a new convex area instance representing the area on the minus side of all
* of the bounding lines or an instance representing the full area if no lines are
* given
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the given set of bounding lines do
- * not form a convex area, meaning that there is no region that is on the minus side of all of the bounding
- * lines.
+ * @throws IllegalArgumentException if the given set of bounding lines do not form a convex area,
+ * meaning that there is no region that is on the minus side of all of the bounding lines.
*/
public static ConvexArea fromBounds(final Line... bounds) {
return fromBounds(Arrays.asList(bounds));
@@ -279,9 +278,8 @@ public final class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vect
* @return a new convex area instance representing the area on the minus side of all
* of the bounding lines or an instance representing the full area if the collection
* is empty
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the given set of bounding lines do
- * not form a convex area, meaning that there is no region that is on the minus side of all of the bounding
- * lines.
+ * @throws IllegalArgumentException if the given set of bounding lines do not form a convex area,
+ * meaning that there is no region that is on the minus side of all of the bounding lines.
*/
public static ConvexArea fromBounds(final Iterable<Line> bounds) {
final List<Segment> segments = new ConvexRegionBoundaryBuilder<>(Segment.class).build(bounds);
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 d21d692..517968b 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
@@ -19,7 +19,6 @@ package org.apache.commons.geometry.euclidean.twod;
import java.util.Objects;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.internal.Equivalency;
import org.apache.commons.geometry.core.partitioning.AbstractHyperplane;
import org.apache.commons.geometry.core.partitioning.EmbeddingHyperplane;
@@ -509,7 +508,7 @@ public final class Line extends AbstractHyperplane<Vector2D>
* @param precision precision context used to compare floating point values
* @return new line containing {@code p1} and {@code p2} and pointing in the direction
* from {@code p1} to {@code p2}
- * @throws GeometryValueException If the vector between {@code p1} and {@code p2} has zero length,
+ * @throws IllegalArgumentException If the vector between {@code p1} and {@code p2} has zero length,
* as evaluated by the given precision context
*/
public static Line fromPoints(final Vector2D p1, final Vector2D p2, final DoublePrecisionContext precision) {
@@ -521,13 +520,13 @@ public final class Line extends AbstractHyperplane<Vector2D>
* @param dir the direction of the line
* @param precision precision context used to compare floating point values
* @return new line containing {@code pt} and pointing in direction {@code dir}
- * @throws GeometryValueException If {@code dir} has zero length, as evaluated by the
+ * @throws IllegalArgumentException If {@code dir} has zero length, as evaluated by the
* given precision context
*/
public static Line fromPointAndDirection(final Vector2D pt, final Vector2D dir,
final DoublePrecisionContext precision) {
if (dir.isZero(precision)) {
- throw new GeometryValueException("Line direction cannot be zero");
+ throw new IllegalArgumentException("Line direction cannot be zero");
}
final Vector2D normalizedDir = dir.normalize();
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 293a80a..29e1a76 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
@@ -21,7 +21,6 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree;
@@ -376,7 +375,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
* @param center center point of the square
* @param size the size of the square
* @return this builder instance
- * @throws GeometryValueException if the width or height of the defined rectangle is zero
+ * @throws IllegalArgumentException if the width or height of the defined rectangle is zero
* as evaluated by the precision context.
*/
public Builder addCenteredSquare(final Vector2D center, final double size) {
@@ -387,7 +386,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
* @param corner point in the corner of the square
* @param size the size of the square
* @return this builder instance
- * @throws GeometryValueException if the width or height of the defined rectangle is zero
+ * @throws IllegalArgumentException if the width or height of the defined rectangle is zero
* as evaluated by the precision context.
*/
public Builder addSquare(final Vector2D corner, final double size) {
@@ -399,7 +398,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
* @param xSize size along the x-axis
* @param ySize size along the y-axis
* @return this builder instance
- * @throws GeometryValueException if the width or height of the defined rectangle is zero
+ * @throws IllegalArgumentException if the width or height of the defined rectangle is zero
* as evaluated by the precision context.
*/
public Builder addCenteredRect(final Vector2D center, final double xSize, final double ySize) {
@@ -423,7 +422,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
* rectangle; this value may be negative, in which case {@code pt} will lie
* on the top of the rectangle
* @return this builder instance
- * @throws GeometryValueException if the width or height of the defined rectangle is zero
+ * @throws IllegalArgumentException if the width or height of the defined rectangle is zero
* as evaluated by the precision context.
*/
public Builder addRect(final Vector2D pt, final double xDelta, final double yDelta) {
@@ -437,7 +436,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
* @param a first corner point in the rectangle (opposite of {@code b})
* @param b second corner point in the rectangle (opposite of {@code a})
* @return this builder instance
- * @throws GeometryValueException if the width or height of the defined rectangle is zero
+ * @throws IllegalArgumentException if the width or height of the defined rectangle is zero
* as evaluated by the precision context.
*/
public Builder addRect(final Vector2D a, final Vector2D b) {
@@ -448,7 +447,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
final double maxY = Math.max(a.getY(), b.getY());
if (precision.eq(minX, maxX) || precision.eq(minY, maxY)) {
- throw new GeometryValueException("Rectangle has zero size: " + a + ", " + b + ".");
+ throw new IllegalArgumentException("Rectangle has zero size: " + a + ", " + b + ".");
}
final Vector2D lowerLeft = Vector2D.of(minX, minY);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java
index ffc050a..dba65a4 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.Split;
@@ -116,7 +115,7 @@ public final class SubLine extends AbstractSubLine {
/** Add a line segment to this instance..
* @param segment line segment to add
- * @throws GeometryException if the given line segment is not from
+ * @throws IllegalArgumentException if the given line segment is not from
* a line equivalent to this instance
*/
public void add(final Segment segment) {
@@ -128,7 +127,7 @@ public final class SubLine extends AbstractSubLine {
/** Add the region represented by the given subline to this instance.
* The argument is not modified.
* @param subline subline to add
- * @throws GeometryException if the given subline is not from
+ * @throws IllegalArgumentException if the given subline is not from
* a line equivalent to this instance
*/
public void add(final SubLine subline) {
@@ -159,14 +158,14 @@ public final class SubLine extends AbstractSubLine {
/** Validate that the given line is equivalent to the line
* defining this subline.
* @param inputLine the line to validate
- * @throws GeometryException if the given line is not equivalent
+ * @throws IllegalArgumentException if the given line is not equivalent
* to the line for this instance
*/
private void validateLine(final Line inputLine) {
final Line line = getLine();
if (!line.eq(inputLine)) {
- throw new GeometryException("Argument is not on the same " +
+ throw new IllegalArgumentException("Argument is not on the same " +
"line. Expected " + line + " but was " +
inputLine);
}
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 815587a..a2e3869 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
@@ -279,8 +279,7 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
* called on a vector pointing along the positive x-axis, then a unit vector representing
* the positive y-axis is returned.
* @return a unit vector orthogonal to the current instance
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the current instance
- * is zero, NaN, or infinite
+ * @throws IllegalArgumentException if the norm of the current instance is zero, NaN, or infinite
*/
@Override
public Vector2D.Unit orthogonal() {
@@ -397,8 +396,7 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
* @param <T> Vector implementation type
* @return The projection or rejection of this instance relative to {@code base},
* depending on the value of {@code reject}.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if {@code base} has a
- * zero, NaN, or infinite norm
+ * @throws IllegalArgumentException if {@code base} has a zero, NaN, or infinite norm
*/
private <T extends Vector2D> T getComponent(final Vector2D base, final boolean reject,
final DoubleFunction2N<T> factory) {
@@ -564,8 +562,7 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
* @param x Vector coordinate.
* @param y Vector coordinate.
* @return a vector whose norm is 1.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given value
- * is zero, NaN, or infinite
+ * @throws IllegalArgumentException if the norm of the given value is zero, NaN, or infinite
*/
public static Unit from(final double x, final double y) {
final double invNorm = 1 / Vectors.checkedNorm(Vectors.norm(x, y));
@@ -577,8 +574,7 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
*
* @param v Vector.
* @return a vector whose norm is 1.
- * @throws org.apache.commons.geometry.core.exception.IllegalNormException if the norm of the given
- * value is zero, NaN, or infinite
+ * @throws IllegalArgumentException if the norm of the given value is zero, NaN, or infinite
*/
public static Unit from(final Vector2D v) {
return v instanceof Unit ?
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java
index dbd4551..f3be7c1 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.geometry.euclidean.internal;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
+import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.oned.Vector1D;
import org.apache.commons.geometry.euclidean.threed.Vector3D;
import org.junit.Assert;
@@ -54,13 +54,13 @@ public class VectorsTest {
Assert.assertEquals(-2e-12, Vectors.checkedNorm(-2e-12), EPS);
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(0.0),
- IllegalNormException.class, "Illegal norm: 0.0");
+ IllegalArgumentException.class, "Illegal norm: 0.0");
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Double.NaN),
- IllegalNormException.class, "Illegal norm: NaN");
+ IllegalArgumentException.class, "Illegal norm: NaN");
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Double.POSITIVE_INFINITY),
- IllegalNormException.class, "Illegal norm: Infinity");
+ IllegalArgumentException.class, "Illegal norm: Infinity");
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Double.NEGATIVE_INFINITY),
- IllegalNormException.class, "Illegal norm: -Infinity");
+ IllegalArgumentException.class, "Illegal norm: -Infinity");
}
@Test
@@ -75,13 +75,27 @@ public class VectorsTest {
Assert.assertEquals(2e-12, Vectors.checkedNorm(Vector1D.of(-2e-12)), EPS);
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.ZERO),
- IllegalNormException.class, "Illegal norm: 0.0");
+ IllegalArgumentException.class, "Illegal norm: 0.0");
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.NaN),
- IllegalNormException.class, "Illegal norm: NaN");
+ IllegalArgumentException.class, "Illegal norm: NaN");
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.POSITIVE_INFINITY),
- IllegalNormException.class, "Illegal norm: Infinity");
+ IllegalArgumentException.class, "Illegal norm: Infinity");
GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.NEGATIVE_INFINITY),
- IllegalNormException.class, "Illegal norm: Infinity");
+ IllegalArgumentException.class, "Illegal norm: Infinity");
+ }
+
+ @Test
+ public void testTryNormalize() {
+ // act/assert
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X,
+ Vectors.tryNormalize(Vector3D.of(2, 0, 0)), EPS);
+
+ Assert.assertNull(Vectors.tryNormalize(Vector3D.of(0, 0, 0)));
+ Assert.assertNull(Vectors.tryNormalize(Vector3D.of(-0, 0, 0)));
+
+ Assert.assertNull(Vectors.tryNormalize(Vector3D.of(Double.NaN, 1, 1)));
+ Assert.assertNull(Vectors.tryNormalize(Vector3D.of(1, Double.POSITIVE_INFINITY, 1)));
+ Assert.assertNull(Vectors.tryNormalize(Vector3D.of(1, 1, Double.NEGATIVE_INFINITY)));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
index 9e6d634..7bb748b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
@@ -16,11 +16,9 @@
*/
package org.apache.commons.geometry.euclidean.oned;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
-import org.apache.commons.geometry.euclidean.exception.NonInvertibleTransformException;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -407,9 +405,9 @@ public class AffineTransformMatrix1DTest {
public void testApplyDirection_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.createScale(0).applyDirection(Vector1D.Unit.PLUS),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.createScale(2).applyDirection(Vector1D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -601,31 +599,31 @@ public class AffineTransformMatrix1DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix1D.of(0, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is 0.0");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is 0.0");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix1D.of(Double.NaN, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is NaN");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix1D.of(Double.NEGATIVE_INFINITY, 0.0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is -Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is -Infinity");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix1D.of(Double.POSITIVE_INFINITY, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is Infinity");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix1D.of(1, Double.NaN).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: NaN");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix1D.of(1, Double.NEGATIVE_INFINITY).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: -Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: -Infinity");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix1D.of(1, Double.POSITIVE_INFINITY).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: Infinity");
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
index dd79284..8b6f12a 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
@@ -18,7 +18,6 @@ package org.apache.commons.geometry.euclidean.oned;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
@@ -65,7 +64,7 @@ public class IntervalTest {
@Test
public void testOf_doubles_invalidIntervals() {
// arrange
- Class<?> excType = GeometryException.class;
+ Class<?> excType = IllegalArgumentException.class;
// act/assert
GeometryTestUtils.assertThrows(() -> Interval.of(1, Double.NaN, TEST_PRECISION), excType);
@@ -89,7 +88,7 @@ public class IntervalTest {
@Test
public void testOf_points_invalidIntervals() {
// arrange
- Class<?> excType = GeometryException.class;
+ Class<?> excType = IllegalArgumentException.class;
// act/assert
GeometryTestUtils.assertThrows(
@@ -139,7 +138,7 @@ public class IntervalTest {
@Test
public void testOf_hyperplanes_invalidArgs() {
// arrange
- Class<?> excType = GeometryException.class;
+ Class<?> excType = IllegalArgumentException.class;
// act/assert
GeometryTestUtils.assertThrows(
@@ -184,7 +183,7 @@ public class IntervalTest {
@Test
public void testPoint_invalidArgs() {
// arrange
- Class<?> excType = GeometryException.class;
+ Class<?> excType = IllegalArgumentException.class;
// act/assert
GeometryTestUtils.assertThrows(
@@ -209,7 +208,7 @@ public class IntervalTest {
@Test
public void testMin_invalidArgs() {
// arrange
- Class<?> excType = GeometryException.class;
+ Class<?> excType = IllegalArgumentException.class;
// act/assert
GeometryTestUtils.assertThrows(
@@ -232,7 +231,7 @@ public class IntervalTest {
@Test
public void testMax_invalidArgs() {
// arrange
- Class<?> excType = GeometryException.class;
+ Class<?> excType = IllegalArgumentException.class;
// act/assert
GeometryTestUtils.assertThrows(
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
index d322ea9..dc7b2fe 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
@@ -21,8 +21,6 @@ import java.util.List;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.partitioning.HyperplaneLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SubHyperplane;
@@ -119,7 +117,7 @@ public class OrientedPointTest {
// act/assert
GeometryTestUtils.assertThrows(
() -> pt.transform(zeroScale),
- GeometryValueException.class, "Oriented point direction cannot be zero");
+ IllegalArgumentException.class, "Oriented point direction cannot be zero");
}
@Test
@@ -374,10 +372,10 @@ public class OrientedPointTest {
// act/assert
GeometryTestUtils.assertThrows(
() -> OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(0.09), precision),
- GeometryValueException.class, "Oriented point direction cannot be zero");
+ IllegalArgumentException.class, "Oriented point direction cannot be zero");
GeometryTestUtils.assertThrows(
() -> OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(-0.09), precision),
- GeometryValueException.class, "Oriented point direction cannot be zero");
+ IllegalArgumentException.class, "Oriented point direction cannot be zero");
}
@Test
@@ -588,14 +586,14 @@ public class OrientedPointTest {
// act/assert
GeometryTestUtils.assertThrows(
() -> builder.add(OrientedPoint.createPositiveFacing(2e-3, precision).span()),
- GeometryException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
() -> builder.add(OrientedPoint.createNegativeFacing(2e-3, precision).span()),
- GeometryException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
() -> builder.add((SubHyperplane<Vector1D>) OrientedPoint.createPositiveFacing(2e-3, precision).span()),
- GeometryException.class);
+ IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index 3df8825..604c177 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -19,11 +19,10 @@ package org.apache.commons.geometry.euclidean.oned;
import java.util.Comparator;
import java.util.regex.Pattern;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -47,13 +46,13 @@ public class Vector1DTest {
public void testConstants_normalize() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.NaN.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.POSITIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
Assert.assertSame(Vector1D.Unit.PLUS, Vector1D.Unit.PLUS.normalize());
Assert.assertSame(Vector1D.Unit.MINUS, Vector1D.Unit.MINUS.normalize());
@@ -186,13 +185,13 @@ public class Vector1DTest {
public void testWithNorm_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.NaN.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.POSITIVE_INFINITY.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -285,13 +284,13 @@ public class Vector1DTest {
public void testNormalize_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector1D.of(0.0).normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.of(Double.NaN).normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.of(Double.POSITIVE_INFINITY).normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.of(Double.NEGATIVE_INFINITY).normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -412,22 +411,22 @@ public class Vector1DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.NaN.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.POSITIVE_INFINITY.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -474,15 +473,15 @@ public class Vector1DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.directionTo(Vector1D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.directionTo(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.directionTo(Vector1D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.directionTo(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.directionTo(Vector1D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -672,13 +671,13 @@ public class Vector1DTest {
@Test
public void testUnitFrom_illegalNorm() {
GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(0.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(Double.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(Double.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(Double.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
index 58a8cea..9b206e8 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
@@ -16,14 +16,12 @@
*/
package org.apache.commons.geometry.euclidean.threed;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils.PermuteCallback3D;
-import org.apache.commons.geometry.euclidean.exception.NonInvertibleTransformException;
import org.apache.commons.geometry.euclidean.threed.rotation.QuaternionRotation;
import org.apache.commons.geometry.euclidean.threed.rotation.StandardRotations;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -626,9 +624,9 @@ public class AffineTransformMatrix3DTest {
public void testApplyDirection_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.createScale(1, 0, 1).applyDirection(Vector3D.Unit.PLUS_Y),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.createScale(2).applyDirection(Vector3D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -950,49 +948,49 @@ public class AffineTransformMatrix3DTest {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is 0.0");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is 0.0");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, Double.NaN, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is NaN");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, Double.NEGATIVE_INFINITY, 0, 0,
0, 0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is NaN");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix3D.of(
Double.POSITIVE_INFINITY, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is NaN");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, Double.NaN,
0, 1, 0, 0,
0, 0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: NaN");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, 1, 0, Double.POSITIVE_INFINITY,
0, 0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: Infinity");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, Double.NEGATIVE_INFINITY).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: -Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: -Infinity");
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java
index 84e111a..3d75c04 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java
@@ -16,15 +16,14 @@
*/
package org.apache.commons.geometry.euclidean.threed;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.oned.Interval;
import org.apache.commons.geometry.euclidean.oned.Vector1D;
import org.apache.commons.geometry.euclidean.threed.rotation.QuaternionRotation;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -59,7 +58,7 @@ public class Line3DTest {
Assert.assertSame(TEST_PRECISION, line.getPrecision());
}
- @Test(expected = IllegalNormException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFromPointAndDirection_illegalDirectionNorm() {
// act/assert
Line3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.ZERO, TEST_PRECISION);
@@ -76,7 +75,7 @@ public class Line3DTest {
Assert.assertSame(TEST_PRECISION, line.getPrecision());
}
- @Test(expected = IllegalNormException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFromPoints_pointsTooClose() {
// act/assert
Line3D.fromPoints(Vector3D.of(1, 1, 1), Vector3D.of(1, 1, 1 + 1e-16), TEST_PRECISION);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
index ac2c381..1f750b8 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
@@ -20,10 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.GeometryException;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
@@ -31,6 +28,7 @@ import org.apache.commons.geometry.euclidean.threed.Plane.SubspaceTransform;
import org.apache.commons.geometry.euclidean.threed.rotation.QuaternionRotation;
import org.apache.commons.geometry.euclidean.twod.AffineTransformMatrix2D;
import org.apache.commons.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -65,7 +63,7 @@ public class PlaneTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Plane.fromNormal(Vector3D.ZERO, TEST_PRECISION);
- }, IllegalNormException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -90,7 +88,7 @@ public class PlaneTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Plane.fromPointAndNormal(pt, Vector3D.ZERO, TEST_PRECISION);
- }, IllegalNormException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -119,22 +117,22 @@ public class PlaneTest {
// identical vectors
GeometryTestUtils.assertThrows(() -> {
Plane.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), TEST_PRECISION);
- }, IllegalNormException.class);
+ }, IllegalArgumentException.class);
// zero vector
GeometryTestUtils.assertThrows(() -> {
Plane.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.ZERO, TEST_PRECISION);
- }, IllegalNormException.class);
+ }, IllegalArgumentException.class);
// collinear vectors
GeometryTestUtils.assertThrows(() -> {
Plane.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 2), TEST_PRECISION);
- }, IllegalNormException.class);
+ }, IllegalArgumentException.class);
// collinear vectors - reversed
GeometryTestUtils.assertThrows(() -> {
Plane.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, -2), TEST_PRECISION);
- }, IllegalNormException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -177,19 +175,19 @@ public class PlaneTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(a, a, a, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(a, a, b, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(a, b, a, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(b, a, a, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -386,7 +384,7 @@ public class PlaneTest {
Vector3D.Unit.PLUS_X,
Vector3D.of(2, 0, 0)
), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(Arrays.asList(
@@ -395,7 +393,7 @@ public class PlaneTest {
Vector3D.of(2, 0, 0),
Vector3D.of(3, 0, 0)
), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -408,7 +406,7 @@ public class PlaneTest {
Vector3D.of(1e-12, 1e-12, 0),
Vector3D.Unit.PLUS_X
), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(Arrays.asList(
@@ -416,7 +414,7 @@ public class PlaneTest {
Vector3D.of(1e-12, 0, 0),
Vector3D.ZERO
), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -429,7 +427,7 @@ public class PlaneTest {
Vector3D.Unit.PLUS_Y,
Vector3D.Unit.PLUS_Z
), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
index c063dfe..970a7ee 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
@@ -22,17 +22,16 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.Region;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.threed.RegionBSPTree3D.RegionNode3D;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -1321,27 +1320,27 @@ public class RegionBSPTree3DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addRect(Vector3D.ZERO, 1e-20, 1, 1);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addRect(Vector3D.ZERO, 1, 1e-20, 1);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addRect(Vector3D.ZERO, 1, 1, 1e-20);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addRect(Vector3D.ZERO, 0, 0, 0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addRect(Vector3D.of(1, 2, 3), Vector3D.of(1, 2, 3));
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addCenteredRect(Vector3D.of(1, 2, 3), 0, 0, 0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -1369,15 +1368,15 @@ public class RegionBSPTree3DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addCube(Vector3D.ZERO, 1e-20);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addCube(Vector3D.of(1, 2, 3), 1e-20);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
RegionBSPTree3D.builder(TEST_PRECISION).addCenteredCube(Vector3D.of(1, 2, 3), 0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Segment3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Segment3DTest.java
index 8979f97..dd06cbd 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Segment3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Segment3DTest.java
@@ -16,16 +16,15 @@
*/
package org.apache.commons.geometry.euclidean.threed;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.oned.Interval;
import org.apache.commons.geometry.euclidean.oned.Vector1D;
import org.apache.commons.geometry.euclidean.threed.rotation.QuaternionRotation;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -64,19 +63,19 @@ public class Segment3DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Segment3D.fromPoints(p0, p0, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Segment3D.fromPoints(p0, Vector3D.POSITIVE_INFINITY, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Segment3D.fromPoints(p0, Vector3D.NEGATIVE_INFINITY, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Segment3D.fromPoints(p0, Vector3D.NaN, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java
index 1ca6474..285d063 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java
@@ -22,7 +22,6 @@ import java.util.List;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.HyperplaneBoundedRegion;
@@ -452,13 +451,13 @@ public class SubPlaneTest {
sp.add(ConvexSubPlane.fromConvexArea(
Plane.fromPointAndPlaneVectors(Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X, TEST_PRECISION),
ConvexArea.full()));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
sp.add(new SubPlane(
Plane.fromPointAndPlaneVectors(Vector3D.of(0, 0, -1), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION),
false));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index b163f78..793b3e5 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -20,12 +20,11 @@ package org.apache.commons.geometry.euclidean.threed;
import java.util.Comparator;
import java.util.regex.Pattern;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.numbers.core.Precision;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
@@ -59,13 +58,13 @@ public class Vector3DTest {
public void testConstants_normalize() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NaN.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
Assert.assertSame(Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_X.normalize());
Assert.assertSame(Vector3D.Unit.MINUS_X, Vector3D.Unit.MINUS_X.normalize());
@@ -269,13 +268,13 @@ public class Vector3DTest {
public void testWithNorm_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NaN.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -409,13 +408,13 @@ public class Vector3DTest {
public void testNormalize_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NaN.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -448,13 +447,13 @@ public class Vector3DTest {
public void testOrthogonal_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NaN.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -474,35 +473,35 @@ public class Vector3DTest {
public void testOrthogonal_givenDirection_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NaN.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
public void testOrthogonal_givenDirection_directionIsCollinear() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.MINUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.of(1.0, 1.0, 1.0).orthogonal(Vector3D.of(2.0, 2.0, 2.0)),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.of(-1.01, -1.01, -1.01).orthogonal(Vector3D.of(20.1, 20.1, 20.1)),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -534,22 +533,22 @@ public class Vector3DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NaN.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -806,13 +805,13 @@ public class Vector3DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> v.project(Vector3D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.project(Vector3D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.project(Vector3D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.project(Vector3D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -852,13 +851,13 @@ public class Vector3DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -954,15 +953,15 @@ public class Vector3DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.directionTo(Vector3D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> p.directionTo(p),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> p.directionTo(Vector3D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.directionTo(p),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> p.directionTo(Vector3D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -1201,13 +1200,13 @@ public class Vector3DTest {
@Test
public void testUnitFrom_static_illegalNorm() {
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(0.0, 0.0, 0.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(Double.NaN, 1.0, 1.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(1.0, Double.NEGATIVE_INFINITY, 1.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(1.0, 1.0, Double.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
index cb61ef0..636971e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
@@ -21,10 +21,7 @@ import java.util.List;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.threed.AffineTransformMatrix3D;
@@ -258,21 +255,25 @@ public class QuaternionRotationTest {
@Test
public void testFromAxisAngle_invalidAxisNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.ZERO, PlaneAngleRadians.PI_OVER_TWO), IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.NaN, PlaneAngleRadians.PI_OVER_TWO), IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.NEGATIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), IllegalNormException.class);
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.ZERO, PlaneAngleRadians.PI_OVER_TWO),
+ IllegalArgumentException.class);
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.NaN, PlaneAngleRadians.PI_OVER_TWO),
+ IllegalArgumentException.class);
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO),
+ IllegalArgumentException.class);
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.NEGATIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO),
+ IllegalArgumentException.class);
}
@Test
public void testFromAxisAngle_invalidAngle() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NaN), GeometryValueException.class,
- "Invalid angle: NaN");
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.POSITIVE_INFINITY), GeometryValueException.class,
- "Invalid angle: Infinity");
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NEGATIVE_INFINITY), GeometryValueException.class,
- "Invalid angle: -Infinity");
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NaN),
+ IllegalArgumentException.class, "Invalid angle: NaN");
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.POSITIVE_INFINITY),
+ IllegalArgumentException.class, "Invalid angle: Infinity");
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NEGATIVE_INFINITY),
+ IllegalArgumentException.class, "Invalid angle: -Infinity");
}
@Test
@@ -1165,16 +1166,16 @@ public class QuaternionRotationTest {
public void testCreateVectorRotation_invalidArgs() {
// act/assert
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.ZERO, Vector3D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.NaN, Vector3D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -1353,24 +1354,24 @@ public class QuaternionRotationTest {
// act/assert
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
Vector3D.Unit.PLUS_X, Vector3D.NaN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.POSITIVE_INFINITY, Vector3D.Unit.MINUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_Y),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
index e855811..88c3a6c 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
@@ -16,11 +16,9 @@
*/
package org.apache.commons.geometry.euclidean.twod;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
-import org.apache.commons.geometry.euclidean.exception.NonInvertibleTransformException;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -626,9 +624,9 @@ public class AffineTransformMatrix2DTest {
public void testApplyDirection_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.createScale(1, 0).applyDirection(Vector2D.Unit.PLUS_Y),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.createScale(2).applyDirection(Vector2D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -921,43 +919,43 @@ public class AffineTransformMatrix2DTest {
AffineTransformMatrix2D.of(
0, 0, 0,
0, 0, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is 0.0");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is 0.0");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix2D.of(
1, 0, 0,
0, Double.NaN, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is NaN");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix2D.of(
1, 0, 0,
0, Double.NEGATIVE_INFINITY, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is -Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is -Infinity");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix2D.of(
Double.POSITIVE_INFINITY, 0, 0,
0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; matrix determinant is Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; matrix determinant is Infinity");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix2D.of(
1, 0, Double.NaN,
0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: NaN");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: NaN");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix2D.of(
1, 0, Double.POSITIVE_INFINITY,
0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: Infinity");
GeometryTestUtils.assertThrows(() -> {
AffineTransformMatrix2D.of(
1, 0, Double.NEGATIVE_INFINITY,
0, 1, 0).inverse();
- }, NonInvertibleTransformException.class, "Transform is not invertible; invalid matrix element: -Infinity");
+ }, IllegalStateException.class, "Transform is not invertible; invalid matrix element: -Infinity");
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
index 8c8cc44..c961f28 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
@@ -21,15 +21,14 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -777,7 +776,7 @@ public class ConvexAreaTest {
Vector2D.Unit.PLUS_X,
Vector2D.ZERO
),TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -814,7 +813,7 @@ public class ConvexAreaTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
ConvexArea.fromVertexLoop(Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -894,7 +893,7 @@ public class ConvexAreaTest {
Vector2D.of(1, 1),
Vector2D.Unit.PLUS_X
),TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -956,7 +955,7 @@ public class ConvexAreaTest {
Vector2D.of(1, 1),
Vector2D.Unit.PLUS_X
),TEST_PRECISION));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -1174,7 +1173,7 @@ public class ConvexAreaTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
ConvexArea.fromBounds(a, b, c);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -1186,7 +1185,7 @@ public class ConvexAreaTest {
Line.fromPointAndAngle(Vector2D.of(0, -1), PlaneAngleRadians.PI, TEST_PRECISION),
Line.fromPointAndAngle(Vector2D.ZERO, PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)
));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
private static void checkRegion(ConvexArea area, RegionLocation loc, Vector2D ... pts) {
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
index 798ce03..551f0c8 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
@@ -16,9 +16,7 @@
*/
package org.apache.commons.geometry.euclidean.twod;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
@@ -59,9 +57,9 @@ public class LineTest {
public void testFromPoints_pointsTooClose() {
// act/assert
GeometryTestUtils.assertThrows(() -> Line.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.Unit.PLUS_X, TEST_PRECISION),
- GeometryValueException.class, "Line direction cannot be zero");
+ IllegalArgumentException.class, "Line direction cannot be zero");
GeometryTestUtils.assertThrows(() -> Line.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.of(1 + 1e-11, 1e-11), TEST_PRECISION),
- GeometryValueException.class, "Line direction cannot be zero");
+ IllegalArgumentException.class, "Line direction cannot be zero");
}
@Test
@@ -84,9 +82,9 @@ public class LineTest {
public void testFromPointAndDirection_directionIsZero() {
// act/assert
GeometryTestUtils.assertThrows(() -> Line.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.ZERO, TEST_PRECISION),
- GeometryValueException.class, "Line direction cannot be zero");
+ IllegalArgumentException.class, "Line direction cannot be zero");
GeometryTestUtils.assertThrows(() -> Line.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.of(1e-11, -1e-12), TEST_PRECISION),
- GeometryValueException.class, "Line direction cannot be zero");
+ IllegalArgumentException.class, "Line direction cannot be zero");
}
@Test
@@ -1060,7 +1058,7 @@ public class LineTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
line.transform(scaleCollapse);
- }, GeometryValueException.class, "Line direction cannot be zero");
+ }, IllegalArgumentException.class, "Line direction cannot be zero");
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
index c480be1..e377a44 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
@@ -22,11 +22,9 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.Region;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
@@ -34,6 +32,7 @@ import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.oned.Interval;
import org.apache.commons.geometry.euclidean.twod.RegionBSPTree2D.RegionNode2D;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -922,39 +921,39 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
builder.addRect(Vector2D.of(1, 1), 0, 2);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addRect(Vector2D.of(1, 1), 2, 0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addRect(Vector2D.of(2, 3), 0, 0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addRect(Vector2D.of(1, 1), Vector2D.of(1, 3));
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addRect(Vector2D.of(1, 1), Vector2D.of(3, 1));
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addRect(Vector2D.of(2, 3), Vector2D.of(2, 3));
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addCenteredRect(Vector2D.of(2, 3), 0, 1e-20);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addSquare(Vector2D.of(2, 3), 1e-20);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.addCenteredSquare(Vector2D.of(2, 3), 0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
index 8e82edf..3c7a57c 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
@@ -18,10 +18,8 @@ package org.apache.commons.geometry.euclidean.twod;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.partitioning.HyperplaneLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
@@ -29,6 +27,7 @@ import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.apache.commons.geometry.euclidean.oned.Interval;
import org.apache.commons.geometry.euclidean.oned.Vector1D;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -67,19 +66,19 @@ public class SegmentTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Segment.fromPoints(p0, p0, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Segment.fromPoints(p0, Vector2D.POSITIVE_INFINITY, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Segment.fromPoints(p0, Vector2D.NEGATIVE_INFINITY, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Segment.fromPoints(p0, Vector2D.NaN, TEST_PRECISION);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java
index c7455da..abd4686 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java
@@ -18,10 +18,8 @@ package org.apache.commons.geometry.euclidean.twod;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.HyperplaneBoundedRegion;
@@ -35,6 +33,7 @@ import org.apache.commons.geometry.euclidean.oned.Interval;
import org.apache.commons.geometry.euclidean.oned.RegionBSPTree1D;
import org.apache.commons.geometry.euclidean.oned.Vector1D;
import org.apache.commons.geometry.euclidean.twod.SubLine.SubLineBuilder;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -223,11 +222,11 @@ public class SubLineTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
subline.add(Segment.fromInterval(otherLine, 0, 1));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
subline.add(new SubLine(otherLine));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -593,11 +592,11 @@ public class SubLineTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
builder.add(Segment.fromInterval(otherLine, 0, 1));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.add(new SubLine(otherLine));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index 1e76c86..51f03f7 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
@@ -19,12 +19,11 @@ package org.apache.commons.geometry.euclidean.twod;
import java.util.Comparator;
import java.util.regex.Pattern;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.IllegalNormException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -50,13 +49,13 @@ public class Vector2DTest {
public void testConstants_normalize() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NaN.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
Assert.assertSame(Vector2D.Unit.PLUS_X, Vector2D.Unit.PLUS_X.normalize());
Assert.assertSame(Vector2D.Unit.MINUS_X, Vector2D.Unit.MINUS_X.normalize());
@@ -229,13 +228,13 @@ public class Vector2DTest {
public void testWithNorm_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NaN.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.withNorm(2.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -336,13 +335,13 @@ public class Vector2DTest {
public void testNormalize_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NaN.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.normalize(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -485,13 +484,13 @@ public class Vector2DTest {
public void testOrthogonal_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NaN.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.orthogonal(),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -511,35 +510,35 @@ public class Vector2DTest {
public void testOrthogonal_givenDirection_illegalNorm() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NaN.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
public void testOrthogonal_givenDirection_directionIsCollinear() {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.MINUS_X),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.of(1.0, 1.0).orthogonal(Vector2D.of(2.0, 2.0)),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.of(-1.01, -1.01).orthogonal(Vector2D.of(20.1, 20.1)),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -565,22 +564,22 @@ public class Vector2DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NaN.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.angle(v),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -654,13 +653,13 @@ public class Vector2DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> v.project(Vector2D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.project(Vector2D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.project(Vector2D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.project(Vector2D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -691,13 +690,13 @@ public class Vector2DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -786,15 +785,15 @@ public class Vector2DTest {
// act/assert
GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.directionTo(Vector2D.ZERO),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> p.directionTo(p),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> p.directionTo(Vector2D.NaN),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.directionTo(p),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> p.directionTo(Vector2D.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
@@ -1013,13 +1012,13 @@ public class Vector2DTest {
@Test
public void testUnitFrom_illegalNorm() {
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(0.0, 0.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(Double.NaN, 1.0),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(1.0, Double.NEGATIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(1.0, Double.POSITIVE_INFINITY),
- IllegalNormException.class);
+ IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java
index 144cb8a..109c710 100644
--- a/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java
+++ b/commons-geometry-hull/src/main/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChain.java
@@ -78,16 +78,16 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
// sort the points in increasing order on the x-axis
Collections.sort(pointsSortedByXAxis, (o1, o2) -> {
- final DoublePrecisionContext precision = getPrecision();
- // need to take the tolerance value into account, otherwise collinear points
- // will not be handled correctly when building the upper/lower hull
- final int diff = precision.compare(o1.getX(), o2.getX());
- if (diff == 0) {
- return precision.compare(o1.getY(), o2.getY());
- } else {
- return diff;
- }
- });
+ final DoublePrecisionContext precision = getPrecision();
+ // need to take the tolerance value into account, otherwise collinear points
+ // will not be handled correctly when building the upper/lower hull
+ final int diff = precision.compare(o1.getX(), o2.getX());
+ if (diff == 0) {
+ return precision.compare(o1.getY(), o2.getY());
+ } else {
+ return diff;
+ }
+ });
// build lower hull
final List<Vector2D> lowerHull = new ArrayList<>();
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java
index 79dfd82..26e077a 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java
@@ -22,15 +22,14 @@ import java.util.Collections;
import java.util.List;
import java.util.function.BiFunction;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.HyperplaneBoundedRegion;
import org.apache.commons.geometry.core.partitioning.HyperplaneLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
/** Class representing an angular interval of size greater than zero to {@code 2pi}. The interval is
* defined by two azimuth angles: a min and a max. The interval starts at the min azimuth angle and
@@ -287,7 +286,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param max max azimuth value
* @param precision precision precision context used to compare floating point values
* @return a new instance resulting the angular region between the given min and max azimuths
- * @throws GeometryException if either azimuth is infinite or NaN
+ * @throws IllegalArgumentException if either azimuth is infinite or NaN
*/
public static AngularInterval of(final double min, final double max, final DoublePrecisionContext precision) {
return of(Point1S.of(min), Point1S.of(max), precision);
@@ -302,7 +301,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param max max azimuth value
* @param precision precision precision context used to compare floating point values
* @return a new instance resulting the angular region between the given min and max points
- * @throws GeometryException if either azimuth is infinite or NaN
+ * @throws IllegalArgumentException if either azimuth is infinite or NaN
*/
public static AngularInterval of(final Point1S min, final Point1S max, final DoublePrecisionContext precision) {
return createInterval(min, max, precision, AngularInterval::new, Convex.FULL);
@@ -315,7 +314,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param a first oriented point
* @param b second oriented point
* @return an instance representing the angular interval between the given oriented points
- * @throws GeometryException if either argument is infinite or NaN
+ * @throws IllegalArgumentException if either argument is infinite or NaN
*/
public static AngularInterval of(final CutAngle a, final CutAngle b) {
return createInterval(a, b, AngularInterval::new, Convex.FULL);
@@ -334,7 +333,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param <T> Angular interval implementation type
* @param fullSpace instance returned if the interval should represent the full space
* @return a new instance resulting the angular region between the given min and max points
- * @throws GeometryException if either azimuth is infinite or NaN
+ * @throws IllegalArgumentException if either azimuth is infinite or NaN
*/
private static <T extends AngularInterval> T createInterval(final Point1S min, final Point1S max,
final DoublePrecisionContext precision, final BiFunction<CutAngle, CutAngle, T> factory,
@@ -366,7 +365,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param fullSpace instance returned if the interval should represent the full space
* @param <T> Angular interval implementation type
* @return a new interval instance created from the given cut angles
- * @throws GeometryException if either argument is infinite or NaN
+ * @throws IllegalArgumentException if either argument is infinite or NaN
*/
private static <T extends AngularInterval> T createInterval(final CutAngle a, final CutAngle b,
final BiFunction<CutAngle, CutAngle, T> factory, final T fullSpace) {
@@ -395,11 +394,11 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
/** Validate that the given points can be used to specify an angular interval.
* @param a first point
* @param b second point
- * @throws GeometryException if either point is infinite NaN
+ * @throws IllegalArgumentException if either point is infinite NaN
*/
private static void validateIntervalValues(final Point1S a, final Point1S b) {
if (!a.isFinite() || !b.isFinite()) {
- throw new GeometryException(MessageFormat.format("Invalid angular interval: [{0}, {1}]",
+ throw new IllegalArgumentException(MessageFormat.format("Invalid angular interval: [{0}, {1}]",
a.getAzimuth(), b.getAzimuth()));
}
}
@@ -458,13 +457,13 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* of interval is less than or equal to {@code pi}.
* @param minBoundary minimum boundary for the interval
* @param maxBoundary maximum boundary for the interval
- * @throws GeometryException if the interval is not convex
+ * @throws IllegalArgumentException if the interval is not convex
*/
private Convex(final CutAngle minBoundary, final CutAngle maxBoundary) {
super(minBoundary, maxBoundary);
if (!isConvex(minBoundary, maxBoundary)) {
- throw new GeometryException(MessageFormat.format("Interval is not convex: [{0}, {1}]",
+ throw new IllegalArgumentException(MessageFormat.format("Interval is not convex: [{0}, {1}]",
minBoundary.getAzimuth(), maxBoundary.getAzimuth()));
}
}
@@ -581,7 +580,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param max max azimuth value
* @param precision precision precision context used to compare floating point values
* @return a new instance resulting the angular region between the given min and max azimuths
- * @throws GeometryException if either azimuth is infinite or NaN, or the given angular
+ * @throws IllegalArgumentException if either azimuth is infinite or NaN, or the given angular
* interval is not convex (meaning it has a size of greater than {@code pi})
*/
public static Convex of(final double min, final double max, final DoublePrecisionContext precision) {
@@ -597,7 +596,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param max max azimuth value
* @param precision precision precision context used to compare floating point values
* @return a new instance resulting the angular region between the given min and max points
- * @throws GeometryException if either azimuth is infinite or NaN, or the given angular
+ * @throws IllegalArgumentException if either azimuth is infinite or NaN, or the given angular
* interval is not convex (meaning it has a size of greater than {@code pi})
*/
public static Convex of(final Point1S min, final Point1S max, final DoublePrecisionContext precision) {
@@ -611,7 +610,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @param a first oriented point
* @param b second oriented point
* @return an instance representing the angular interval between the given oriented points
- * @throws GeometryException if either azimuth is infinite or NaN, or the given angular
+ * @throws IllegalArgumentException if either azimuth is infinite or NaN, or the given angular
* interval is not convex (meaning it has a size of greater than {@code pi})
*/
public static Convex of(final CutAngle a, final CutAngle b) {
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java
index 4616355..af54513 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java
@@ -22,7 +22,6 @@ import java.util.Objects;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.internal.Equivalency;
import org.apache.commons.geometry.core.partitioning.AbstractHyperplane;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
@@ -490,13 +489,15 @@ public final class CutAngle extends AbstractHyperplane<Point1S>
/** Validate the given subhyperplane lies on the same hyperplane.
* @param sub subhyperplane to validate
+ * @throws IllegalArgumentException if the argument is not on the same hyperplane
+ * as the instance
*/
private void validateHyperplane(final SubHyperplane<Point1S> sub) {
final CutAngle baseHyper = base.getHyperplane();
final CutAngle inputHyper = (CutAngle) sub.getHyperplane();
if (!baseHyper.eq(inputHyper)) {
- throw new GeometryException("Argument is not on the same " +
+ throw new IllegalArgumentException("Argument is not on the same " +
"hyperplane. Expected " + baseHyper + " but was " +
inputHyper);
}
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java
index 0122cd3..44c720b 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/Point1S.java
@@ -19,14 +19,13 @@ package org.apache.commons.geometry.spherical.oned;
import java.util.Comparator;
import java.util.Objects;
-import org.apache.commons.numbers.angle.PlaneAngle;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.Point;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.euclidean.twod.PolarCoordinates;
import org.apache.commons.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.numbers.angle.PlaneAngle;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
/** This class represents a point on the 1-sphere, or in other words, an
* azimuth angle on a circle. The value of the azimuth angle is not normalized
@@ -164,7 +163,7 @@ public final class Point1S implements Point<Point1S> {
* @param base point to place this instance's azimuth value above
* @return a point equivalent to the current instance but with an azimuth
* value in the range {@code [base, base + 2pi)}
- * @throws GeometryValueException if the azimuth value is NaN or infinite and
+ * @throws IllegalArgumentException if the azimuth value is NaN or infinite and
* cannot be normalized
*/
public Point1S above(final Point1S base) {
@@ -176,7 +175,7 @@ public final class Point1S implements Point<Point1S> {
* @param base point to place this instance's azimuth value below
* @return a point equivalent to the current instance but with an azimuth
* value in the range {@code [base - 2pi, base)}
- * @throws GeometryValueException if the azimuth value is NaN or infinite and
+ * @throws IllegalArgumentException if the azimuth value is NaN or infinite and
* cannot be normalized
*/
public Point1S below(final Point1S base) {
@@ -188,7 +187,7 @@ public final class Point1S implements Point<Point1S> {
* @param center point to center this instance around
* @return a point equivalent to this instance but with an azimuth value
* in the range {@code [center - pi, center + pi)}.
- * @throws GeometryValueException if the azimuth value is NaN or infinite and
+ * @throws IllegalArgumentException if the azimuth value is NaN or infinite and
* cannot be normalized
*/
public Point1S normalize(final Point1S center) {
@@ -201,7 +200,7 @@ public final class Point1S implements Point<Point1S> {
* @param center angle to center this instance around
* @return a point equivalent to this instance but with an azimuth value
* in the range {@code [center - pi, center + pi)}.
- * @throws GeometryValueException if the azimuth value is NaN or infinite and
+ * @throws IllegalArgumentException if the azimuth value is NaN or infinite and
* cannot be normalized
*/
public Point1S normalize(final double center) {
@@ -209,7 +208,7 @@ public final class Point1S implements Point<Point1S> {
final double az = PlaneAngleRadians.normalize(azimuth, center);
return new Point1S(az, normalizedAzimuth);
}
- throw new GeometryValueException("Cannot normalize azimuth value: " + azimuth);
+ throw new IllegalArgumentException("Cannot normalize azimuth value: " + azimuth);
}
/** Get the point exactly opposite this point on the circle, {@code pi} distance away.
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 7581b90..d77b892 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
@@ -272,9 +272,8 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
* @return a new convex area instance representing the area on the minus side of all
* of the bounding great circles or an instance representing the full area if no
* circles are given
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the given set of bounding great
- * circles do not form a convex area, meaning that there is no region that is on the minus side of all
- * of the bounding circles.
+ * @throws IllegalArgumentException if the given set of bounding great circles do not form a convex area,
+ * meaning that there is no region that is on the minus side of all of the bounding circles.
*/
public static ConvexArea2S fromBounds(final GreatCircle... bounds) {
return fromBounds(Arrays.asList(bounds));
@@ -288,9 +287,8 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
* @return a new convex area instance representing the area on the minus side of all
* of the bounding great circles or an instance representing the full area if no
* circles are given
- * @throws org.apache.commons.geometry.core.exception.GeometryException if the given set of bounding great
- * circles do not form a convex area, meaning that there is no region that is on the minus side of all
- * of the bounding circles.
+ * @throws IllegalArgumentException if the given set of bounding great circles do not form a convex area,
+ * meaning that there is no region that is on the minus side of all of the bounding circles.
*/
public static ConvexArea2S fromBounds(final Iterable<GreatCircle> bounds) {
final List<GreatArc> arcs = new ConvexRegionBoundaryBuilder<>(GreatArc.class).build(bounds);
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArc.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArc.java
index d2d17a9..f3466bf 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArc.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatArc.java
@@ -197,8 +197,8 @@ public final class GreatArc extends AbstractSubGreatCircle implements ConvexSubH
* @param end end point point for the interval
* @param precision precision context used to compare floating point numbers
* @return an arc representing the shortest path between the given points
- * @throws org.apache.commons.geometry.core.exception.GeometryException if either of the given points is
- * NaN or infinite, or if the given points are equal or antipodal as evaluated by the given precision context
+ * @throws IllegalArgumentException if either of the given points is NaN or infinite, or if the given
+ * points are equal or antipodal as evaluated by the given precision context
* @see GreatCircle#fromPoints(Point2S, Point2S, org.apache.commons.geometry.core.precision.DoublePrecisionContext)
*/
public static GreatArc fromPoints(final Point2S start, final Point2S end, final DoublePrecisionContext precision) {
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 3b791f1..1deaf8c 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
@@ -18,9 +18,7 @@ package org.apache.commons.geometry.spherical.twod;
import java.util.Objects;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.internal.Equivalency;
import org.apache.commons.geometry.core.partitioning.AbstractHyperplane;
import org.apache.commons.geometry.core.partitioning.EmbeddingHyperplane;
@@ -29,6 +27,7 @@ import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.euclidean.threed.Vector3D;
import org.apache.commons.geometry.spherical.oned.AngularInterval;
import org.apache.commons.geometry.spherical.oned.Point1S;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
/** Class representing a great circle on the 2-sphere. A great circle is the
* intersection of a sphere with a plane that passes through its center. It is
@@ -215,7 +214,7 @@ public final class GreatCircle extends AbstractHyperplane<Point2S>
* @param start start point
* @param end end point
* @return an arc on this circle between the given points
- * @throws GeometryException if the specified interval is not
+ * @throws IllegalArgumentException if the specified interval is not
* convex (ie, the angle between the points is greater than {@code pi}
*/
public GreatArc arc(final Point2S start, final Point2S end) {
@@ -226,7 +225,7 @@ public final class GreatCircle extends AbstractHyperplane<Point2S>
* @param start start subspace point
* @param end end subspace point
* @return an arc on this circle between the given subspace points
- * @throws GeometryException if the specified interval is not
+ * @throws IllegalArgumentException if the specified interval is not
* convex (ie, the angle between the points is greater than {@code pi}
*/
public GreatArc arc(final Point1S start, final Point1S end) {
@@ -237,7 +236,7 @@ public final class GreatCircle extends AbstractHyperplane<Point2S>
* @param start start subspace azimuth
* @param end end subspace azimuth
* @return an arc on this circle between the given subspace azimuths
- * @throws GeometryException if the specified interval is not
+ * @throws IllegalArgumentException if the specified interval is not
* convex (ie, the angle between the points is greater than {@code pi}
*/
public GreatArc arc(final double start, final double end) {
@@ -409,14 +408,14 @@ public final class GreatCircle extends AbstractHyperplane<Point2S>
* @param b second point on the great circle
* @param precision precision context used to compare floating point values
* @return great circle instance containing the given points
- * @throws GeometryException if either of the given points is NaN or infinite, or if the given points are
+ * @throws IllegalArgumentException if either of the given points is NaN or infinite, or if the given points are
* equal or antipodal as evaluated by the given precision context
*/
public static GreatCircle fromPoints(final Point2S a, final Point2S b,
final DoublePrecisionContext precision) {
if (!a.isFinite() || !b.isFinite()) {
- throw new GeometryException("Invalid points for great circle: " + a + ", " + b);
+ throw new IllegalArgumentException("Invalid points for great circle: " + a + ", " + b);
}
String err = null;
@@ -429,7 +428,7 @@ public final class GreatCircle extends AbstractHyperplane<Point2S>
}
if (err != null) {
- throw new GeometryException("Cannot create great circle from points " + a + " and " + b +
+ throw new IllegalArgumentException("Cannot create great circle from points " + a + " and " + b +
": points are " + err);
}
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubGreatCircle.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubGreatCircle.java
index ca0163d..d2f918c 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubGreatCircle.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/SubGreatCircle.java
@@ -20,7 +20,6 @@ import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.Split;
@@ -129,7 +128,7 @@ public final class SubGreatCircle extends AbstractSubGreatCircle {
/** Add an arc to this instance.
* @param arc arc to add
- * @throws GeometryException if the given arc is not from
+ * @throws IllegalArgumentException if the given arc is not from
* a great circle equivalent to this instance
*/
public void add(final GreatArc arc) {
@@ -141,7 +140,7 @@ public final class SubGreatCircle extends AbstractSubGreatCircle {
/** Add the region represented by the given subcircle to this instance.
* The argument is not modified.
* @param subcircle subcircle to add
- * @throws GeometryException if the given subcircle is not from
+ * @throws IllegalArgumentException if the given subcircle is not from
* a great circle equivalent to this instance
*/
public void add(final SubGreatCircle subcircle) {
@@ -168,14 +167,14 @@ public final class SubGreatCircle extends AbstractSubGreatCircle {
/** Validate that the given great circle is equivalent to the circle
* defining this instance.
* @param inputCircle the great circle to validate
- * @throws GeometryException if the argument is not equivalent
+ * @throws IllegalArgumentException if the argument is not equivalent
* to the great circle for this instance
*/
private void validateGreatCircle(final GreatCircle inputCircle) {
final GreatCircle circle = getCircle();
if (!circle.eq(inputCircle)) {
- throw new GeometryException("Argument is not on the same " +
+ throw new IllegalArgumentException("Argument is not on the same " +
"great circle. Expected " + circle + " but was " +
inputCircle);
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
index 585bd79..ce923eb 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
@@ -18,15 +18,14 @@ package org.apache.commons.geometry.spherical.oned;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.Region;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -56,27 +55,27 @@ public class AngularIntervalTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Double.NEGATIVE_INFINITY, 0, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(0, Double.POSITIVE_INFINITY, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Double.NaN, 0, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(0, Double.NaN, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Double.NaN, Double.NaN, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -97,27 +96,27 @@ public class AngularIntervalTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Point1S.of(Double.NEGATIVE_INFINITY), Point1S.ZERO, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Point1S.ZERO, Point1S.of(Double.POSITIVE_INFINITY), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Point1S.of(Double.POSITIVE_INFINITY), Point1S.of(Double.NEGATIVE_INFINITY), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Point1S.NaN, Point1S.ZERO, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Point1S.ZERO, Point1S.NaN, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(Point1S.NaN, Point1S.NaN, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -155,15 +154,15 @@ public class AngularIntervalTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(pt, nan);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(nan, pt);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.of(nan, nan);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -544,19 +543,19 @@ public class AngularIntervalTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(0, PlaneAngleRadians.PI + 1e-1, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(PlaneAngleRadians.PI_OVER_TWO, -PlaneAngleRadians.PI_OVER_TWO + 1, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(0, -0.5, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -581,20 +580,20 @@ public class AngularIntervalTest {
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(Point1S.of(Double.NEGATIVE_INFINITY),
Point1S.of(Double.POSITIVE_INFINITY), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(Point1S.of(0), Point1S.of(PlaneAngleRadians.PI + 1e-1), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(Point1S.of(PlaneAngleRadians.PI_OVER_TWO),
Point1S.of(-PlaneAngleRadians.PI_OVER_TWO + 1), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(Point1S.of(0), Point1S.of(-0.5), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -632,21 +631,21 @@ public class AngularIntervalTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(pt, nan);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(nan, pt);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(nan, nan);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
AngularInterval.Convex.of(
CutAngle.createNegativeFacing(1, TEST_PRECISION),
CutAngle.createPositiveFacing(0.5, TEST_PRECISION));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
index 3b99fc2..ea6b6eb 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
@@ -18,10 +18,8 @@ package org.apache.commons.geometry.spherical.oned;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.HyperplaneLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SubHyperplane;
@@ -545,14 +543,14 @@ public class CutAngleTest {
// act/assert
GeometryTestUtils.assertThrows(
() -> builder.add(CutAngle.createPositiveFacing(2e-3, precision).span()),
- GeometryException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
() -> builder.add(CutAngle.createNegativeFacing(2e-3, precision).span()),
- GeometryException.class);
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
() -> builder.add((SubHyperplane<Point1S>) CutAngle.createPositiveFacing(2e-3, precision).span()),
- GeometryException.class);
+ IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
index 067fc3e..00597da 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
@@ -18,9 +18,7 @@ package org.apache.commons.geometry.spherical.oned;
import java.util.Comparator;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.GeometryValueException;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.twod.PolarCoordinates;
@@ -347,15 +345,15 @@ public class Point1STest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.POSITIVE_INFINITY).normalize(0.0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.NEGATIVE_INFINITY).normalize(0.0);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.NaN).normalize(Point1S.ZERO);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -386,15 +384,15 @@ public class Point1STest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.POSITIVE_INFINITY).above(Point1S.ZERO);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.NEGATIVE_INFINITY).above(Point1S.ZERO);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.NaN).above(Point1S.ZERO);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
@@ -425,15 +423,15 @@ public class Point1STest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.POSITIVE_INFINITY).below(Point1S.ZERO);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.NEGATIVE_INFINITY).below(Point1S.ZERO);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
Point1S.of(Double.NaN).below(Point1S.ZERO);
- }, GeometryValueException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
index 07d5d09..121768c 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
@@ -18,10 +18,8 @@ package org.apache.commons.geometry.spherical.twod;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
@@ -29,6 +27,7 @@ import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.threed.Vector3D;
import org.apache.commons.geometry.spherical.SphericalTestUtils;
import org.apache.commons.geometry.spherical.oned.AngularInterval;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -155,11 +154,11 @@ public class GreatArcTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
GreatArc.fromPoints(Point2S.PLUS_I, Point2S.of(1e-12, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
GreatArc.fromPoints(Point2S.PLUS_I, Point2S.MINUS_I, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
index 4db3bbb..4c64052 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
@@ -18,9 +18,7 @@ package org.apache.commons.geometry.spherical.twod;
import java.util.regex.Pattern;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.HyperplaneLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
@@ -28,6 +26,7 @@ import org.apache.commons.geometry.euclidean.threed.Vector3D;
import org.apache.commons.geometry.spherical.SphericalTestUtils;
import org.apache.commons.geometry.spherical.oned.AngularInterval;
import org.apache.commons.geometry.spherical.oned.Point1S;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -95,34 +94,34 @@ public class GreatCircleTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
GreatCircle.fromPoints(p1, p1, TEST_PRECISION);
- }, GeometryException.class, Pattern.compile("^.*points are equal$"));
+ }, IllegalArgumentException.class, Pattern.compile("^.*points are equal$"));
GeometryTestUtils.assertThrows(() -> {
GreatCircle.fromPoints(p1, Point2S.of(1e-12, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION);
- }, GeometryException.class, Pattern.compile("^.*points are equal$"));
+ }, IllegalArgumentException.class, Pattern.compile("^.*points are equal$"));
GeometryTestUtils.assertThrows(() -> {
GreatCircle.fromPoints(
Point2S.from(Vector3D.Unit.PLUS_X),
Point2S.from(Vector3D.Unit.MINUS_X),
TEST_PRECISION);
- }, GeometryException.class, Pattern.compile("^.*points are antipodal$"));
+ }, IllegalArgumentException.class, Pattern.compile("^.*points are antipodal$"));
GeometryTestUtils.assertThrows(() -> {
GreatCircle.fromPoints(p1, Point2S.NaN, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
GreatCircle.fromPoints(Point2S.NaN, p2, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
GreatCircle.fromPoints(p1, Point2S.of(Double.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
GreatCircle.fromPoints(Point2S.of(Double.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), p2, TEST_PRECISION);
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java
index 9aa57d7..221f410 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java
@@ -18,11 +18,9 @@ package org.apache.commons.geometry.spherical.twod;
import java.util.List;
-import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
-import org.apache.commons.geometry.core.exception.GeometryException;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.Split;
@@ -35,6 +33,7 @@ import org.apache.commons.geometry.spherical.SphericalTestUtils;
import org.apache.commons.geometry.spherical.oned.AngularInterval;
import org.apache.commons.geometry.spherical.oned.RegionBSPTree1S;
import org.apache.commons.geometry.spherical.twod.SubGreatCircle.SubGreatCircleBuilder;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.Assert;
import org.junit.Test;
@@ -333,7 +332,7 @@ public class SubGreatCircleTest {
checkArc(arcs.get(0), Point2S.PLUS_J, Point2S.MINUS_J);
}
- @Test(expected = GeometryException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testAdd_arc_differentCircle() {
// arrange
GreatCircle circle = GreatCircle.fromPoints(Point2S.MINUS_K, Point2S.MINUS_J, TEST_PRECISION);
@@ -374,7 +373,7 @@ public class SubGreatCircleTest {
checkArc(arcs.get(1), Point2S.PLUS_J, Point2S.MINUS_J);
}
- @Test(expected = GeometryException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testAdd_subGreatCircle_otherCircle() {
// arrange
GreatCircle circle = GreatCircle.fromPoints(Point2S.MINUS_K, Point2S.MINUS_J, TEST_PRECISION);
@@ -427,11 +426,11 @@ public class SubGreatCircleTest {
// act/assert
GeometryTestUtils.assertThrows(() -> {
builder.add(otherCircle.span());
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.add(new SubGreatCircle(otherCircle));
- }, GeometryException.class);
+ }, IllegalArgumentException.class);
GeometryTestUtils.assertThrows(() -> {
builder.add(new UnknownSubHyperplane());