Quaternion angle calculation












0












$begingroup$


I'm working on a programming project, in this project I'm receiving an angle as a quaternion value, I partially understand how they work but I don't find any math to get the values I need.

What I would need is the angle between a fictional line/vector going to the the quaternion point from the origin (yes I know what you are thinking, but I couldn't think of a better explanation) and the "earth" a plane that is perpendicular to the gravitational vector, in this case one of your planes of reference.

Also I would need to get the rotation of the line/vector, this time the rotation should be according to the plane perpendicular to itself.

If possible all angles should be described as an angle between -180° and 180° (that's were my troubles are from.


If someone could help me by this it would be awesome

Thank you in advanced

~TJ


In this picture γ complementary angle of the first questing and R is the secondary angle.
Angles










share|cite|improve this question









$endgroup$












  • $begingroup$
    Do you mean something like Conversion between quaternions and Euler angles?
    $endgroup$
    – Somos
    Jan 15 at 23:13










  • $begingroup$
    I actualy tried implementing that a few times but it did't give me a result between -180° and 180°, I alsways had -90° to 90°. These are the formulas I used.
    $endgroup$
    – Tim Jager
    Jan 16 at 6:12












  • $begingroup$
    gx = 2 * (xz - wy) || gy = 2 * (wx + yz) || gz = ww - xx - yy + zz || yaw = atan2(2*xy - 2*wz, 2*ww + 2*xx - 1) || pitch = atan(gx / sqrt(gygy + gzgz)) || float roll = atan(gy/gz)
    $endgroup$
    – Tim Jager
    Jan 16 at 6:19










  • $begingroup$
    You should always use atan2(y,x) instead of atan(y/x). It is a common mistake.
    $endgroup$
    – Somos
    Jan 16 at 14:59












  • $begingroup$
    That did it. Thank you Somos.
    $endgroup$
    – Tim Jager
    Jan 16 at 19:49
















0












$begingroup$


I'm working on a programming project, in this project I'm receiving an angle as a quaternion value, I partially understand how they work but I don't find any math to get the values I need.

What I would need is the angle between a fictional line/vector going to the the quaternion point from the origin (yes I know what you are thinking, but I couldn't think of a better explanation) and the "earth" a plane that is perpendicular to the gravitational vector, in this case one of your planes of reference.

Also I would need to get the rotation of the line/vector, this time the rotation should be according to the plane perpendicular to itself.

If possible all angles should be described as an angle between -180° and 180° (that's were my troubles are from.


If someone could help me by this it would be awesome

Thank you in advanced

~TJ


In this picture γ complementary angle of the first questing and R is the secondary angle.
Angles










share|cite|improve this question









$endgroup$












  • $begingroup$
    Do you mean something like Conversion between quaternions and Euler angles?
    $endgroup$
    – Somos
    Jan 15 at 23:13










  • $begingroup$
    I actualy tried implementing that a few times but it did't give me a result between -180° and 180°, I alsways had -90° to 90°. These are the formulas I used.
    $endgroup$
    – Tim Jager
    Jan 16 at 6:12












  • $begingroup$
    gx = 2 * (xz - wy) || gy = 2 * (wx + yz) || gz = ww - xx - yy + zz || yaw = atan2(2*xy - 2*wz, 2*ww + 2*xx - 1) || pitch = atan(gx / sqrt(gygy + gzgz)) || float roll = atan(gy/gz)
    $endgroup$
    – Tim Jager
    Jan 16 at 6:19










  • $begingroup$
    You should always use atan2(y,x) instead of atan(y/x). It is a common mistake.
    $endgroup$
    – Somos
    Jan 16 at 14:59












  • $begingroup$
    That did it. Thank you Somos.
    $endgroup$
    – Tim Jager
    Jan 16 at 19:49














0












0








0





$begingroup$


I'm working on a programming project, in this project I'm receiving an angle as a quaternion value, I partially understand how they work but I don't find any math to get the values I need.

What I would need is the angle between a fictional line/vector going to the the quaternion point from the origin (yes I know what you are thinking, but I couldn't think of a better explanation) and the "earth" a plane that is perpendicular to the gravitational vector, in this case one of your planes of reference.

Also I would need to get the rotation of the line/vector, this time the rotation should be according to the plane perpendicular to itself.

If possible all angles should be described as an angle between -180° and 180° (that's were my troubles are from.


If someone could help me by this it would be awesome

Thank you in advanced

~TJ


In this picture γ complementary angle of the first questing and R is the secondary angle.
Angles










share|cite|improve this question









$endgroup$




I'm working on a programming project, in this project I'm receiving an angle as a quaternion value, I partially understand how they work but I don't find any math to get the values I need.

What I would need is the angle between a fictional line/vector going to the the quaternion point from the origin (yes I know what you are thinking, but I couldn't think of a better explanation) and the "earth" a plane that is perpendicular to the gravitational vector, in this case one of your planes of reference.

Also I would need to get the rotation of the line/vector, this time the rotation should be according to the plane perpendicular to itself.

If possible all angles should be described as an angle between -180° and 180° (that's were my troubles are from.


If someone could help me by this it would be awesome

Thank you in advanced

~TJ


In this picture γ complementary angle of the first questing and R is the secondary angle.
Angles







quaternions angle






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Jan 15 at 22:38









Tim JagerTim Jager

11




11












  • $begingroup$
    Do you mean something like Conversion between quaternions and Euler angles?
    $endgroup$
    – Somos
    Jan 15 at 23:13










  • $begingroup$
    I actualy tried implementing that a few times but it did't give me a result between -180° and 180°, I alsways had -90° to 90°. These are the formulas I used.
    $endgroup$
    – Tim Jager
    Jan 16 at 6:12












  • $begingroup$
    gx = 2 * (xz - wy) || gy = 2 * (wx + yz) || gz = ww - xx - yy + zz || yaw = atan2(2*xy - 2*wz, 2*ww + 2*xx - 1) || pitch = atan(gx / sqrt(gygy + gzgz)) || float roll = atan(gy/gz)
    $endgroup$
    – Tim Jager
    Jan 16 at 6:19










  • $begingroup$
    You should always use atan2(y,x) instead of atan(y/x). It is a common mistake.
    $endgroup$
    – Somos
    Jan 16 at 14:59












  • $begingroup$
    That did it. Thank you Somos.
    $endgroup$
    – Tim Jager
    Jan 16 at 19:49


















  • $begingroup$
    Do you mean something like Conversion between quaternions and Euler angles?
    $endgroup$
    – Somos
    Jan 15 at 23:13










  • $begingroup$
    I actualy tried implementing that a few times but it did't give me a result between -180° and 180°, I alsways had -90° to 90°. These are the formulas I used.
    $endgroup$
    – Tim Jager
    Jan 16 at 6:12












  • $begingroup$
    gx = 2 * (xz - wy) || gy = 2 * (wx + yz) || gz = ww - xx - yy + zz || yaw = atan2(2*xy - 2*wz, 2*ww + 2*xx - 1) || pitch = atan(gx / sqrt(gygy + gzgz)) || float roll = atan(gy/gz)
    $endgroup$
    – Tim Jager
    Jan 16 at 6:19










  • $begingroup$
    You should always use atan2(y,x) instead of atan(y/x). It is a common mistake.
    $endgroup$
    – Somos
    Jan 16 at 14:59












  • $begingroup$
    That did it. Thank you Somos.
    $endgroup$
    – Tim Jager
    Jan 16 at 19:49
















$begingroup$
Do you mean something like Conversion between quaternions and Euler angles?
$endgroup$
– Somos
Jan 15 at 23:13




$begingroup$
Do you mean something like Conversion between quaternions and Euler angles?
$endgroup$
– Somos
Jan 15 at 23:13












$begingroup$
I actualy tried implementing that a few times but it did't give me a result between -180° and 180°, I alsways had -90° to 90°. These are the formulas I used.
$endgroup$
– Tim Jager
Jan 16 at 6:12






$begingroup$
I actualy tried implementing that a few times but it did't give me a result between -180° and 180°, I alsways had -90° to 90°. These are the formulas I used.
$endgroup$
– Tim Jager
Jan 16 at 6:12














$begingroup$
gx = 2 * (xz - wy) || gy = 2 * (wx + yz) || gz = ww - xx - yy + zz || yaw = atan2(2*xy - 2*wz, 2*ww + 2*xx - 1) || pitch = atan(gx / sqrt(gygy + gzgz)) || float roll = atan(gy/gz)
$endgroup$
– Tim Jager
Jan 16 at 6:19




$begingroup$
gx = 2 * (xz - wy) || gy = 2 * (wx + yz) || gz = ww - xx - yy + zz || yaw = atan2(2*xy - 2*wz, 2*ww + 2*xx - 1) || pitch = atan(gx / sqrt(gygy + gzgz)) || float roll = atan(gy/gz)
$endgroup$
– Tim Jager
Jan 16 at 6:19












$begingroup$
You should always use atan2(y,x) instead of atan(y/x). It is a common mistake.
$endgroup$
– Somos
Jan 16 at 14:59






$begingroup$
You should always use atan2(y,x) instead of atan(y/x). It is a common mistake.
$endgroup$
– Somos
Jan 16 at 14:59














$begingroup$
That did it. Thank you Somos.
$endgroup$
– Tim Jager
Jan 16 at 19:49




$begingroup$
That did it. Thank you Somos.
$endgroup$
– Tim Jager
Jan 16 at 19:49










1 Answer
1






active

oldest

votes


















0












$begingroup$


You should always use atan2(y,x) instead of atan(y/x). It is a common mistake. – @Somos




Thank you, apparently that did it!






share|cite|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3075066%2fquaternion-angle-calculation%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$


    You should always use atan2(y,x) instead of atan(y/x). It is a common mistake. – @Somos




    Thank you, apparently that did it!






    share|cite|improve this answer









    $endgroup$


















      0












      $begingroup$


      You should always use atan2(y,x) instead of atan(y/x). It is a common mistake. – @Somos




      Thank you, apparently that did it!






      share|cite|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$


        You should always use atan2(y,x) instead of atan(y/x). It is a common mistake. – @Somos




        Thank you, apparently that did it!






        share|cite|improve this answer









        $endgroup$




        You should always use atan2(y,x) instead of atan(y/x). It is a common mistake. – @Somos




        Thank you, apparently that did it!







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Jan 16 at 17:53









        Tim JagerTim Jager

        11




        11






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3075066%2fquaternion-angle-calculation%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Mario Kart Wii

            What does “Dominus providebit” mean?

            Antonio Litta Visconti Arese