Shortest way to achieve target angle

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












Suppose I am moving in a certain compass bearing (e.g. $270^circ$) and I want to be going in a different direction (e.g. $120^circ$). Is there a formula or series of math operations that I can use to determine which direction I should turn (I want the shorter direction)?



I've tried to increase my angle, i.e. turn counterclockwise, if $texttarget bearing - textcurrent bearing < 360 - (texttarget bearing - textcurrent bearing)$, and it only seems to work in some cases.



Please help! I've been having lots of trouble.







share|cite|improve this question






















  • I've edited this as I understand it. If I interpreted your question incorrectly, please change it or let me know.
    – davidlowryduda♦
    Feb 16 '12 at 18:10










  • That's correct, thanks. As you might guess, English isn't my mother tongue. :D
    – Ruuhkis
    Feb 16 '12 at 18:33















up vote
1
down vote

favorite
1












Suppose I am moving in a certain compass bearing (e.g. $270^circ$) and I want to be going in a different direction (e.g. $120^circ$). Is there a formula or series of math operations that I can use to determine which direction I should turn (I want the shorter direction)?



I've tried to increase my angle, i.e. turn counterclockwise, if $texttarget bearing - textcurrent bearing < 360 - (texttarget bearing - textcurrent bearing)$, and it only seems to work in some cases.



Please help! I've been having lots of trouble.







share|cite|improve this question






















  • I've edited this as I understand it. If I interpreted your question incorrectly, please change it or let me know.
    – davidlowryduda♦
    Feb 16 '12 at 18:10










  • That's correct, thanks. As you might guess, English isn't my mother tongue. :D
    – Ruuhkis
    Feb 16 '12 at 18:33













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





Suppose I am moving in a certain compass bearing (e.g. $270^circ$) and I want to be going in a different direction (e.g. $120^circ$). Is there a formula or series of math operations that I can use to determine which direction I should turn (I want the shorter direction)?



I've tried to increase my angle, i.e. turn counterclockwise, if $texttarget bearing - textcurrent bearing < 360 - (texttarget bearing - textcurrent bearing)$, and it only seems to work in some cases.



Please help! I've been having lots of trouble.







share|cite|improve this question














Suppose I am moving in a certain compass bearing (e.g. $270^circ$) and I want to be going in a different direction (e.g. $120^circ$). Is there a formula or series of math operations that I can use to determine which direction I should turn (I want the shorter direction)?



I've tried to increase my angle, i.e. turn counterclockwise, if $texttarget bearing - textcurrent bearing < 360 - (texttarget bearing - textcurrent bearing)$, and it only seems to work in some cases.



Please help! I've been having lots of trouble.









share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Feb 17 '12 at 4:20









J. M. is not a mathematician

59.9k5146283




59.9k5146283










asked Feb 16 '12 at 18:00









Ruuhkis

1084




1084











  • I've edited this as I understand it. If I interpreted your question incorrectly, please change it or let me know.
    – davidlowryduda♦
    Feb 16 '12 at 18:10










  • That's correct, thanks. As you might guess, English isn't my mother tongue. :D
    – Ruuhkis
    Feb 16 '12 at 18:33

















  • I've edited this as I understand it. If I interpreted your question incorrectly, please change it or let me know.
    – davidlowryduda♦
    Feb 16 '12 at 18:10










  • That's correct, thanks. As you might guess, English isn't my mother tongue. :D
    – Ruuhkis
    Feb 16 '12 at 18:33
















I've edited this as I understand it. If I interpreted your question incorrectly, please change it or let me know.
– davidlowryduda♦
Feb 16 '12 at 18:10




I've edited this as I understand it. If I interpreted your question incorrectly, please change it or let me know.
– davidlowryduda♦
Feb 16 '12 at 18:10












That's correct, thanks. As you might guess, English isn't my mother tongue. :D
– Ruuhkis
Feb 16 '12 at 18:33





That's correct, thanks. As you might guess, English isn't my mother tongue. :D
– Ruuhkis
Feb 16 '12 at 18:33











3 Answers
3






active

oldest

votes

















up vote
6
down vote



accepted










Let $T$ be the target bearing and $C$ be the current bearing. Let's consider three numbers:



$$beginalignalpha&=T-C\
beta&=T-C+360°\
gamma&=T-C-360°endalign$$



Now, whichever of $|alpha|$, $|beta|$, and $|gamma|$ is the smallest tells us which of $alpha$, $beta$, and $gamma$ is relevant and if the one with the smallest absolute value is positive, go clockwise, and if it's negative, go counterclockwise.



edit The animation below shows the locations of the target point in red and the current point in blue, for various values of each, with the values of $|alpha|$, $|beta|$, and $|gamma|$ as well as the motion (which is indicated by an arc along the circle) shown in the lower right corner.



enter image description here






share|cite|improve this answer






















  • This is absolutely best answer one can ever get! Thanks for amazing visualizing too, I am more of visual learner. :) Couldn't thank you enough!
    – Ruuhkis
    Feb 17 '12 at 7:28

















up vote
2
down vote













If you're looking for a "one-liner", let $T$ be the target bearing and $C$ be the current bearing:



$$beginaligndelta&=(T-C+540°)bmod360°-180°endalign$$



The shortest rotation distance in degrees is given by $delta$. Positive values indicate clockwise rotation, negative values indicate counterclockwise rotation.



$180°$ turns are always expressed as counterclockwise $-180°$.






share|cite|improve this answer




















  • Awesome, thanks!
    – Pasi Matalamäki
    Aug 30 at 9:03

















up vote
0
down vote













Say you're going at bearing $a$ and your target bearing is $b$. I'll assume that both $a$ and $b$ are between zero (inclusive) and 360 (exclusive), and I'll also assume that the direction of increasing bearing is counterclockwise (that's the usual convention in higher math, and I think it's the one you are using). Here are the cases:



If $alt b$, and $b-ale180$, turn counterclockwise.



If $alt b$, and $b-agt180$, turn clockwise.



If $agt b$, and $a-ble180$, turn clockwise.



If $agt b$, and $a-bgt180$, turn counterclockwise.






share|cite|improve this answer




















    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    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%2f110080%2fshortest-way-to-achieve-target-angle%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    Let $T$ be the target bearing and $C$ be the current bearing. Let's consider three numbers:



    $$beginalignalpha&=T-C\
    beta&=T-C+360°\
    gamma&=T-C-360°endalign$$



    Now, whichever of $|alpha|$, $|beta|$, and $|gamma|$ is the smallest tells us which of $alpha$, $beta$, and $gamma$ is relevant and if the one with the smallest absolute value is positive, go clockwise, and if it's negative, go counterclockwise.



    edit The animation below shows the locations of the target point in red and the current point in blue, for various values of each, with the values of $|alpha|$, $|beta|$, and $|gamma|$ as well as the motion (which is indicated by an arc along the circle) shown in the lower right corner.



    enter image description here






    share|cite|improve this answer






















    • This is absolutely best answer one can ever get! Thanks for amazing visualizing too, I am more of visual learner. :) Couldn't thank you enough!
      – Ruuhkis
      Feb 17 '12 at 7:28














    up vote
    6
    down vote



    accepted










    Let $T$ be the target bearing and $C$ be the current bearing. Let's consider three numbers:



    $$beginalignalpha&=T-C\
    beta&=T-C+360°\
    gamma&=T-C-360°endalign$$



    Now, whichever of $|alpha|$, $|beta|$, and $|gamma|$ is the smallest tells us which of $alpha$, $beta$, and $gamma$ is relevant and if the one with the smallest absolute value is positive, go clockwise, and if it's negative, go counterclockwise.



    edit The animation below shows the locations of the target point in red and the current point in blue, for various values of each, with the values of $|alpha|$, $|beta|$, and $|gamma|$ as well as the motion (which is indicated by an arc along the circle) shown in the lower right corner.



    enter image description here






    share|cite|improve this answer






















    • This is absolutely best answer one can ever get! Thanks for amazing visualizing too, I am more of visual learner. :) Couldn't thank you enough!
      – Ruuhkis
      Feb 17 '12 at 7:28












    up vote
    6
    down vote



    accepted







    up vote
    6
    down vote



    accepted






    Let $T$ be the target bearing and $C$ be the current bearing. Let's consider three numbers:



    $$beginalignalpha&=T-C\
    beta&=T-C+360°\
    gamma&=T-C-360°endalign$$



    Now, whichever of $|alpha|$, $|beta|$, and $|gamma|$ is the smallest tells us which of $alpha$, $beta$, and $gamma$ is relevant and if the one with the smallest absolute value is positive, go clockwise, and if it's negative, go counterclockwise.



    edit The animation below shows the locations of the target point in red and the current point in blue, for various values of each, with the values of $|alpha|$, $|beta|$, and $|gamma|$ as well as the motion (which is indicated by an arc along the circle) shown in the lower right corner.



    enter image description here






    share|cite|improve this answer














    Let $T$ be the target bearing and $C$ be the current bearing. Let's consider three numbers:



    $$beginalignalpha&=T-C\
    beta&=T-C+360°\
    gamma&=T-C-360°endalign$$



    Now, whichever of $|alpha|$, $|beta|$, and $|gamma|$ is the smallest tells us which of $alpha$, $beta$, and $gamma$ is relevant and if the one with the smallest absolute value is positive, go clockwise, and if it's negative, go counterclockwise.



    edit The animation below shows the locations of the target point in red and the current point in blue, for various values of each, with the values of $|alpha|$, $|beta|$, and $|gamma|$ as well as the motion (which is indicated by an arc along the circle) shown in the lower right corner.



    enter image description here







    share|cite|improve this answer














    share|cite|improve this answer



    share|cite|improve this answer








    edited Feb 17 '12 at 4:53

























    answered Feb 17 '12 at 3:30









    Isaac

    29.6k1185128




    29.6k1185128











    • This is absolutely best answer one can ever get! Thanks for amazing visualizing too, I am more of visual learner. :) Couldn't thank you enough!
      – Ruuhkis
      Feb 17 '12 at 7:28
















    • This is absolutely best answer one can ever get! Thanks for amazing visualizing too, I am more of visual learner. :) Couldn't thank you enough!
      – Ruuhkis
      Feb 17 '12 at 7:28















    This is absolutely best answer one can ever get! Thanks for amazing visualizing too, I am more of visual learner. :) Couldn't thank you enough!
    – Ruuhkis
    Feb 17 '12 at 7:28




    This is absolutely best answer one can ever get! Thanks for amazing visualizing too, I am more of visual learner. :) Couldn't thank you enough!
    – Ruuhkis
    Feb 17 '12 at 7:28










    up vote
    2
    down vote













    If you're looking for a "one-liner", let $T$ be the target bearing and $C$ be the current bearing:



    $$beginaligndelta&=(T-C+540°)bmod360°-180°endalign$$



    The shortest rotation distance in degrees is given by $delta$. Positive values indicate clockwise rotation, negative values indicate counterclockwise rotation.



    $180°$ turns are always expressed as counterclockwise $-180°$.






    share|cite|improve this answer




















    • Awesome, thanks!
      – Pasi Matalamäki
      Aug 30 at 9:03














    up vote
    2
    down vote













    If you're looking for a "one-liner", let $T$ be the target bearing and $C$ be the current bearing:



    $$beginaligndelta&=(T-C+540°)bmod360°-180°endalign$$



    The shortest rotation distance in degrees is given by $delta$. Positive values indicate clockwise rotation, negative values indicate counterclockwise rotation.



    $180°$ turns are always expressed as counterclockwise $-180°$.






    share|cite|improve this answer




















    • Awesome, thanks!
      – Pasi Matalamäki
      Aug 30 at 9:03












    up vote
    2
    down vote










    up vote
    2
    down vote









    If you're looking for a "one-liner", let $T$ be the target bearing and $C$ be the current bearing:



    $$beginaligndelta&=(T-C+540°)bmod360°-180°endalign$$



    The shortest rotation distance in degrees is given by $delta$. Positive values indicate clockwise rotation, negative values indicate counterclockwise rotation.



    $180°$ turns are always expressed as counterclockwise $-180°$.






    share|cite|improve this answer












    If you're looking for a "one-liner", let $T$ be the target bearing and $C$ be the current bearing:



    $$beginaligndelta&=(T-C+540°)bmod360°-180°endalign$$



    The shortest rotation distance in degrees is given by $delta$. Positive values indicate clockwise rotation, negative values indicate counterclockwise rotation.



    $180°$ turns are always expressed as counterclockwise $-180°$.







    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered Aug 29 at 8:48









    Unsigned

    1213




    1213











    • Awesome, thanks!
      – Pasi Matalamäki
      Aug 30 at 9:03
















    • Awesome, thanks!
      – Pasi Matalamäki
      Aug 30 at 9:03















    Awesome, thanks!
    – Pasi Matalamäki
    Aug 30 at 9:03




    Awesome, thanks!
    – Pasi Matalamäki
    Aug 30 at 9:03










    up vote
    0
    down vote













    Say you're going at bearing $a$ and your target bearing is $b$. I'll assume that both $a$ and $b$ are between zero (inclusive) and 360 (exclusive), and I'll also assume that the direction of increasing bearing is counterclockwise (that's the usual convention in higher math, and I think it's the one you are using). Here are the cases:



    If $alt b$, and $b-ale180$, turn counterclockwise.



    If $alt b$, and $b-agt180$, turn clockwise.



    If $agt b$, and $a-ble180$, turn clockwise.



    If $agt b$, and $a-bgt180$, turn counterclockwise.






    share|cite|improve this answer
























      up vote
      0
      down vote













      Say you're going at bearing $a$ and your target bearing is $b$. I'll assume that both $a$ and $b$ are between zero (inclusive) and 360 (exclusive), and I'll also assume that the direction of increasing bearing is counterclockwise (that's the usual convention in higher math, and I think it's the one you are using). Here are the cases:



      If $alt b$, and $b-ale180$, turn counterclockwise.



      If $alt b$, and $b-agt180$, turn clockwise.



      If $agt b$, and $a-ble180$, turn clockwise.



      If $agt b$, and $a-bgt180$, turn counterclockwise.






      share|cite|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Say you're going at bearing $a$ and your target bearing is $b$. I'll assume that both $a$ and $b$ are between zero (inclusive) and 360 (exclusive), and I'll also assume that the direction of increasing bearing is counterclockwise (that's the usual convention in higher math, and I think it's the one you are using). Here are the cases:



        If $alt b$, and $b-ale180$, turn counterclockwise.



        If $alt b$, and $b-agt180$, turn clockwise.



        If $agt b$, and $a-ble180$, turn clockwise.



        If $agt b$, and $a-bgt180$, turn counterclockwise.






        share|cite|improve this answer












        Say you're going at bearing $a$ and your target bearing is $b$. I'll assume that both $a$ and $b$ are between zero (inclusive) and 360 (exclusive), and I'll also assume that the direction of increasing bearing is counterclockwise (that's the usual convention in higher math, and I think it's the one you are using). Here are the cases:



        If $alt b$, and $b-ale180$, turn counterclockwise.



        If $alt b$, and $b-agt180$, turn clockwise.



        If $agt b$, and $a-ble180$, turn clockwise.



        If $agt b$, and $a-bgt180$, turn counterclockwise.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Feb 17 '12 at 3:30









        Gerry Myerson

        144k8145295




        144k8145295



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f110080%2fshortest-way-to-achieve-target-angle%23new-answer', 'question_page');

            );

            Post as a guest













































































            這個網誌中的熱門文章

            How to combine Bézier curves to a surface?

            Mutual Information Always Non-negative

            Why am i infinitely getting the same tweet with the Twitter Search API?