← Back to team overview

yade-users team mailing list archive

Re: Be carefull with "normalize"


Luc Sibille a écrit :

 Is the "normalize" function from wm3 used currently in Yade?
Vectors in Yade are vectors from wm3, and - if I'm not wrong - "normalize" is a member of this class. So yes, unless you find an exception, any "normalize" in Yade is the one i was speaking about.
I know how you feel...

Bruno have you got an idea of the default value of the "tolerance" value? The reason for this check could be to avoid a division by zero or "something" to close to zero.

Well... there is no reason to avoid division by zero, and even less reasons to return a null vector instead of (1,0,0) or something like this. If a division by zero makes the program crash, so should do the normalization of a null vector. But this is still not the problem here : vectors are not null at all, they are just "something small" with respect to what the developper of wm3 considered "small", arbitrarily. In my understanding of number representations (someone will correct me perhaps), there is no less precision when computing the norm of (2e-20, 1e-20, 0) compared to the norm of (2e+20, 1e+20, 0). That is why this tolerance makes no sense.

Think to it as a matter of units, like in previous Janek mail. If one wants to define the simulation with lengths in gigakilometers, and get coordinates in the range 10e-30 - 10e-32, no "tolerance" should prevent it.



Bruno Chareyre a écrit :

Be aware that if you use the "normalize" function from wm3, it might give the result (0,0,0) if the norm of the vector is smaller than a "tolerance" value. It sounds very strange to me, as I see no reason for this check, and I was wondering if it could not cause problems in some cases, when a "normalized" vector has length 0... Janek had this problem when defining the normal of some triangular facets (of small size) by normalizing the cross product of edges vectors. I prefer not to be the only one thinking about this potential problem, which probably needs a fix.

A few ideas from a discussion with Janek :
1- possibly fix minWm3 so that the test vs. tolerance is removed
2- display a warning to the user when the tolerance is hit and the vector is "rounded" to (0,0,0)
3-  run batch tests with/without the tolerance test



Chareyre Bruno
Maitre de conference

Grenoble INP
Laboratoire 3SR - bureau E145
BP 53 - 38041, Grenoble cedex 9 - France
Tél : 33 4 56 52 86 21
Fax : 33 4 76 82 70 43

Follow ups