# 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

Chiara

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
2012-02-22
Last query:
2012-02-22
2012-02-22
 Bruno Chareyre (bruno-chareyre) said on 2012-02-22: #1

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?

 Chiara Modenese (chiara-modenese) said on 2012-02-22: #2

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

>
>
> 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.

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?
>
> --
> know that it is solved:
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
>

 Bruno Chareyre (bruno-chareyre) said on 2012-02-22: #3

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

 Chiara Modenese (chiara-modenese) said on 2012-02-22: #4

OK, thanks Bruno for clarification!
C.

 Chiara Modenese (chiara-modenese) said on 2012-02-22: #5

Thanks Chareyre, that solved my question.