Skip to content
Permalink
Browse files
GEOMETRY-13: using Norms from commons-numbers
  • Loading branch information
darkma773r committed Jun 9, 2021
1 parent f636fba commit af2b57c867d1ebd690ec0cdf93865314651d7f33
Showing 10 changed files with 12 additions and 12 deletions.
@@ -17,7 +17,7 @@
package org.apache.commons.geometry.euclidean.internal;

import org.apache.commons.geometry.core.Vector;
import org.apache.commons.numbers.arrays.SafeNorm;
import org.apache.commons.numbers.core.Norms;

/** This class consists exclusively of static vector utility methods.
*/
@@ -104,7 +104,7 @@ public static double norm(final double x1, final double x2) {
* @see <a href="http://mathworld.wolfram.com/L2-Norm.html">L2 Norm</a>
*/
public static double norm(final double x1, final double x2, final double x3) {
return SafeNorm.value(new double[] {x1, x2, x3});
return Norms.euclidean(x1, x2, x3);
}

/** Get the square of the L<sub>2</sub> norm (also known as the Euclidean norm)
@@ -22,7 +22,7 @@
import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
import org.apache.commons.geometry.euclidean.EuclideanVector;
import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.LinearCombination;
import org.apache.commons.numbers.core.Precision;

/** This class represents vectors and points in one-dimensional Euclidean space.
@@ -23,7 +23,7 @@
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.LinearCombination;

/** Class using a matrix to represent affine transformations in 3 dimensional Euclidean space.
*
@@ -25,7 +25,7 @@
import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
import org.apache.commons.geometry.euclidean.MultiDimensionalEuclideanVector;
import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.LinearCombination;
import org.apache.commons.numbers.core.Precision;

/** This class represents vectors and points in three-dimensional Euclidean space.
@@ -24,7 +24,7 @@
import org.apache.commons.geometry.euclidean.threed.AffineTransformMatrix3D;
import org.apache.commons.geometry.euclidean.threed.Vector3D;
import org.apache.commons.numbers.angle.Angle;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.LinearCombination;
import org.apache.commons.numbers.quaternion.Quaternion;
import org.apache.commons.numbers.quaternion.Slerp;

@@ -23,7 +23,7 @@
import org.apache.commons.geometry.euclidean.internal.Matrices;
import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.geometry.euclidean.twod.rotation.Rotation2D;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.LinearCombination;

/** Class using a matrix to represent affine transformations in 2 dimensional Euclidean space.
*
@@ -26,7 +26,7 @@
import org.apache.commons.geometry.euclidean.oned.AffineTransformMatrix1D;
import org.apache.commons.geometry.euclidean.oned.Vector1D;
import org.apache.commons.numbers.angle.Angle;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.LinearCombination;
import org.apache.commons.numbers.core.Precision;

/** This class represents an oriented line in the 2D plane.
@@ -25,7 +25,7 @@
import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
import org.apache.commons.geometry.euclidean.MultiDimensionalEuclideanVector;
import org.apache.commons.geometry.euclidean.internal.Vectors;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.LinearCombination;
import org.apache.commons.numbers.core.Precision;

/** This class represents vectors and points in two-dimensional Euclidean space.
@@ -78,9 +78,9 @@ void testCheckedNorm_vectorArg() {
GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Vector3D.NaN),
IllegalArgumentException.class, "Illegal norm: NaN");
GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Vector3D.POSITIVE_INFINITY),
IllegalArgumentException.class, "Illegal norm: NaN");
IllegalArgumentException.class, "Illegal norm: Infinity");
GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Vector3D.NEGATIVE_INFINITY),
IllegalArgumentException.class, "Illegal norm: NaN");
IllegalArgumentException.class, "Illegal norm: Infinity");
}

@Test
@@ -25,7 +25,7 @@
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.euclidean.twod.ConvexArea;
import org.apache.commons.geometry.euclidean.twod.Vector2D;
import org.apache.commons.numbers.arrays.LinearCombination;
import org.apache.commons.numbers.core.LinearCombination;
import org.apache.commons.numbers.core.Precision;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;

0 comments on commit af2b57c

Please sign in to comment.