[ 
https://issues.apache.org/jira/browse/GEOMETRY-26?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Matt Juntunen closed GEOMETRY-26.
---------------------------------

> Vector safeNormalize()
> ----------------------
>
>                 Key: GEOMETRY-26
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-26
>             Project: Apache Commons Geometry
>          Issue Type: Wish
>            Reporter: Matt Juntunen
>            Priority: Minor
>
> I propose adding a {{safeNormalize}} method to the {{Vector}} classes that 
> will return null instead throwing an exception when attempting to normalize. 
> The rationale for this is that
> in some algorithms, different actions may need to be taken depending on 
> whether or not a vector can be normalized. It is inefficient to calculate the 
> norm, determine if it is valid (zero, NaN, or infinite), and then calculate 
> it again in the {{normalize}} method to perform the normalization. One 
> approach to avoid this is to simply call {{normalize}} and then catch any 
> exceptions that are thrown on failure (this is what 
> {{QuaternionRotation.getAxis()}} does). However, I think having a null check 
> will produce cleaner code.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to