Hi, 2012/9/20 Anxionnat Julien <julien.anxion...@cnes.fr>: >> De : Tanguy Yannick [mailto:yannick.tan...@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
--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org