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 88087a4453f0c5238b6f63108054c8ee273c9ae6
Author: Matt Juntunen <matt.juntu...@hotmail.com>
AuthorDate: Fri Sep 21 22:26:14 2018 -0400

    GEOMETRY-17: cleaning up Vector interfaces; created 
MultiDimensionalEuclideanVector and moved project, reject, and orthgonal 
methods to it; Vector1D nor longer has project and reject
---
 .../apache/commons/geometry/core/AffinePoint.java  |   4 +-
 .../org/apache/commons/geometry/core/Vector.java   |  28 ----
 .../commons/geometry/euclidean/EuclideanPoint.java |   2 +-
 .../geometry/euclidean/EuclideanVector.java        |  16 +-
 .../euclidean/MultiDimensionalEuclideanVector.java |  77 ++++++++++
 .../commons/geometry/euclidean/oned/Vector1D.java  |  20 ---
 .../geometry/euclidean/threed/Vector3D.java        | 164 ++++++++++-----------
 .../commons/geometry/euclidean/twod/Vector2D.java  |  73 +++++----
 .../geometry/euclidean/oned/Vector1DTest.java      |  68 ---------
 9 files changed, 201 insertions(+), 251 deletions(-)

diff --git 
a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/AffinePoint.java
 
b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/AffinePoint.java
index 80d7b22..a684da4 100644
--- 
a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/AffinePoint.java
+++ 
b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/AffinePoint.java
@@ -30,13 +30,13 @@ package org.apache.commons.geometry.core;
  */
 public interface AffinePoint<P extends AffinePoint<P, V>, V extends Vector<V>> 
extends Point<P> {
 
-    /** Returns the displacement vector from this point to p.
+    /** Get the displacement vector from this point to p.
      * @param p second point
      * @return The displacement vector from this point to p.
      */
     V subtract(P p);
 
-    /** Returns the point resulting from adding the given displacement
+    /** Get the point resulting from adding the given displacement
      * vector to this point.
      * @param v displacement vector
      * @return point resulting from displacing this point by v
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 f835730..b37c4ea 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
@@ -159,34 +159,6 @@ public interface Vector<V extends Vector<V>> extends 
Spatial {
      */
     double dotProduct(V v);
 
-    /** Get the projection of the instance onto the given base vector. The 
returned
-     * vector is parallel to {@code base}. Vector projection and rejection onto
-     * a given base are related by the equation
-     * <code>
-     *      <strong>v</strong> = <strong>v<sub>projection</sub></strong> + 
<strong>v<sub>rejection</sub></strong>
-     * </code>
-     * @param base base vector
-     * @return the vector projection of the instance onto {@code base}
-     * @exception IllegalNormException if the norm of the base vector is zero, 
NaN, or infinite
-     * @see #reject(Vector)
-     */
-    V project(V base);
-
-    /** Get the rejection of the instance from the given base vector. The 
returned
-     * vector is orthogonal to {@code base}. This operation can be interpreted 
as
-     * returning the orthogonal projection of the instance onto the hyperplane
-     * orthogonal to {@code base}. Vector projection and rejection onto
-     * a given base are related by the equation
-     * <code>
-     *      <strong>v</strong> = <strong>v<sub>projection</sub></strong> + 
<strong>v<sub>rejection</sub></strong>
-     * </code>
-     * @param base base vector
-     * @return the vector rejection of the instance from {@code base}
-     * @exception IllegalNormException if the norm of the base vector is zero, 
NaN, or infinite
-     * @see #project(Vector)
-     */
-    V reject(V base);
-
     /** Compute the angular separation between two vectors in radians.
      * @param v other vector
      * @return angular separation between this instance and v in radians
diff --git 
a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanPoint.java
 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanPoint.java
index 5aecf85..f3c332c 100644
--- 
a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanPoint.java
+++ 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/EuclideanPoint.java
@@ -26,7 +26,7 @@ import 
org.apache.commons.geometry.core.exception.IllegalNormException;
  */
 public interface EuclideanPoint<P extends EuclideanPoint<P, V>, V extends 
EuclideanVector<P, V>> extends AffinePoint<P, V> {
 
-    /** Returns a vector with the same coordinates as this point.
+    /** Get a vector with the same coordinates as this point.
      * This is equivalent to the expression {@code v = P - Z} where
      * {@code P} is this point, {@code Z} is the zero point. and
      * {@code v} is the returned vector.
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 ad4f21b..595d5e3 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
@@ -18,14 +18,14 @@ package org.apache.commons.geometry.euclidean;
 
 import org.apache.commons.geometry.core.Vector;
 
-/** Represents a vector in a Euclidean space of any dimension.
+/** Vector extension interface for working in Euclidean space.
  *
  * @param <P> Point implementation type
  * @param <V> Vector implementation type
  */
 public interface EuclideanVector<P extends EuclideanPoint<P, V>, V extends 
EuclideanVector<P, V>> extends Vector<V> {
 
-    /** Returns a point with the same coordinates as this vector.
+    /** Get a point with the same coordinates as this vector.
      * This is equivalent to the expression {@code P = Z + v}, where
      * {@code v} is this vector, {@code Z} is the zero point, and
      * {@code P} is the returned point.
@@ -33,12 +33,12 @@ public interface EuclideanVector<P extends 
EuclideanPoint<P, V>, V extends Eucli
      */
     P asPoint();
 
-    /** Linearly interpolates between this vector and the given vector using 
the equation
-     * {@code V = (1 - t)*A + t*B}, where {@code A} is the current vector and 
{@code B}
-     * is the given vector. This means that if {@code t = 0}, a vector equal 
to the current
-     * vector will be returned. If {@code t = 1}, a vector equal to the 
argument will be returned.
-     * The {@code t} parameter is not constrained to the range {@code [0, 1]}, 
meaning that
-     * linear extrapolation can also be performed with this method.
+    /** Get a vector constructed by linearly interpolating between this vector 
and the given vector.
+     * The vector coordinates are generated by the equation {@code V = (1 - 
t)*A + t*B}, where {@code A}
+     * is the current vector and {@code B} is the given vector. This means 
that if {@code t = 0}, a
+     * vector equal to the current vector will be returned. If {@code t = 1}, 
a vector equal to the
+     * argument will be returned. The {@code t} parameter is not constrained 
to the range {@code [0, 1]},
+     * meaning that linear extrapolation can also be performed with this 
method.
      * @param v other vector
      * @param t interpolation parameter
      * @return interpolated or extrapolated vector
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
new file mode 100644
index 0000000..5c916e4
--- /dev/null
+++ 
b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/MultiDimensionalEuclideanVector.java
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+import org.apache.commons.geometry.core.Vector;
+import org.apache.commons.geometry.core.exception.IllegalNormException;
+
+/**
+ * Euclidean vector extension interface with methods applicable to spaces of
+ * two or more dimensions.
+ *
+ * @param <P> Point implementation type
+ * @param <V> Vector implementation type
+ */
+public interface MultiDimensionalEuclideanVector<P extends EuclideanPoint<P, 
V>, V extends MultiDimensionalEuclideanVector<P, V>>
+        extends EuclideanVector<P, V> {
+
+    /** Get the projection of the instance onto the given base vector. The 
returned
+     * vector is parallel to {@code base}. Vector projection and rejection onto
+     * a given base are related by the equation
+     * <code>
+     *      <strong>v</strong> = <strong>v<sub>projection</sub></strong> + 
<strong>v<sub>rejection</sub></strong>
+     * </code>
+     * @param base base vector
+     * @return the vector projection of the instance onto {@code base}
+     * @exception IllegalNormException if the norm of the base vector is zero, 
NaN, or infinite
+     * @see #reject(Vector)
+     */
+    V project(V base);
+
+    /** Get the rejection of the instance from the given base vector. The 
returned
+     * vector is orthogonal to {@code base}. This operation can be interpreted 
as
+     * returning the orthogonal projection of the instance onto the hyperplane
+     * orthogonal to {@code base}. Vector projection and rejection onto
+     * a given base are related by the equation
+     * <code>
+     *      <strong>v</strong> = <strong>v<sub>projection</sub></strong> + 
<strong>v<sub>rejection</sub></strong>
+     * </code>
+     * @param base base vector
+     * @return the vector rejection of the instance from {@code base}
+     * @exception IllegalNormException if the norm of the base vector is zero, 
NaN, or infinite
+     * @see #project(Vector)
+     */
+    V reject(V base);
+
+    /** Get a unit vector orthogonal to the instance.
+     * @return a unit vector orthogonal to the current instance
+     * @throws IllegalNormException if the norm of the current instance is 
zero, NaN,
+     *  or infinite
+     */
+    public V orthogonal();
+
+    /** Get a unit vector orthogonal to the current vector and pointing in the 
direction
+     * of {@code dir}. This method is equivalent to calling {@code 
dir.reject(vec).normalize()}
+     * except that no intermediate vector object is produced.
+     * @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 IllegalNormException if either vector norm is zero, NaN or 
infinite,
+     *      or the given vector is collinear with this vector.
+     */
+    public V orthogonal(V dir);
+}
\ No newline at end of file
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 ee2f260..97cba0a 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
@@ -183,26 +183,6 @@ public class Vector1D extends Cartesian1D implements 
EuclideanVector<Point1D, Ve
     }
 
     /** {@inheritDoc}
-     * <p>For the one-dimensional case, this method simply returns the current 
instance.</p>
-     */
-    @Override
-    public Vector1D project(final Vector1D base) {
-        base.getCheckedNorm(); // validate the base norm
-
-        return this;
-    }
-
-    /** {@inheritDoc}
-     * <p>For the one-dimensional case, this method simply returns the zero 
vector.</p>
-     */
-    @Override
-    public Vector1D reject(final Vector1D base) {
-        base.getCheckedNorm(); // validate the base norm
-
-        return Vector1D.ZERO;
-    }
-
-    /** {@inheritDoc}
      * <p>For the one-dimensional case, this method returns 0 if the vector x 
values have
      * the same sign and {@code pi} if they are opposite.</p>
      */
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 2a1bfdd..0436efe 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
@@ -20,14 +20,14 @@ package org.apache.commons.geometry.euclidean.threed;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
 import org.apache.commons.geometry.core.internal.DoubleFunction3N;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
-import org.apache.commons.geometry.euclidean.EuclideanVector;
+import org.apache.commons.geometry.euclidean.MultiDimensionalEuclideanVector;
 import org.apache.commons.geometry.euclidean.internal.Vectors;
 import org.apache.commons.numbers.arrays.LinearCombination;
 
 /** This class represents a vector in three-dimensional Euclidean space.
  * Instances of this class are guaranteed to be immutable.
  */
-public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, 
Vector3D> {
+public class Vector3D extends Cartesian3D implements 
MultiDimensionalEuclideanVector<Point3D, Vector3D> {
 
     /** Zero (null) vector (coordinates: 0, 0, 0). */
     public static final Vector3D ZERO   = new Vector3D(0, 0, 0);
@@ -182,89 +182,6 @@ public class Vector3D extends Cartesian3D implements 
EuclideanVector<Point3D, Ve
         return normalize(getX(), getY(), getZ());
     }
 
-    /** Get a vector orthogonal to the instance.
-     * <p>There are an infinite number of normalized vectors orthogonal
-     * to the instance. This method picks up one of them almost
-     * arbitrarily. It is useful when one needs to compute a reference
-     * frame with one of the axes in a predefined direction. The
-     * following example shows how to build a frame having the k axis
-     * aligned with the known vector u :
-     * <pre><code>
-     *   Vector3D k = u.normalize();
-     *   Vector3D i = k.orthogonal();
-     *   Vector3D j = k.crossProduct(i);
-     * </code></pre>
-     * @return a new normalized vector orthogonal to the instance
-     * @exception IllegalNormException if the norm of the instance is zero, 
NaN,
-     *  or infinite
-     */
-    public Vector3D orthogonal() {
-        double threshold = 0.6 * getCheckedNorm();
-
-        final double x = getX();
-        final double y = getY();
-        final double z = getZ();
-
-        if (Math.abs(x) <= threshold) {
-            double inverse  = 1 / Math.sqrt(y * y + z * z);
-            return new Vector3D(0, inverse * z, -inverse * y);
-        } else if (Math.abs(y) <= threshold) {
-            double inverse  = 1 / Math.sqrt(x * x + z * z);
-            return new Vector3D(-inverse * z, 0, inverse * x);
-        }
-        double inverse  = 1 / Math.sqrt(x * x + y * y);
-        return new Vector3D(inverse * y, -inverse * x, 0);
-    }
-
-    /** Returns a unit vector orthogonal to the current vector and pointing in 
the direction
-     * of {@code dir}. This method is equivalent to calling {@code 
dir.reject(vec).normalize()}
-     * except that no intermediate vector object is produced.
-     * @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 IllegalNormException if either vector norm is zero, NaN or 
infinite,
-     *      or the given vector is collinear with this vector.
-     */
-    public Vector3D orthogonal(Vector3D dir) {
-        return dir.getComponent(this, true, Vector3D::normalize);
-    }
-
-    /** {@inheritDoc}
-     * <p>This method computes the angular separation between two
-     * vectors using the dot product for well separated vectors and the
-     * cross product for almost aligned vectors. This allows to have a
-     * good accuracy in all cases, even for vectors very close to each
-     * other.</p>
-     */
-    @Override
-    public double angle(Vector3D v) {
-        double normProduct = getCheckedNorm() * v.getCheckedNorm();
-
-        double dot = dotProduct(v);
-        double threshold = normProduct * 0.9999;
-        if ((dot < -threshold) || (dot > threshold)) {
-            // the vectors are almost aligned, compute using the sine
-            Vector3D cross = crossProduct(v);
-            if (dot >= 0) {
-                return Math.asin(cross.getNorm() / normProduct);
-            }
-            return Math.PI - Math.asin(cross.getNorm() / normProduct);
-        }
-
-        // the vectors are sufficiently separated to use the cosine
-        return Math.acos(dot / normProduct);
-    }
-
-    /** Compute the cross-product of the instance with another vector.
-     * @param v other vector
-     * @return the cross product this ^ v as a new Cartesian3D
-     */
-    public Vector3D crossProduct(final Vector3D v) {
-        return new Vector3D(LinearCombination.value(getY(), v.getZ(), -getZ(), 
v.getY()),
-                            LinearCombination.value(getZ(), v.getX(), -getX(), 
v.getZ()),
-                            LinearCombination.value(getX(), v.getY(), -getY(), 
v.getX()));
-    }
-
     /** {@inheritDoc} */
     @Override
     public Vector3D scalarMultiply(double a) {
@@ -324,6 +241,32 @@ public class Vector3D extends Cartesian3D implements 
EuclideanVector<Point3D, Ve
         return LinearCombination.value(getX(), v.getX(), getY(), v.getY(), 
getZ(), v.getZ());
     }
 
+    /** {@inheritDoc}
+     * <p>This method computes the angular separation between two
+     * vectors using the dot product for well separated vectors and the
+     * cross product for almost aligned vectors. This allows to have a
+     * good accuracy in all cases, even for vectors very close to each
+     * other.</p>
+     */
+    @Override
+    public double angle(Vector3D v) {
+        double normProduct = getCheckedNorm() * v.getCheckedNorm();
+
+        double dot = dotProduct(v);
+        double threshold = normProduct * 0.9999;
+        if ((dot < -threshold) || (dot > threshold)) {
+            // the vectors are almost aligned, compute using the sine
+            Vector3D cross = crossProduct(v);
+            if (dot >= 0) {
+                return Math.asin(cross.getNorm() / normProduct);
+            }
+            return Math.PI - Math.asin(cross.getNorm() / normProduct);
+        }
+
+        // the vectors are sufficiently separated to use the cosine
+        return Math.acos(dot / normProduct);
+    }
+
     /** {@inheritDoc} */
     @Override
     public Vector3D project(Vector3D base) {
@@ -336,6 +279,57 @@ public class Vector3D extends Cartesian3D implements 
EuclideanVector<Point3D, Ve
         return getComponent(base, true, Vector3D::new);
     }
 
+    /** {@inheritDoc}
+     * <p>There are an infinite number of normalized vectors orthogonal
+     * to the instance. This method picks up one of them almost
+     * arbitrarily. It is useful when one needs to compute a reference
+     * frame with one of the axes in a predefined direction. The
+     * following example shows how to build a frame having the k axis
+     * aligned with the known vector u :
+     * <pre><code>
+     *   Vector3D k = u.normalize();
+     *   Vector3D i = k.orthogonal();
+     *   Vector3D j = k.crossProduct(i);
+     * </code></pre></p>
+     * @return a unit vector orthogonal to the instance
+     * @throws IllegalNormException if the norm of the instance is zero, NaN,
+     *  or infinite
+     */
+    @Override
+    public Vector3D orthogonal() {
+        double threshold = 0.6 * getCheckedNorm();
+
+        final double x = getX();
+        final double y = getY();
+        final double z = getZ();
+
+        if (Math.abs(x) <= threshold) {
+            double inverse  = 1 / Math.sqrt(y * y + z * z);
+            return new Vector3D(0, inverse * z, -inverse * y);
+        } else if (Math.abs(y) <= threshold) {
+            double inverse  = 1 / Math.sqrt(x * x + z * z);
+            return new Vector3D(-inverse * z, 0, inverse * x);
+        }
+        double inverse  = 1 / Math.sqrt(x * x + y * y);
+        return new Vector3D(inverse * y, -inverse * x, 0);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Vector3D orthogonal(Vector3D dir) {
+        return dir.getComponent(this, true, Vector3D::normalize);
+    }
+
+    /** Compute the cross-product of the instance with another vector.
+     * @param v other vector
+     * @return the cross product this ^ v as a new Cartesian3D
+     */
+    public Vector3D crossProduct(final Vector3D v) {
+        return new Vector3D(LinearCombination.value(getY(), v.getZ(), -getZ(), 
v.getY()),
+                            LinearCombination.value(getZ(), v.getX(), -getX(), 
v.getZ()),
+                            LinearCombination.value(getX(), v.getY(), -getY(), 
v.getX()));
+    }
+
     /**
      * Get a hashCode for the vector.
      * <p>All NaN values have the same hash code.</p>
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 8c3c39b..3a936f9 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
@@ -19,14 +19,14 @@ package org.apache.commons.geometry.euclidean.twod;
 import org.apache.commons.geometry.core.exception.IllegalNormException;
 import org.apache.commons.geometry.core.internal.DoubleFunction2N;
 import org.apache.commons.geometry.core.internal.SimpleTupleFormat;
-import org.apache.commons.geometry.euclidean.EuclideanVector;
+import org.apache.commons.geometry.euclidean.MultiDimensionalEuclideanVector;
 import org.apache.commons.geometry.euclidean.internal.Vectors;
 import org.apache.commons.numbers.arrays.LinearCombination;
 
 /** This class represents a vector in two-dimensional Euclidean space.
  * Instances of this class are guaranteed to be immutable.
  */
-public class Vector2D extends Cartesian2D implements EuclideanVector<Point2D, 
Vector2D> {
+public class Vector2D extends Cartesian2D implements 
MultiDimensionalEuclideanVector<Point2D, Vector2D> {
 
     /** Zero vector (coordinates: 0, 0). */
     public static final Vector2D ZERO   = new Vector2D(0, 0);
@@ -192,43 +192,6 @@ public class Vector2D extends Cartesian2D implements 
EuclideanVector<Point2D, Ve
         return LinearCombination.value(getX(), v.getX(), getY(), v.getY());
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public Vector2D project(Vector2D base) {
-        return getComponent(base, false, Vector2D::new);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public Vector2D reject(Vector2D base) {
-        return getComponent(base, true, Vector2D::new);
-    }
-
-    /** Returns a unit vector orthogonal to the current vector by rotating the
-     * vector {@code pi/2} radians counterclockwise around the origin. For 
example,
-     * if this method is called on the vector representing the positive 
x-axis, then
-     * a vector representing the positive y-axis is returned.
-     * @return a unit vector orthogonal to the current instance
-     * @throws IllegalNormException if the norm of the current instance is 
zero, NaN,
-     *  or infinite
-     */
-    public Vector2D orthogonal() {
-        return normalize(-getY(), getX());
-    }
-
-    /** Returns a unit vector orthogonal to the current vector and pointing in 
the direction
-     * of {@code dir}. This method is equivalent to calling {@code 
dir.reject(vec).normalize()}
-     * except that no intermediate vector object is produced.
-     * @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 IllegalNormException if either vector norm is zero, NaN or 
infinite,
-     *      or the given vector is collinear with this vector.
-     */
-    public Vector2D orthogonal(Vector2D dir) {
-        return dir.getComponent(this, true, Vector2D::normalize);
-    }
-
     /** {@inheritDoc}
      * <p>This method computes the angular separation between the two
      * vectors using the dot product for well separated vectors and the
@@ -255,6 +218,38 @@ public class Vector2D extends Cartesian2D implements 
EuclideanVector<Point2D, Ve
         return Math.acos(dot / normProduct);
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public Vector2D project(Vector2D base) {
+        return getComponent(base, false, Vector2D::new);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Vector2D reject(Vector2D base) {
+        return getComponent(base, true, Vector2D::new);
+    }
+
+    /** {@inheritDoc}
+     * The returned vector is computed by rotating the current instance {@code 
pi/2} radians
+     * counterclockwise around the origin and normalizing. For example, if 
this method is
+     * 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 IllegalNormException if the norm of the current instance is 
zero, NaN,
+     *  or infinite
+     */
+    @Override
+    public Vector2D orthogonal() {
+        return normalize(-getY(), getX());
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Vector2D orthogonal(Vector2D dir) {
+        return dir.getComponent(this, true, Vector2D::normalize);
+    }
+
     /**
      * Compute the cross-product of the instance and the given vector.
      * <p>
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 8e1b797..effc704 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
@@ -334,74 +334,6 @@ public class Vector1DTest {
     }
 
     @Test
-    public void testProject() {
-        // arrange
-        Vector1D v1 = Vector1D.of(2);
-        Vector1D v2 = Vector1D.of(-3);
-        Vector1D v3 = Vector1D.of(4);
-
-        // act/assert
-        checkVector(Vector1D.ZERO.project(v1), 0);
-        checkVector(Vector1D.ZERO.project(v2), 0);
-        checkVector(Vector1D.ZERO.project(v3), 0);
-
-        checkVector(v1.project(v1), 2);
-        checkVector(v1.project(v2), 2);
-        checkVector(v1.project(v3), 2);
-
-        checkVector(v2.project(v1), -3);
-        checkVector(v2.project(v2), -3);
-        checkVector(v2.project(v3), -3);
-
-        checkVector(v3.project(v1), 4);
-        checkVector(v3.project(v2), 4);
-        checkVector(v3.project(v3), 4);
-    }
-
-    @Test
-    public void testProject_baseHasIllegalNorm() {
-        // act/assert
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).project(Vector1D.ZERO),
-                IllegalNormException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).project(Vector1D.NaN),
-                IllegalNormException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).project(Vector1D.POSITIVE_INFINITY),
-                IllegalNormException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).project(Vector1D.NEGATIVE_INFINITY),
-                IllegalNormException.class);
-    }
-
-    @Test
-    public void testReject() {
-        // arrange
-        Vector1D v1 = Vector1D.of(2);
-        Vector1D v2 = Vector1D.of(-3);
-
-        // act/assert
-        checkVector(Vector1D.ZERO.reject(v1), 0);
-        checkVector(Vector1D.ZERO.reject(v2), 0);
-
-        checkVector(v1.reject(v1), 0);
-        checkVector(v1.reject(v2), 0);
-
-        checkVector(v2.reject(v1), 0);
-        checkVector(v2.reject(v2), 0);
-    }
-
-    @Test
-    public void testReject_baseHasIllegalNorm() {
-        // act/assert
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).reject(Vector1D.ZERO),
-                IllegalNormException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).reject(Vector1D.NaN),
-                IllegalNormException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).reject(Vector1D.POSITIVE_INFINITY),
-                IllegalNormException.class);
-        GeometryTestUtils.assertThrows(() -> 
Vector1D.of(2.0).reject(Vector1D.NEGATIVE_INFINITY),
-                IllegalNormException.class);
-    }
-
-    @Test
     public void testAngle() {
         // arrange
         Vector1D v1 = Vector1D.of(2);

Reply via email to