[ 
https://issues.apache.org/jira/browse/GEOMETRY-150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17743185#comment-17743185
 ] 

Matt Juntunen commented on GEOMETRY-150:
----------------------------------------

A few comments:
- {{Vectors}} is in the {{internal}} package and is not intended to be part of 
the public API. We should not add any method intended for public use there.
- Two vectors are codirectional if the dot product of their normalized forms is 
equal to 1. But how close to 1 do we have to be in order to return true? This 
makes me think that this method needs to accept a 
{{Precision.DoubleEquivalence}} in order to allow the caller to specify how 
close we need to be.
- This could possibly be implemented as a default method in {{Vector}} with 
something like this:
{code:java}
default boolean isCodirectionalWith(final V other, final 
Precision.DoubleEquivalence precision) {
    final V thisNormalized = normalizeOrNull();
    final V otherNormalized = other.normalizeOrNull();
        
    if (thisNormalized != null && otherNormalized != null) {
        final double dot = thisNormalized.dot(otherNormalized);
        return precision.eq(dot, 1.0);
    }
    return false;
}
{code}

> implement isCodirectionalTo(Vector y)
> -------------------------------------
>
>                 Key: GEOMETRY-150
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-150
>             Project: Commons Geometry
>          Issue Type: New Feature
>          Components: euclidean1D
>            Reporter: Dimitrios Efthymiou
>            Priority: Minor
>              Labels: features
>             Fix For: 1.1
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> implement isCodirectionalTo(Vector y) method in the Vector interface. The 
> isCodirectionalTo() checks if the 2 vectors point at the same direction. This 
> means that each vector can be obtained from the other by multiplying by a 
> positive scalar.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to