Jump to content

  • Log In with Google      Sign In   
  • Create Account

bitinf

Member Since 06 Apr 2013
Offline Last Active Apr 08 2013 03:54 PM

Posts I've Made

In Topic: conversion quaternion <--->euler angles goes wrong

06 April 2013 - 04:18 PM

thanks a lot!

Any set of the angles will do (just like returning q or -q is acceptable as well). If you want the other quaternion representing the Eulers, negate it.

 

I guess the reason for ambiguity is because of the call to asin (which returns angles only in a 180 degree (or pi radian) range), not the full range (because of how inverse functions work, they can only return one value). Try adding pi on to the return from asin, you will probably get the other quaternion instead... (EDIT: asin(x + pi) != asin(x) so ignore that ;), the formula is asin(x + pi) = -asin(x), I think [too much beer])

 

(atan2 does return full 2pi radian range though).

 

I wouldn't worry about it though. Note the trig functions don't really have inverse functions (since a function can only return one value in the strict mathematical sense of the term), asin is a restirction of the "inverse" sin funtion so that it does have a unique inverse.

 

EDIT: Try thinking of it like this instead:

 

why doesn't sqrt(-1 * -1) return -1? Same deal.


In Topic: conversion quaternion <--->euler angles goes wrong

06 April 2013 - 03:05 PM

Thank you so much for the timely reply. I know -q and q represent the same rotation.

You say that one quaternion may have many corresponding Euler angles. I also think so. But why common methods only return a single set of angles?   And the same, why the inverse (from angles to quaternion) returns a single quaternion?  Are there some rules in it?

Thanks!

 

q and -q represent the same rotation, unit quaternions are a double cover for the sphere.

 

The only issue is when interpolating/slerping quaternions, you want to go the quickest route rather than the long way round, but you can do that by checking that the quaternion dot product between the 2 quaternions is positive, if it is negative negate one of the quaternions before interpolation.

 

EDIT: If you think about the axis/rotation form of a quaternion it is easy to see that -q and q represent the same rotation; the axis is negated but so is the rotation angle => they represent the same rotation.

 

EDIT2: Euler angle representations aren't unique either, so converting Euler angles to a quaternion and then back again might not give you the same angles back either ;)

 

EDIT3: So in conclusion, there's nothing to worry about.


PARTNERS