Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Euler to Quaternion conversion is incorrect #164
It seems that using the set method for the QuatF object and passing it an EulerF it incorrectly converts. Somewhere an axis ends up being negative when it was positive. This doesn't happen when passing it an angle axis.
I didn't really change the existing code to fix it, because I didn't have time to look at it real close, but instead commented it out and just wrote my own based on(http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm):
That should fix it. Also I don't don't if there was originally a QuatD class, but I made one so if there is change it respectively there as well.
Once I figure out a workflow for submitting fixes on here I will start making these changes myself, but don't really have the time at work yet.
Also if you want something to test with just use this:
You will notice rot has a negative 0.7071067811... which is incorrect, then if you use this:
you will get something like this: "0.00000000000000000 0.00000000000000000 0.70710678118654746 0.70710678118654757"
I was using doubles (F64) the entire time so that is why my values are huge.
If I'm reading it right, translating it to stock would give:
QuatF& QuatF::set( const EulerF & e )
// Qyaw(z) = [ (0, 0, sin z/2), cos z/2 ]
Bit beyond my personal comfort level though for throwing that out as a PR, since it's not math I'm heavily familiar with.
Okay, I'm writing unit tests for this using the following approach. I create an
Currently it works if I expect the angle to be less than 1e-3. Is that too large a tolerance? I mean, that's 1/1000th of a radian...