quaternions

Asked by Chiara Modenese on 2012-02-22

Hi there,
if I take the difference between two quaternions in Yade should I worry about anything at all? I recall these two lines in ScGeom.cpp (which I find difficult to gather -- maybe there is an old discussion about it?)

#else
    if (isnan(aa.angle())) aa.angle()=0;
#endif
   if (aa.angle() > Mathr::PI) aa.angle() -= Mathr::TWO_PI; // angle is between 0 and 2*pi, but should be between -pi and pi

Thanks for advice!
Chiara

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
2012-02-22
Last query:
2012-02-22
Last reply:
2012-02-22

By "difference", do you mean q1*q2^-1 or q1-q2?
The first case should be safe now if eigen fixed the problem (I think they should but I didn't keep exact track of what they did), else the isnan() test is a workaround.
The second case: does it make sense mathematicaly?

On 22 Feb 2012, at 11:55, Chareyre wrote:

> Your question #188478 on Yade changed:
> https://answers.launchpad.net/yade/+question/188478
>
> Status: Open => Answered
>
> Chareyre proposed the following answer:
> By "difference", do you mean q1*q2^-1 or q1-q2?
> The first case should be safe now if eigen fixed the problem (I think they should but I didn't keep exact track of what they did), else the isnan() test is a workaround.
Of course I meant the first case. OK, so the workaround is still necessary, I just wanted confirmation of that.

What about this second line?
if (aa.angle() > Mathr::PI) aa.angle() -= Mathr::TWO_PI; // angle is between 0 and 2*pi, but should be between -pi and pi

Thanks,
Chiara

> The second case: does it make sense mathematicaly?
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/yade/+question/188478/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/yade/+question/188478
>
> You received this question notification because you asked the question.

I didn't mean the workaround was necessary. It should not (because eigen
devs must have fix this iirc). But _if_ you still find problems the
workaround will fix them.
For the second line, it is independant and it speaks by itself: by
convention angle is between 0 and 2pi in eigen, if you want variations
centered on zero then you shift some values.

Bruno

OK, thanks Bruno for clarification!
C.

Thanks Chareyre, that solved my question.