[
https://issues.apache.org/jira/browse/GEOMETRY-17?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16621443#comment-16621443
]
Matt Juntunen commented on GEOMETRY-17:
---------------------------------------
I see what you mean as far as the weirdness of the getRealNonZeroNorm() method.
My concern with the isFinite() method is that we'd be double-computing the norm
in a lot of cases: first to check it and then to return it. I'd prefer to do it
all in one go. I previously had this method private and used that Vectors
utility method to do the check so I can revert back to that. Outside callers
will just need to perform their own checks if needed.
Regarding the skipping of validation in places, that sounds really interesting.
Perhaps our rule of thumb could be that we only throw when we are unable to
meet the requirements placed on the return value by the API. For example,
normalize() would throw because if the norm is zero, NaN, or infinite, the norm
of the returned vector will not be 1, as the API states. Similarly, project()
and reject() should throw since the requirement is that the two returned
vectors add to the original. On the other hand, angle() doesn't need to throw
because we're just performing a calculation and there is no constraint on its
value. So, the following methods would throw and everything else would
propagate zero norms, NaNs, and infinities:
# normalize()
# withNorm(double)
# project(Vector)
# reject(Vector)
# orthogonal()
# orthogonal(Vector)
I also think that we should probably move the project, reject, and orthogonal
methods into an interface specific for Euclidean vectors with 2 or more
dimensions. I have project and reject in Vector1D now and they really don't
make sense there.
> Euclidean Vector Method Follow-Up
> ---------------------------------
>
> Key: GEOMETRY-17
> URL: https://issues.apache.org/jira/browse/GEOMETRY-17
> Project: Apache Commons Geometry
> Issue Type: Improvement
> Reporter: Matt Juntunen
> Priority: Major
>
> This is a follow-up issue to GEOMETRY-9. The following tasks should be
> completed:
> # Vector2D - needs an orthogonal() method like Vector3D
> # Vector#getMagnitude() should be removed. I originally added this as part
> of GEOMETRY-9 as an alias for getNorm(), but after thinking about it more and
> working with it, I believe it's more confusing than useful to have multiple
> names in the code base for the same idea.
> # Vector#withMagnitude() should be renamed to Vector#withNorm() for the same
> reason as above.
> # Vector#getRealNonZeroNorm() - This is currently a private method in the
> Vector implementation classes but I believe it is useful enough to be made
> public. The idea is that this would return the vector norm but throw an
> IllegalNormException if the norm is zero, NaN, or infinite. I've already come
> across some places in other classes (such as Rotation) where I want to use
> this.
>
> Pull request: https://github.com/apache/commons-geometry/pull/11
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)