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 2018/09/23 10:45:44 UTC
[commons-geometry] branch master updated: GEOMETRY-20: removing
getNorm1(), getNormInf(), distance1(),
and distanceInf() Vector methods to simplify and streamline API
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
The following commit(s) were added to refs/heads/master by this push:
new 7b79994 GEOMETRY-20: removing getNorm1(), getNormInf(), distance1(), and distanceInf() Vector methods to simplify and streamline API
new ede33ea Merge branch 'GEOMETRY-20__matt'
7b79994 is described below
commit 7b7999490bfec70fb9b2e601f87bd0497707989b
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Sat Sep 22 22:07:59 2018 -0400
GEOMETRY-20: removing getNorm1(), getNormInf(), distance1(), and distanceInf() Vector methods to simplify and streamline API
---
.../org/apache/commons/geometry/core/Vector.java | 34 ----------
.../threed/enclosing/SphereGenerator.java | 12 +++-
.../geometry/euclidean/internal/Vectors.java | 67 -------------------
.../commons/geometry/euclidean/oned/Vector1D.java | 24 -------
.../geometry/euclidean/threed/Vector3D.java | 32 ---------
.../commons/geometry/euclidean/twod/Vector2D.java | 24 -------
.../geometry/euclidean/internal/VectorsTest.java | 76 ----------------------
.../geometry/euclidean/oned/Vector1DTest.java | 46 -------------
.../geometry/euclidean/threed/Vector3DTest.java | 56 ----------------
.../geometry/euclidean/twod/Vector2DTest.java | 58 -----------------
10 files changed, 11 insertions(+), 418 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 b37c4ea..043cccc 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
@@ -36,13 +36,6 @@ public interface Vector<V extends Vector<V>> extends Spatial {
*/
V getZero();
- /** Get the L<sub>1</sub> norm for the vector. This is defined as the
- * sum of the absolute values of all vector components.
- * @see <a href="http://mathworld.wolfram.com/L1-Norm.html">L1 Norm</a>
- * @return L<sub>1</sub> norm for the vector
- */
- double getNorm1();
-
/** Get the L<sub>2</sub> norm (commonly known as the Euclidean norm) for the vector.
* 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.
@@ -58,13 +51,6 @@ public interface Vector<V extends Vector<V>> extends Spatial {
*/
double getNormSq();
- /** Get the L<sub>∞</sub> norm for the vector. This is defined as the
- * maximum of the absolute values of all vector components.
- * @see <a href="http://mathworld.wolfram.com/L-Infinity-Norm.html">L<sub>∞</sub> Norm</a>
- * @return L<sub>∞</sub> norm for the vector
- */
- double getNormInf();
-
/** Returns a vector with the same direction but with the given
* norm. This is equivalent to calling {@code vec.normalize().scalarMultiply(mag)}
* but without the intermediate vector.
@@ -117,32 +103,12 @@ public interface Vector<V extends Vector<V>> extends Spatial {
*/
V scalarMultiply(double a);
- /** Compute the distance between the instance and another vector according to the L<sub>1</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>q.subtract(p).getNorm1()</code> except that no intermediate
- * vector is built</p>
- * @see #getNorm1()
- * @param v second vector
- * @return the distance between the instance and p according to the L<sub>1</sub> norm
- */
- double distance1(V v);
-
/** Compute the distance between the instance and another vector.
* @param v second vector
* @return the distance between the instance and v
*/
double distance(V v);
- /** Compute the distance between the instance and another vector according to the L<sub>∞</sub> norm.
- * <p>Calling this method is equivalent to calling:
- * <code>q.subtract(p).getNormInf()</code> except that no intermediate
- * vector is built</p>
- * @see #getNormInf()
- * @param v second vector
- * @return the distance between the instance and p according to the L<sub>∞</sub> norm
- */
- double distanceInf(V v);
-
/** Compute the square of the distance between the instance and another vector.
* <p>Calling this method is equivalent to calling:
* <code>q.subtract(p).getNormSq()</code> except that no intermediate
diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
index b0ada02..0111191 100644
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.apache.commons.geometry.enclosing.EnclosingBall;
import org.apache.commons.geometry.enclosing.SupportBallGenerator;
+import org.apache.commons.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.geometry.euclidean.threed.Plane;
import org.apache.commons.geometry.euclidean.threed.Point3D;
import org.apache.commons.geometry.euclidean.twod.Point2D;
@@ -53,7 +54,7 @@ public class SphereGenerator implements SupportBallGenerator<Point3D> {
// delegate to 2D disk generator
final Plane p = new Plane(vA, vB, vC,
- 1.0e-10 * (vA.asVector().getNorm1() + vB.asVector().getNorm1() + vC.asVector().getNorm1()));
+ 1.0e-10 * (norm1(vA) + norm1(vB) + norm1(vC)));
final EnclosingBall<Point2D> disk =
new DiskGenerator().ballOnSupport(Arrays.asList(p.toSubSpace(vA),
p.toSubSpace(vB),
@@ -149,4 +150,13 @@ public class SphereGenerator implements SupportBallGenerator<Point3D> {
add(c2[3].multiply(c3[2]).multiply(c1[1].subtract(c1[0])));
}
+ /** Compute the L<sub>1</sub> vector norm for the given set of coordinates.
+ * This is defined as the sum of the absolute values of all components.
+ * @param coord set of coordinates
+ * @return L<sub>1</sub> vector norm for the given set of coordinates
+ * @see <a href="http://mathworld.wolfram.com/L1-Norm.html">L1 Norm</a>
+ */
+ private double norm1(final Cartesian3D coord) {
+ return Math.abs(coord.getX()) + Math.abs(coord.getY()) + Math.abs(coord.getZ());
+ }
}
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 cc054a5..ddf5883 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
@@ -36,7 +36,6 @@ public final class Vectors {
return Double.isFinite(value) && value != 0.0;
}
-
/** Throws an {@link IllegalNormException} 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.
@@ -64,39 +63,6 @@ public final class Vectors {
return checkedNorm(vec.getNorm());
}
- /** Get the L<sub>1</sub> norm for the vector with the given components.
- * This is defined as the sum of the absolute values of all vector components.
- * @param x vector component
- * @return L<sub>1</sub> norm for the vector with the given components
- * @see <a href="http://mathworld.wolfram.com/L1-Norm.html">L1 Norm</a>
- */
- public static double norm1(final double x) {
- return Math.abs(x);
- }
-
- /** Get the L<sub>1</sub> norm for the vector with the given components.
- * This is defined as the sum of the absolute values of all vector components.
- * @param x1 first vector component
- * @param x2 second vector component
- * @return L<sub>1</sub> norm for the vector with the given components
- * @see <a href="http://mathworld.wolfram.com/L1-Norm.html">L1 Norm</a>
- */
- public static double norm1(final double x1, final double x2) {
- return Math.abs(x1) + Math.abs(x2);
- }
-
- /** Get the L<sub>1</sub> norm for the vector with the given components.
- * This is defined as the sum of the absolute values of all vector components.
- * @param x1 first vector component
- * @param x2 second vector component
- * @param x3 third vector component
- * @return L<sub>1</sub> norm for the vector with the given components
- * @see <a href="http://mathworld.wolfram.com/L1-Norm.html">L1 Norm</a>
- */
- public static double norm1(final double x1, final double x2, final double x3) {
- return Math.abs(x1) + Math.abs(x2) + Math.abs(x3);
- }
-
/** 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.
@@ -168,37 +134,4 @@ public final class Vectors {
public static double normSq(final double x1, final double x2, final double x3) {
return (x1 * x1) + (x2 * x2) + (x3 * x3);
}
-
- /** Get the L<sub>∞</sub> norm for the vector with the given components. This is defined
- * as the maximum of the absolute values of all vector components.
- * @param x vector component
- * @return L<sub>∞</sub> norm for the vector with the given components
- * @see <a href="http://mathworld.wolfram.com/L-Infinity-Norm.html">L<sub>∞</sub> Norm</a>
- */
- public static double normInf(final double x) {
- return Math.abs(x);
- }
-
- /** Get the L<sub>∞</sub> norm for the vector with the given components. This is defined
- * as the maximum of the absolute values of all vector components.
- * @param x1 first vector component
- * @param x2 second vector component
- * @return L<sub>∞</sub> norm for the vector with the given components
- * @see <a href="http://mathworld.wolfram.com/L-Infinity-Norm.html">L<sub>∞</sub> Norm</a>
- */
- public static double normInf(final double x1, final double x2) {
- return Math.max(Math.abs(x1), Math.abs(x2));
- }
-
- /** Get the L<sub>∞</sub> norm for the vector with the given components. This is defined
- * as the maximum of the absolute values of all vector components.
- * @param x1 first vector component
- * @param x2 second vector component
- * @param x3 third vector component
- * @return L<sub>∞</sub> norm for the vector with the given components
- * @see <a href="http://mathworld.wolfram.com/L-Infinity-Norm.html">L<sub>∞</sub> Norm</a>
- */
- public static double normInf(final double x1, final double x2, final double x3) {
- return Math.max(Math.max(Math.abs(x1), Math.abs(x2)), Math.abs(x3));
- }
}
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 97cba0a..7b1507b 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
@@ -80,12 +80,6 @@ public class Vector1D extends Cartesian1D implements EuclideanVector<Point1D, Ve
/** {@inheritDoc} */
@Override
- public double getNorm1() {
- return Vectors.norm1(getX());
- }
-
- /** {@inheritDoc} */
- @Override
public double getNorm() {
return Vectors.norm(getX());
}
@@ -98,12 +92,6 @@ public class Vector1D extends Cartesian1D implements EuclideanVector<Point1D, Ve
/** {@inheritDoc} */
@Override
- public double getNormInf() {
- return Vectors.normInf(getX());
- }
-
- /** {@inheritDoc} */
- @Override
public Vector1D withNorm(double magnitude) {
getCheckedNorm(); // validate our norm value
@@ -154,24 +142,12 @@ public class Vector1D extends Cartesian1D implements EuclideanVector<Point1D, Ve
/** {@inheritDoc} */
@Override
- public double distance1(Vector1D v) {
- return Vectors.norm1(getX() - v.getX());
- }
-
- /** {@inheritDoc} */
- @Override
public double distance(Vector1D v) {
return Vectors.norm(getX() - v.getX());
}
/** {@inheritDoc} */
@Override
- public double distanceInf(Vector1D v) {
- return Vectors.normInf(getX() - v.getX());
- }
-
- /** {@inheritDoc} */
- @Override
public double distanceSq(Vector1D v) {
return Vectors.normSq(getX() - v.getX());
}
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 c075ff2..13f6da7 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
@@ -96,12 +96,6 @@ public class Vector3D extends Cartesian3D implements MultiDimensionalEuclideanVe
/** {@inheritDoc} */
@Override
- public double getNorm1() {
- return Vectors.norm1(getX(), getY(), getZ());
- }
-
- /** {@inheritDoc} */
- @Override
public double getNorm() {
return Vectors.norm(getX(), getY(), getZ());
}
@@ -114,12 +108,6 @@ public class Vector3D extends Cartesian3D implements MultiDimensionalEuclideanVe
/** {@inheritDoc} */
@Override
- public double getNormInf() {
- return Vectors.normInf(getX(), getY(), getZ());
- }
-
- /** {@inheritDoc} */
- @Override
public Vector3D withNorm(double magnitude) {
final double invNorm = 1.0 / getCheckedNorm();
@@ -190,16 +178,6 @@ public class Vector3D extends Cartesian3D implements MultiDimensionalEuclideanVe
/** {@inheritDoc} */
@Override
- public double distance1(Vector3D v) {
- return Vectors.norm1(
- getX() - v.getX(),
- getY() - v.getY(),
- getZ() - v.getZ()
- );
- }
-
- /** {@inheritDoc} */
- @Override
public double distance(Vector3D v) {
return Vectors.norm(
getX() - v.getX(),
@@ -210,16 +188,6 @@ public class Vector3D extends Cartesian3D implements MultiDimensionalEuclideanVe
/** {@inheritDoc} */
@Override
- public double distanceInf(Vector3D v) {
- return Vectors.normInf(
- getX() - v.getX(),
- getY() - v.getY(),
- getZ() - v.getZ()
- );
- }
-
- /** {@inheritDoc} */
- @Override
public double distanceSq(Vector3D v) {
return Vectors.normSq(
getX() - v.getX(),
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 3a936f9..9915a32 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
@@ -87,12 +87,6 @@ public class Vector2D extends Cartesian2D implements MultiDimensionalEuclideanVe
/** {@inheritDoc} */
@Override
- public double getNorm1() {
- return Vectors.norm1(getX(), getY());
- }
-
- /** {@inheritDoc} */
- @Override
public double getNorm() {
return Vectors.norm(getX(), getY());
}
@@ -105,12 +99,6 @@ public class Vector2D extends Cartesian2D implements MultiDimensionalEuclideanVe
/** {@inheritDoc} */
@Override
- public double getNormInf() {
- return Vectors.normInf(getX(), getY());
- }
-
- /** {@inheritDoc} */
- @Override
public Vector2D withNorm(double magnitude) {
final double invNorm = 1.0 / getCheckedNorm();
@@ -164,24 +152,12 @@ public class Vector2D extends Cartesian2D implements MultiDimensionalEuclideanVe
/** {@inheritDoc} */
@Override
- public double distance1(Vector2D v) {
- return Vectors.norm1(getX() - v.getX(), getY() - v.getY());
- }
-
- /** {@inheritDoc} */
- @Override
public double distance(Vector2D v) {
return Vectors.norm(getX() - v.getX(), getY() - v.getY());
}
/** {@inheritDoc} */
@Override
- public double distanceInf(Vector2D v) {
- return Vectors.normInf(getX() - v.getX(), getY() - v.getY());
- }
-
- /** {@inheritDoc} */
- @Override
public double distanceSq(Vector2D v) {
return Vectors.normSq(getX() - v.getX(), getY() - v.getY());
}
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 207df63..2264641 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
@@ -85,44 +85,6 @@ public class VectorsTest {
}
@Test
- public void testNorm1_oneD() {
- // act/assert
- Assert.assertEquals(0.0, Vectors.norm1(0.0), EPS);
-
- Assert.assertEquals(2.0, Vectors.norm1(-2.0), EPS);
- Assert.assertEquals(1.0, Vectors.norm1(-1.0), EPS);
-
- Assert.assertEquals(1.0, Vectors.norm1(1.0), EPS);
- Assert.assertEquals(2.0, Vectors.norm1(2.0), EPS);
- }
-
- @Test
- public void testNorm1_twoD() {
- // act/assert
- Assert.assertEquals(0.0, Vectors.norm1(0.0, 0.0), EPS);
-
- Assert.assertEquals(3.0, Vectors.norm1(1.0, 2.0), EPS);
- Assert.assertEquals(7.0, Vectors.norm1(3.0, -4.0), EPS);
- Assert.assertEquals(11.0, Vectors.norm1(-5.0, 6.0), EPS);
- Assert.assertEquals(16.0, Vectors.norm1(-7.0, -9.0), EPS);
- }
-
- @Test
- public void testNorm1_threeD() {
- // act/assert
- Assert.assertEquals(0.0, Vectors.norm1(0.0, 0.0, 0.0), EPS);
-
- Assert.assertEquals(6.0, Vectors.norm1(1.0, 2.0, 3.0), EPS);
- Assert.assertEquals(15.0, Vectors.norm1(4.0, 5.0, -6.0), EPS);
- Assert.assertEquals(24.0, Vectors.norm1(7.0, -8.0, 9.0), EPS);
- Assert.assertEquals(33.0, Vectors.norm1(10.0, -11.0, -12.0), EPS);
- Assert.assertEquals(42.0, Vectors.norm1(-13.0, 14.0, 15.0), EPS);
- Assert.assertEquals(51.0, Vectors.norm1(-16.0, 17.0, -18.0), EPS);
- Assert.assertEquals(60.0, Vectors.norm1(-19.0, -20.0, 21.0), EPS);
- Assert.assertEquals(69.0, Vectors.norm1(-22.0, -23.0, -24.0), EPS);
- }
-
- @Test
public void testNorm_oneD() {
// act/assert
Assert.assertEquals(0.0, Vectors.norm(0.0), EPS);
@@ -197,42 +159,4 @@ public class VectorsTest {
Assert.assertEquals(1202.0, Vectors.normSq(-19.0, -20.0, 21.0), EPS);
Assert.assertEquals(1589.0, Vectors.normSq(-22.0, -23.0, -24.0), EPS);
}
-
- @Test
- public void testNormInf_oneD() {
- // act/assert
- Assert.assertEquals(0.0, Vectors.normInf(0.0), EPS);
-
- Assert.assertEquals(2.0, Vectors.normInf(-2.0), EPS);
- Assert.assertEquals(1.0, Vectors.normInf(-1.0), EPS);
-
- Assert.assertEquals(1.0, Vectors.normInf(1.0), EPS);
- Assert.assertEquals(2.0, Vectors.normInf(2.0), EPS);
- }
-
- @Test
- public void testNormInf_twoD() {
- // act/assert
- Assert.assertEquals(0.0, Vectors.normInf(0.0, 0.0), EPS);
-
- Assert.assertEquals(2.0, Vectors.normInf(2.0, 1.0), EPS);
- Assert.assertEquals(4.0, Vectors.normInf(3.0, -4.0), EPS);
- Assert.assertEquals(6.0, Vectors.normInf(-6.0, 5.0), EPS);
- Assert.assertEquals(9.0, Vectors.normInf(-7.0, -9.0), EPS);
- }
-
- @Test
- public void testNormInf_threeD() {
- // act/assert
- Assert.assertEquals(0.0, Vectors.normInf(0.0, 0.0, 0.0), EPS);
-
- Assert.assertEquals(3.0, Vectors.normInf(1.0, 3.0, 2.0), EPS);
- Assert.assertEquals(6.0, Vectors.normInf(6.0, 5.0, -4.0), EPS);
- Assert.assertEquals(9.0, Vectors.normInf(7.0, -9.0, 8.0), EPS);
- Assert.assertEquals(12.0, Vectors.normInf(10.0, -11.0, -12.0), EPS);
- Assert.assertEquals(15.0, Vectors.normInf(-13.0, 14.0, 15.0), EPS);
- Assert.assertEquals(18.0, Vectors.normInf(-16.0, 17.0, -18.0), EPS);
- Assert.assertEquals(21.0, Vectors.normInf(-21.0, -19.0, 20.0), EPS);
- Assert.assertEquals(24.0, Vectors.normInf(-22.0, -23.0, -24.0), EPS);
- }
}
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 effc704..df90a7a 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
@@ -78,14 +78,6 @@ public class Vector1DTest {
}
@Test
- public void testNorm1() {
- // act/assert
- Assert.assertEquals(0.0, Vector1D.ZERO.getNorm1(), TEST_TOLERANCE);
- Assert.assertEquals(6.0, Vector1D.of(6).getNorm1(), TEST_TOLERANCE);
- Assert.assertEquals(6.0, Vector1D.of(-6).getNorm1(), TEST_TOLERANCE);
- }
-
- @Test
public void testNorm() {
// act/assert
Assert.assertEquals(0.0, Vector1D.ZERO.getNorm(), TEST_TOLERANCE);
@@ -102,14 +94,6 @@ public class Vector1DTest {
}
@Test
- public void testNormInf() {
- // act/assert
- Assert.assertEquals(0.0, Vector1D.ZERO.getNormInf(), TEST_TOLERANCE);
- Assert.assertEquals(3.0, Vector1D.of(3).getNormInf(), TEST_TOLERANCE);
- Assert.assertEquals(3.0, Vector1D.of(-3).getNormInf(), TEST_TOLERANCE);
- }
-
- @Test
public void testWithNorm() {
// act/assert
checkVector(Vector1D.ONE.withNorm(0.0), 0.0);
@@ -261,22 +245,6 @@ public class Vector1DTest {
}
@Test
- public void testDistance1() {
- // arrange
- Vector1D v1 = Vector1D.of(1);
- Vector1D v2 = Vector1D.of(-4);
-
- // act/assert
- Assert.assertEquals(0.0, v1.distance1(v1), TEST_TOLERANCE);
-
- Assert.assertEquals(5.0, v1.distance1(v2), TEST_TOLERANCE);
- Assert.assertEquals(5.0, v2.distance1(v1), TEST_TOLERANCE);
- Assert.assertEquals(v1.subtract(v2).getNorm1(), v1.distance1(v2), TEST_TOLERANCE);
-
- Assert.assertEquals(0.0, Vector1D.of(-1).distance1(Vector1D.of(-1)), TEST_TOLERANCE);
- }
-
- @Test
public void testDistance() {
// arrange
Vector1D v1 = Vector1D.of(1);
@@ -293,20 +261,6 @@ public class Vector1DTest {
}
@Test
- public void testDistanceInf() {
- // arrange
- Vector1D v1 = Vector1D.of(1);
- Vector1D v2 = Vector1D.of(-4);
-
- // act/assert
- Assert.assertEquals(0.0, Vector1D.of(-1).distanceInf(Vector1D.of(-1)), TEST_TOLERANCE);
- Assert.assertEquals(5.0, v1.distanceInf(v2), TEST_TOLERANCE);
- Assert.assertEquals(5.0, v2.distanceInf(v1), TEST_TOLERANCE);
-
- Assert.assertEquals(v1.subtract(v2).getNormInf(), v1.distanceInf(v2), TEST_TOLERANCE);
- }
-
- @Test
public void testDistanceSq() {
// arrange
Vector1D v1 = Vector1D.of(1);
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 0997f57..b555e2b 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
@@ -94,14 +94,6 @@ public class Vector3DTest {
}
@Test
- public void testNorm1() {
- // act/assert
- Assert.assertEquals(0.0, Vector3D.ZERO.getNorm1(), EPS);
- Assert.assertEquals(9.0, Vector3D.of(2, -3, 4).getNorm1(), EPS);
- Assert.assertEquals(9.0, Vector3D.of(-2, 3, -4).getNorm1(), EPS);
- }
-
- @Test
public void testNorm() {
// act/assert
Assert.assertEquals(0.0, Vector3D.ZERO.getNorm(), 0);
@@ -118,14 +110,6 @@ public class Vector3DTest {
}
@Test
- public void testNormInf() {
- // act/assert
- Assert.assertEquals(0.0, Vector3D.ZERO.getNormInf(), 0);
- Assert.assertEquals(4, Vector3D.of(2, 3, 4).getNormInf(), EPS);
- Assert.assertEquals(4, Vector3D.of(-2, -3, -4).getNormInf(), EPS);
- }
-
- @Test
public void testWithNorm() {
// arrange
double x = 2;
@@ -553,26 +537,6 @@ public class Vector3DTest {
}
@Test
- public void testDistance1() {
- // arrange
- Vector3D v1 = Vector3D.of(1, -2, 3);
- Vector3D v2 = Vector3D.of(-4, 2, 0);
- Vector3D v3 = Vector3D.of(5, -6, -7);
-
- // act/assert
- Assert.assertEquals(0.0, v1.distance1(v1), EPS);
- Assert.assertEquals(0.0, v2.distance1(v2), EPS);
-
- Assert.assertEquals(12.0, v1.distance1(v2), EPS);
- Assert.assertEquals(12.0, v2.distance1(v1), EPS);
-
- Assert.assertEquals(v1.subtract(v2).getNorm1(), v1.distance1(v2), EPS);
-
- Assert.assertEquals(18, v1.distance1(v3), EPS);
- Assert.assertEquals(18, v3.distance1(v1), EPS);
- }
-
- @Test
public void testDistance() {
// arrange
Vector3D v1 = Vector3D.of(1, -2, 3);
@@ -613,26 +577,6 @@ public class Vector3DTest {
}
@Test
- public void testDistanceInf() {
- // arrange
- Vector3D v1 = Vector3D.of(1, -2, 3);
- Vector3D v2 = Vector3D.of(-4, 2, 0);
- Vector3D v3 = Vector3D.of(5, -6, -7);
-
- // act/assert
- Assert.assertEquals(0.0, v1.distanceInf(v1), EPS);
- Assert.assertEquals(0.0, v2.distanceInf(v2), EPS);
-
- Assert.assertEquals(5, v1.distanceInf(v2), EPS);
- Assert.assertEquals(5, v2.distanceInf(v1), EPS);
-
- Assert.assertEquals(v1.subtract(v2).getNormInf(), v1.distanceInf(v2), EPS);
-
- Assert.assertEquals(10, v1.distanceInf(v3), EPS);
- Assert.assertEquals(10, v3.distanceInf(v1), EPS);
- }
-
- @Test
public void testDotProduct() {
// arrange
Vector3D v1 = Vector3D.of(1, -2, 3);
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 f1855c3..83a841d 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
@@ -78,17 +78,6 @@ public class Vector2DTest {
}
@Test
- public void testNorm1() {
- // act/assert
- Assert.assertEquals(0.0, Vector2D.of(0, 0).getNorm1(), EPS);
-
- Assert.assertEquals(3.0, Vector2D.of(1, 2).getNorm1(), EPS);
- Assert.assertEquals(3.0, Vector2D.of(1, -2).getNorm1(), EPS);
- Assert.assertEquals(3.0, Vector2D.of(-1, 2).getNorm1(), EPS);
- Assert.assertEquals(3.0, Vector2D.of(-1, -2).getNorm1(), EPS);
- }
-
- @Test
public void testNorm() {
// act/assert
Assert.assertEquals(0.0, Vector2D.of(0, 0).getNorm(), EPS);
@@ -115,19 +104,6 @@ public class Vector2DTest {
}
@Test
- public void testNormInf() {
- // act/assert
- Assert.assertEquals(0.0, Vector2D.of(0, 0).getNormInf(), EPS);
-
- Assert.assertEquals(2.0, Vector2D.of(1, 2).getNormInf(), EPS);
- Assert.assertEquals(2.0, Vector2D.of(1, -2).getNormInf(), EPS);
- Assert.assertEquals(2.0, Vector2D.of(-1, 2).getNormInf(), EPS);
- Assert.assertEquals(2.0, Vector2D.of(-1, -2).getNormInf(), EPS);
-
- Assert.assertEquals(100.0, Vector2D.of(100, -99).getNormInf(), EPS);
- }
-
- @Test
public void testWithNorm() {
// act/assert
checkVector(Vector2D.of(3, 4).withNorm(1.0), 0.6, 0.8);
@@ -292,23 +268,6 @@ public class Vector2DTest {
}
@Test
- public void testDistance1() {
- // arrange
- Vector2D v1 = Vector2D.of(1, 1);
- Vector2D v2 = Vector2D.of(4, 5);
- Vector2D v3 = Vector2D.of(-1, 0);
-
- // act/assert
- Assert.assertEquals(0, v1.distance1(v1), EPS);
-
- Assert.assertEquals(7, v1.distance1(v2), EPS);
- Assert.assertEquals(7, v2.distance1(v1), EPS);
-
- Assert.assertEquals(3, v1.distance1(v3), EPS);
- Assert.assertEquals(3, v3.distance1(v1), EPS);
- }
-
- @Test
public void testDistance() {
// arrange
Vector2D v1 = Vector2D.of(1, 1);
@@ -343,23 +302,6 @@ public class Vector2DTest {
}
@Test
- public void testDistanceInf() {
- // arrange
- Vector2D v1 = Vector2D.of(1, 1);
- Vector2D v2 = Vector2D.of(4, 5);
- Vector2D v3 = Vector2D.of(-1, 0);
-
- // act/assert
- Assert.assertEquals(0, v1.distanceInf(v1), EPS);
-
- Assert.assertEquals(4, v1.distanceInf(v2), EPS);
- Assert.assertEquals(4, v2.distanceInf(v1), EPS);
-
- Assert.assertEquals(2, v1.distanceInf(v3), EPS);
- Assert.assertEquals(2, v3.distanceInf(v1), EPS);
- }
-
- @Test
public void testDotProduct() {
// arrange
Vector2D v1 = Vector2D.of(1, 1);