commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tanguy Yannick <Yannick.Tan...@cnes.fr>
Subject RE: [math] Adding some methods in Precision class (oacm.util)
Date Thu, 20 Sep 2012 15:44:21 GMT
>Hi,

>2012/9/20 Anxionnat Julien <Julien.Anxionnat@cnes.fr>:
>>> De : Tanguy Yannick [mailto:Yannick.Tanguy@cnes.fr] About the default 
>>> value (1e-14), I know the tolerance is case- dependant, but some 
>>> times, we don't precisely know the order of magnitude (ex : jacobians 
>>> matrices) and it's quite practical to have a default value.
>>
>> Hi,
>> A point of the discussion with Gilles in the MATH-863 (new Quaternion 
>> class) is about this magic 1E-14. ;)
>>
>> Consider the following methods:
>>
>>     public Quaternion normalize() {
>>         final double norm = getNorm();
>>         if (norm >= Precision.SAFE_MIN) {
>>             return new Quaternion(q0 / norm, q1 / norm, q2 / norm, q3 / norm);
>>         } else {
>>             throw new ZeroException();
>>         }
>>     }
>>
>>     public boolean isUnitQuaternion() {
>>         final double norm = getNorm();
>>         if (Precision.equals(norm, 1.0, Precision.EPSILON)) {
>>             return true;
>>         } else {
>>             return false;
>>         }
>>     }
>>
>>
>> => There are many cases where
>>
>>     myQuaternion.normalize().isUnitQuaternion()
>> returns "false".
>>
>> The Precision.EPSILON is too small. That's why we use this "historical" arbitrary
tolerance of 1E-14.
>>
>>
>> Do you think that adding a tolerance parameter in this method isUnitQuaternion()
(and in its neighboors) is a good idea ?
>>
>>
>> Julien
>>
>I think a tolerance parameter which defaults to 1E-14 in my view be the best option. I
have nothing against this magic number; I just don't think that it should sit in the general
class Precision. I think this is also what makes Gilles unhappy (TBC). How about a static
final double Quaternion.DEFAULT_TOL, instead of Precision.DEFAULT_TOL?
>S├ębastien

Ok, I understand your point of view, it make sense to put specific epsilon/tolerance value
in the corresponding classes (and to justify the value!!). We'll propose this default value
in the Quaternion class (see feature 863) and will use the same mechanism in our other classes.
Best regards,

Yannick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message