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/14 00:20:36 UTC
[commons-geometry] 03/14: removing unnecessary
Vector?D.of(Cartesian?D) methods;
conversion between points and vectors can be accomplished with toPoint() and
toVector() methods
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 9d09f787a3d80bac6cc0972844ba446776ed5e51
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Sun Jul 22 14:33:05 2018 -0400
removing unnecessary Vector?D.of(Cartesian?D) methods; conversion between points and vectors can be accomplished with toPoint() and toVector() methods
---
.../org/apache/commons/geometry/euclidean/oned/Point1D.java | 2 +-
.../org/apache/commons/geometry/euclidean/oned/Vector1D.java | 8 --------
.../apache/commons/geometry/euclidean/threed/Vector3D.java | 8 --------
.../org/apache/commons/geometry/euclidean/twod/Vector2D.java | 8 --------
.../apache/commons/geometry/euclidean/oned/Vector1DTest.java | 12 ------------
.../commons/geometry/euclidean/threed/Vector3DTest.java | 11 -----------
.../apache/commons/geometry/euclidean/twod/Vector2DTest.java | 9 ---------
7 files changed, 1 insertion(+), 57 deletions(-)
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java
index 2100e72..1e6603e 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java
@@ -68,7 +68,7 @@ public final class Point1D extends Cartesian1D implements EuclideanPoint<Point1D
/** {@inheritDoc} */
@Override
public Vector1D asVector() {
- return Vector1D.of(this);
+ return Vector1D.of(getX());
}
/** {@inheritDoc} */
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 11786a5..8ed1194 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
@@ -267,14 +267,6 @@ public final class Vector1D extends Cartesian1D implements EuclideanVector<Point
return new Vector1D(x);
}
- /** Returns a vector instance with the given coordinate value.
- * @param value vector coordinate
- * @return vector instance
- */
- public static Vector1D of(Cartesian1D value) {
- return new Vector1D(value.getX());
- }
-
/** Parses the given string and returns a new vector instance. The expected string
* format is the same as that returned by {@link #toString()}.
* @param str the string to parse
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 f290fdd..50fee39 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
@@ -432,14 +432,6 @@ public final class Vector3D extends Cartesian3D implements EuclideanVector<Point
return new Vector3D(x, y, z);
}
- /** Returns a vector instance with the given coordinate values.
- * @param value vector coordinates
- * @return vector instance
- */
- public static Vector3D of(Cartesian3D value) {
- return new Vector3D(value.getX(), value.getY(), value.getZ());
- }
-
/** Creates a vector from the coordinates in the given 3-element array.
* @param v coordinates array
* @return new vector
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 3d6fa79..a81dcd7 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
@@ -368,14 +368,6 @@ public final class Vector2D extends Cartesian2D implements EuclideanVector<Point
return new Vector2D(x, y);
}
- /** Returns a vector instance with the given coordinate values.
- * @param value vector coordinates
- * @return vector instance
- */
- public static Vector2D of(Cartesian2D value) {
- return new Vector2D(value.getX(), value.getY());
- }
-
/** Creates a vector from the coordinates in the given 2-element array.
* @param v coordinates array
* @return new vector
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 c86be90..cce8abe 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
@@ -374,18 +374,6 @@ public class Vector1DTest {
}
@Test
- public void testOf_coordinateArg() {
- // act/assert
- checkVector(Vector1D.of(Vector1D.of(0)), 0.0);
- checkVector(Vector1D.of(Vector1D.of(-1)), -1.0);
- checkVector(Vector1D.of(Vector1D.of(1)), 1.0);
- checkVector(Vector1D.of(Vector1D.of(Math.PI)), Math.PI);
- checkVector(Vector1D.of(Vector1D.of(Double.NaN)), Double.NaN);
- checkVector(Vector1D.of(Vector1D.of(Double.NEGATIVE_INFINITY)), Double.NEGATIVE_INFINITY);
- checkVector(Vector1D.of(Vector1D.of(Double.POSITIVE_INFINITY)), Double.POSITIVE_INFINITY);
- }
-
- @Test
public void testLinearCombination() {
// act/assert
checkVector(Vector1D.linearCombination(2, Vector1D.of(3)), 6);
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 9991e0c..a0dfd4b 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
@@ -709,17 +709,6 @@ public class Vector3DTest {
}
@Test
- public void testOf_coordinateArg() {
- // act/assert
- checkVector(Vector3D.of(Point3D.of(1, 2, 3)), 1, 2, 3);
- checkVector(Vector3D.of(Point3D.of(-1, -2, -3)), -1, -2, -3);
- checkVector(Vector3D.of(Point3D.of(Math.PI, Double.NaN, Double.POSITIVE_INFINITY)),
- Math.PI, Double.NaN, Double.POSITIVE_INFINITY);
- checkVector(Vector3D.of(Point3D.of(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Math.E)),
- Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Math.E);
- }
-
- @Test
public void testOf_arrayArg() {
// act/assert
checkVector(Vector3D.of(new double[] { 1, 2, 3 }), 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 1050ee4..3bf0687 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
@@ -521,15 +521,6 @@ public class Vector2DTest {
}
@Test
- public void testOf_coordinateArg() {
- // act/assert
- checkVector(Vector2D.of(Point2D.of(0, 1)), 0, 1);
- checkVector(Vector2D.of(Point2D.of(-1, -2)), -1, -2);
- checkVector(Vector2D.of(Point2D.of(Math.PI, Double.NaN)), Math.PI, Double.NaN);
- checkVector(Vector2D.of(Point2D.of(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY)), Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
- }
-
- @Test
public void testOf_arrayArg() {
// act/assert
checkVector(Vector2D.of(new double[] { 0, 1 }), 0, 1);