← Back to team overview

yade-dev team mailing list archive

Re: computation of MomentBending

 

Question sent to Eigen forum (http://forum.kde.org/viewtopic.php?f=74&t=91129).

More fun with quaternions (showing that pasting the numbers from cerr<< is pointless for testing) :

Step 1 :
cerr<<q
 ->  1 -1.56132e-11 7.47311e-11 -1.7066e-10
cerr<<q.w()
-> 1
NaN angle found in angleAxisr(q)

Step 2 :
q.normalize; cerr<<q
->  1 -1.56132e-11 7.47311e-11 -1.7066e-10 //Exactly the same output
cerr<<q.w()
-> 1
_No NaN angle found_ in angleAxisr(q), angle is 0.

We were discussing with Vaclav, lately, the weird "numerical_precision" (or whatever it is called) parameter of Wm3; There is actually a similar trick in Eigen::angleAxis (this copy operator is used in the constructor) :

template<typename Scalar>
AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionType& q)
{
  Scalar n2 = q.vec().squaredNorm();
_if (n2 < precision<Scalar>()*precision<Scalar>())_
  {
    m_angle = 0;
    m_axis << 1, 0, 0;
  }
  else
  {
m_angle = 2*std::acos(q.w());<--------- here we are computing acos(1) in step 1 and 2 according to cerr...
    m_axis = q.vec() / ei_sqrt(n2);
  }
  return *this;
}



On 26/10/10 19:07, Janek Kozicki wrote:
Václav Šmilauer said:     (by the date of Tue, 26 Oct 2010 18:58:32 +0200)

so, for example a function that calculates axis angle, could do a
check if that argument to acos is higher that 1.0. And if yes - then
perform a normalization, to bring back down that quaternion to an
identity quaternion. This method will prevent quaternions from growing
bigger than indentity, but will not catch quaternions that get
smaller than identity - and that should be prevented too somehow (but
will not produce NaNs).
I think it should be fixed in eigen, if that is a pure numerics problem.
That's why we use libs, to not do everything ourselves.
yep, and so I'm glad that Bruno will contact them :)

What happens if you re-normalize all quaternions before computing the
product? (just to check; I am not suggesting to do it all the time)
Then a simple thing happens: your quaternions are always good!

Numerical error is a thing that we cannot get rid of, we must live
with it. And it accumulates.



--
_______________
Bruno Chareyre
Associate Professor
ENSE^(3) - Grenoble INP
Lab. 3SR
BP 53 - 38041, Grenoble cedex 9 - France
Tél : +33 4 56 52 86 21
Fax : +33 4 76 82 70 43
________________


Follow ups

References