Jump to content
  • Advertisement
Alundra

Quaternion to Euler very imprecise

Recommended Posts

Posted (edited)
6 hours ago, a light breeze said:

Don't.  Just don't.  "Euler" isn't some arbitrary sequence of letters, it's the last name of the mathematician Leonhard Euler (pronounced /ˈɔɪlər/), and deliberately mispronouncing somebody's name is just incredibly insulting.

I apologise as I didn't mean to offend, slightly off topic, but it is quite interesting linguistically this kind of thing, and often comes up with Euler angles: :) 

https://english.stackexchange.com/questions/315906/pronunciation-of-the-name-leonhard-euler

It has some similarities to a 'borrowed word' from another language. Often the pronounciation will be changed to fit more easily with the language that adopts it .. see pidgin english for example. As well as the phonetic pronounciation being 'yooler' in english, there is a conflict with the word oil, and our existing word oiler, in which case it makes total sense to alter the pronounciation in english, otherwise you are relying on context for meaning.

The counterargument of course, which has won in maths, is that as a name it should be preserved as spoken in the original language. But you can see there are valid arguments both ways. And of course languages are dynamic, evolving and subject to change, I believe pronounciation in english has changed greatly in the past few hundred years, compare the difference between american english and british english for example. You say tomato, I say tomato... :D 

Edited by lawnjelly

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

https://www.andre-gaschler.com/rotationconverter/

What I'm observing from using this online converter, It appears that quaternion is indeed 45° on each axis but in the YXZ arrangement. The Euler's you get are partially confirmed but flipped Y and Z. Matching YXZ gives 45° Euler angles across the board. 

Perhaps that's a clue.

edit: if I use your ZXY arrangement, then the input quaternion is (appears) incorrect.

Edited by GoliathForge

Share this post


Link to post
Share on other sites
30 minutes ago, GoliathForge said:

https://www.andre-gaschler.com/rotationconverter/

What I'm observing from using this online converter, It appears that quaternion is indeed 45° on each axis but in the YXZ arrangement. The Euler's you get are partially confirmed but flipped Y and Z. Matching YXZ gives 45° Euler angles across the board. 

Perhaps that's a clue.

edit: if I use your ZXY arrangement, then the input quaternion is incorrect.

That's a brilliant webpage .. shows exactly what is going on. His conversion to quaternion is using YXZ convention, and the conversion back to euler is using YZX convention I believe. If you convert back to euler using the same YXZ convention you get 45 degrees. :D 

Share this post


Link to post
Share on other sites
Posted (edited)

Looks like in reality it's an handedness problem, I'm in left handed, my FromEuler is in left handed and the ToEuler is in right handed. The calculation from this website is in right handed.

Edited by Alundra

Share this post


Link to post
Share on other sites
55 minutes ago, Alundra said:

Looks like in reality it's an handedness problem, I'm in left handed, my FromEuler is in left handed and the ToEuler is in right handed. The calculation from this website is in right handed.

Just out of curiosity, what leads you to believe it's due to handedness and not (as you originally surmised) axis order? (I ask because, as far as I know at least, Euler-angle conversions are usually agnostic with respect to handedness, whereas axis order does in fact matter.)

Share this post


Link to post
Share on other sites

I finally got the left handed version working:

void Quaternion::ToEulerAngles(float* X, float* Y, float* Z) const
{
    const float SingularityTest = (x * w) - (y * z);
    if (SingularityTest > 0.4999995f)
    {
        *Y = 2.0f * atan2(y, x);
        *X = CMath::HALF_PI;
        *Z = 0.0f;
    }
    else if (SingularityTest < -0.4999995f)
    {
        *Y = -2.0f * atan2(y, x);
        *X = -CMath::HALF_PI;
        *Z = 0.0f;
    }
    else
    {
        *Y = atan2(2.0f * w * y + 2.0f * x * z, 1.0f - 2.0f * (x * x + y * y));
        *X = asin(2.0f * SingularityTest);
        *Z = atan2(2.0f * w * z + 2.0f * x * y, 1.0f - 2.0f * (x * x + z * z));
    }
}

 

Share this post


Link to post
Share on other sites

I'll repeat myself and say that I'm skeptical that Euler-angle conversions are handedness-aware. I just mention this in case you're somehow confusing handedness with axis order (which would be easy to do, since both of these conventions can vary from source to source).

As an exercise, it might be interesting to try writing left- and right-handed versions of the same conversion function and see how they differ. That might provide some insight as to whether handedness is actually a factor.

Share this post


Link to post
Share on other sites

Well, handedness changes the sign of the angle in this case. I.e., it determines if an angle rotates clockwise or counterclockwise around an axis.

Share this post


Link to post
Share on other sites
4 hours ago, l0calh05t said:

Well, handedness changes the sign of the angle in this case. I.e., it determines if an angle rotates clockwise or counterclockwise around an axis.

That's (partly) true, but that's not the question. The question is, does choice of handedness affect how Euler-angle conversion should be implemented? I'm suggesting it does not.

I'm happy to be corrected, but I think something concrete is needed here, such as example code showing how left- and right-handed versions of an Euler-angle conversion function might differ, or at least an explanation of how choice of handedness would affect the code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!