darkma773r commented on code in PR #217:
URL: https://github.com/apache/commons-geometry/pull/217#discussion_r1273636413


##########
commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Vector.java:
##########
@@ -142,4 +144,24 @@ public interface Vector<V extends Vector<V>> extends 
Spatial {
      * @throws IllegalArgumentException if either vector has a zero, NaN, or 
infinite norm
      */
     double angle(V v);
+
+
+    /**
+     * Determines if this vector has teh same direction as the other vector.
+     * It normalizes both vectors and if the dot product of them is 1,
+     * then it returns {@code true}, otherwise {@code false}.
+     * @param other other vector
+     * @param precision precision object used for floating point comparisons
+     * @return {@code true} if this vector has the same direction as the otehr 
vector.
+     */
+    default boolean isCodirectionalWith(final V other, final 
Precision.DoubleEquivalence precision) {
+        final V thisNormalized = normalizeOrNull();
+        final V otherNormalized = other.normalizeOrNull();
+
+        if (thisNormalized != null && otherNormalized != null) {

Review Comment:
   We need unit tests for the following:
   - cases where one or both vectors cannot be normalized (i.e., they are zero, 
NaN, or infinite)
   - cases where the vectors are very close but not exactly pointing in the 
same direction (the given precision determines the result in these cases)
   
   Add these tests to `commons-geometry-core` (see `SizedTest` for a possible 
example of how to do this) and the corresponding `VectorXDTest` classses.



##########
commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Vector.java:
##########
@@ -142,4 +144,24 @@ public interface Vector<V extends Vector<V>> extends 
Spatial {
      * @throws IllegalArgumentException if either vector has a zero, NaN, or 
infinite norm
      */
     double angle(V v);
+
+
+    /**
+     * Determines if this vector has teh same direction as the other vector.
+     * It normalizes both vectors and if the dot product of them is 1,
+     * then it returns {@code true}, otherwise {@code false}.
+     * @param other other vector
+     * @param precision precision object used for floating point comparisons
+     * @return {@code true} if this vector has the same direction as the otehr 
vector.

Review Comment:
   - typo `teh` -> `the`
   - Document the expected result when one or both of the vectors cannot be 
normalized



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to