How do I convert a line angle to a navigational-bearing scale (i.e., with range of [0,360] with “North” =...











up vote
1
down vote

favorite












I have two points, (x1,y1) and (x2,y2), that I'd like to draw a line between. I know I can figure out the angle of that line using Sin(th)=opp/Hyp:



theta = arcsin((y1-y2)/sqrt((y1-y2)^2 + (x1-x2)^2))) *180/pi



or by using arctangent and the slope:



theta = arctan((y2-y1)/(x2-x1)) * 180/pi



However, I want to convert that angle to be on the scale of [0,360].
Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg .



Thanks!!










share|cite|improve this question
























  • First - you forget to take square root of the lengths. Second - easier way would be to compute the slope of line and then use the relation $tan(alpha)=m$ where $alpha$ is the angle between line and positive side of x axis and $m$ is the slope. Third - take the result and calculate it modulo 360 - it will give you a result in the wanted scale.
    – Galc127
    Aug 5 '15 at 6:20










  • What do you mean by "compass scale": (1) where $0°$ is to the right and positive angles are counterclockwise from there [this is the trigonometric standard], (2) where $0°$ is up and positive angles are clockwise from there [this is the bearing standard], or (3) other?
    – Rory Daulton
    Aug 5 '15 at 11:53










  • A line can have two direction angles, separated by $180°$, so you could limit the result to $[0°,180°)$. Is that what you want?
    – Rory Daulton
    Aug 5 '15 at 12:01










  • @Rory Daulton: good point. I guess it actually doesn't really matter. I just want to differentiate 360 degrees of angle direction while comparing change vector directions in an NMDS ordination. Which would you suggest?
    – theforestecologist
    Aug 5 '15 at 13:58










  • @Galc127 I'm afraid I don't know what you mean by "calculate it modulo 360". Could you explain? Also, what is the best way to add the extra angle degrees necessary to extend my triangle's angle the whole way to the pos x axis?
    – theforestecologist
    Aug 5 '15 at 14:07















up vote
1
down vote

favorite












I have two points, (x1,y1) and (x2,y2), that I'd like to draw a line between. I know I can figure out the angle of that line using Sin(th)=opp/Hyp:



theta = arcsin((y1-y2)/sqrt((y1-y2)^2 + (x1-x2)^2))) *180/pi



or by using arctangent and the slope:



theta = arctan((y2-y1)/(x2-x1)) * 180/pi



However, I want to convert that angle to be on the scale of [0,360].
Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg .



Thanks!!










share|cite|improve this question
























  • First - you forget to take square root of the lengths. Second - easier way would be to compute the slope of line and then use the relation $tan(alpha)=m$ where $alpha$ is the angle between line and positive side of x axis and $m$ is the slope. Third - take the result and calculate it modulo 360 - it will give you a result in the wanted scale.
    – Galc127
    Aug 5 '15 at 6:20










  • What do you mean by "compass scale": (1) where $0°$ is to the right and positive angles are counterclockwise from there [this is the trigonometric standard], (2) where $0°$ is up and positive angles are clockwise from there [this is the bearing standard], or (3) other?
    – Rory Daulton
    Aug 5 '15 at 11:53










  • A line can have two direction angles, separated by $180°$, so you could limit the result to $[0°,180°)$. Is that what you want?
    – Rory Daulton
    Aug 5 '15 at 12:01










  • @Rory Daulton: good point. I guess it actually doesn't really matter. I just want to differentiate 360 degrees of angle direction while comparing change vector directions in an NMDS ordination. Which would you suggest?
    – theforestecologist
    Aug 5 '15 at 13:58










  • @Galc127 I'm afraid I don't know what you mean by "calculate it modulo 360". Could you explain? Also, what is the best way to add the extra angle degrees necessary to extend my triangle's angle the whole way to the pos x axis?
    – theforestecologist
    Aug 5 '15 at 14:07













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have two points, (x1,y1) and (x2,y2), that I'd like to draw a line between. I know I can figure out the angle of that line using Sin(th)=opp/Hyp:



theta = arcsin((y1-y2)/sqrt((y1-y2)^2 + (x1-x2)^2))) *180/pi



or by using arctangent and the slope:



theta = arctan((y2-y1)/(x2-x1)) * 180/pi



However, I want to convert that angle to be on the scale of [0,360].
Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg .



Thanks!!










share|cite|improve this question















I have two points, (x1,y1) and (x2,y2), that I'd like to draw a line between. I know I can figure out the angle of that line using Sin(th)=opp/Hyp:



theta = arcsin((y1-y2)/sqrt((y1-y2)^2 + (x1-x2)^2))) *180/pi



or by using arctangent and the slope:



theta = arctan((y2-y1)/(x2-x1)) * 180/pi



However, I want to convert that angle to be on the scale of [0,360].
Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg .



Thanks!!







algebra-precalculus geometry angle






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Aug 5 '15 at 17:19

























asked Aug 5 '15 at 6:11









theforestecologist

12829




12829












  • First - you forget to take square root of the lengths. Second - easier way would be to compute the slope of line and then use the relation $tan(alpha)=m$ where $alpha$ is the angle between line and positive side of x axis and $m$ is the slope. Third - take the result and calculate it modulo 360 - it will give you a result in the wanted scale.
    – Galc127
    Aug 5 '15 at 6:20










  • What do you mean by "compass scale": (1) where $0°$ is to the right and positive angles are counterclockwise from there [this is the trigonometric standard], (2) where $0°$ is up and positive angles are clockwise from there [this is the bearing standard], or (3) other?
    – Rory Daulton
    Aug 5 '15 at 11:53










  • A line can have two direction angles, separated by $180°$, so you could limit the result to $[0°,180°)$. Is that what you want?
    – Rory Daulton
    Aug 5 '15 at 12:01










  • @Rory Daulton: good point. I guess it actually doesn't really matter. I just want to differentiate 360 degrees of angle direction while comparing change vector directions in an NMDS ordination. Which would you suggest?
    – theforestecologist
    Aug 5 '15 at 13:58










  • @Galc127 I'm afraid I don't know what you mean by "calculate it modulo 360". Could you explain? Also, what is the best way to add the extra angle degrees necessary to extend my triangle's angle the whole way to the pos x axis?
    – theforestecologist
    Aug 5 '15 at 14:07


















  • First - you forget to take square root of the lengths. Second - easier way would be to compute the slope of line and then use the relation $tan(alpha)=m$ where $alpha$ is the angle between line and positive side of x axis and $m$ is the slope. Third - take the result and calculate it modulo 360 - it will give you a result in the wanted scale.
    – Galc127
    Aug 5 '15 at 6:20










  • What do you mean by "compass scale": (1) where $0°$ is to the right and positive angles are counterclockwise from there [this is the trigonometric standard], (2) where $0°$ is up and positive angles are clockwise from there [this is the bearing standard], or (3) other?
    – Rory Daulton
    Aug 5 '15 at 11:53










  • A line can have two direction angles, separated by $180°$, so you could limit the result to $[0°,180°)$. Is that what you want?
    – Rory Daulton
    Aug 5 '15 at 12:01










  • @Rory Daulton: good point. I guess it actually doesn't really matter. I just want to differentiate 360 degrees of angle direction while comparing change vector directions in an NMDS ordination. Which would you suggest?
    – theforestecologist
    Aug 5 '15 at 13:58










  • @Galc127 I'm afraid I don't know what you mean by "calculate it modulo 360". Could you explain? Also, what is the best way to add the extra angle degrees necessary to extend my triangle's angle the whole way to the pos x axis?
    – theforestecologist
    Aug 5 '15 at 14:07
















First - you forget to take square root of the lengths. Second - easier way would be to compute the slope of line and then use the relation $tan(alpha)=m$ where $alpha$ is the angle between line and positive side of x axis and $m$ is the slope. Third - take the result and calculate it modulo 360 - it will give you a result in the wanted scale.
– Galc127
Aug 5 '15 at 6:20




First - you forget to take square root of the lengths. Second - easier way would be to compute the slope of line and then use the relation $tan(alpha)=m$ where $alpha$ is the angle between line and positive side of x axis and $m$ is the slope. Third - take the result and calculate it modulo 360 - it will give you a result in the wanted scale.
– Galc127
Aug 5 '15 at 6:20












What do you mean by "compass scale": (1) where $0°$ is to the right and positive angles are counterclockwise from there [this is the trigonometric standard], (2) where $0°$ is up and positive angles are clockwise from there [this is the bearing standard], or (3) other?
– Rory Daulton
Aug 5 '15 at 11:53




What do you mean by "compass scale": (1) where $0°$ is to the right and positive angles are counterclockwise from there [this is the trigonometric standard], (2) where $0°$ is up and positive angles are clockwise from there [this is the bearing standard], or (3) other?
– Rory Daulton
Aug 5 '15 at 11:53












A line can have two direction angles, separated by $180°$, so you could limit the result to $[0°,180°)$. Is that what you want?
– Rory Daulton
Aug 5 '15 at 12:01




A line can have two direction angles, separated by $180°$, so you could limit the result to $[0°,180°)$. Is that what you want?
– Rory Daulton
Aug 5 '15 at 12:01












@Rory Daulton: good point. I guess it actually doesn't really matter. I just want to differentiate 360 degrees of angle direction while comparing change vector directions in an NMDS ordination. Which would you suggest?
– theforestecologist
Aug 5 '15 at 13:58




@Rory Daulton: good point. I guess it actually doesn't really matter. I just want to differentiate 360 degrees of angle direction while comparing change vector directions in an NMDS ordination. Which would you suggest?
– theforestecologist
Aug 5 '15 at 13:58












@Galc127 I'm afraid I don't know what you mean by "calculate it modulo 360". Could you explain? Also, what is the best way to add the extra angle degrees necessary to extend my triangle's angle the whole way to the pos x axis?
– theforestecologist
Aug 5 '15 at 14:07




@Galc127 I'm afraid I don't know what you mean by "calculate it modulo 360". Could you explain? Also, what is the best way to add the extra angle degrees necessary to extend my triangle's angle the whole way to the pos x axis?
– theforestecologist
Aug 5 '15 at 14:07










3 Answers
3






active

oldest

votes

















up vote
1
down vote













Here is a way to get a direction angle for your line, where $0le theta<180°$, $0°$ means straight up (due north), and $90°$ means to the right (due east). This is the standard for bearings in navigation. Let me know if you mean something else: your comments have not been clear.



$$theta = begin{cases}
90°-dfrac{180°}{pi}cdottan^{-1}left(dfrac{y_2-y_1}{x_2-x_1}right), & text{if }x_1ne x_2 \[2ex]
0°, & text{if }x_1=x_2
end{cases}
$$



Here's the explanation:




  • The internal fraction $dfrac{y_2-y_1}{x_2-x_1}$ is the slope of the line

  • The arctangent of that slope is the direction angle of the line, in standard trigonometric form (measured in radians, $0$ is to the right, positive angles are counterclockwise).

  • Multiplying that radians angle by $dfrac{180°}{pi}$ converts it to degrees.

  • Subtracting that degree angle from $90°$ changes the orientation to match that of bearings in navigation.

  • That calculation fails for a vertical line, since the $x$-coordinates are equal and the slope is undefined. My formula makes that a special case: vertical lines have bearing $0°$.


There is one problem with that formula: if your two given points are identical, there is no well-defined line through them so no well-defined angle, but my formula gives an answer of $0°$. A slight modification can easily take care of that special case.





You ask about the angle of the line determined by the points $(-0.019,0.406)$ and $(-0.287,-0.353)$. Here is the calculation from my formula:



Angle calculation in TI-Nspire CX calculator



And here is what the angle looks like on a graph:



Angle calculation in Geogebra graph



You see that the two agree. I hope the graph shows you more clearly exactly which angle my formula gives.



As for your different answers: I can't speak about your "nav bearings scale" since I don't know what that is. Check my graph to make sure we are talking about the same angle.



My formula gives values $0°<theta<90°$ for lines with positive slope and values $90°<theta<180°$ for lines with negative slope. However, the answer does depend on which point is point 1 and which is point 2. If you do want a formula that distinguishes between them, and also gives angles up to $360°$, here is an alternate formula that uses the atan2 function.



$$theta = 90°-dfrac{180°}{pi}cdotoperatorname{atan2}left(x_2-x_1,y_2-y_1right)$$



This gives an undefined value if the two points are identical. Is this what you want? (Be careful, some systems that have the atan2 function swap the $x$ and $y$ parameters.)






share|cite|improve this answer























  • Great! My initial confusion was simply due to having typed numbers in incorrectly!
    – theforestecologist
    Aug 5 '15 at 16:10










  • Ok so now I have a secondary question. I have two points: (-0.019,0.406) and (-0.287,-0.353) that appear to have an angle ~= 205 on my nav. bearings scale. However your equation gives me an angle of ~19.5. Can you help me figure out what's going on here? My equation matches yours: 90 - arctan((y2-y1)/(x2-x1))*180/pi
    – theforestecologist
    Aug 5 '15 at 16:45












  • I guess the issue lays in the fact that the position of all of the negative values creates essentially a positive slope. How do I get around this problem (which should arise, for example, whenever point1 is in quad 2 and point 2 is in quad 3)? ....or, now lookign at it further, I guess your solution only splits my scale into repeating 180 deg segments??
    – theforestecologist
    Aug 5 '15 at 17:05


















up vote
0
down vote













Multiply your formula result with $180/pi$ to obtain counterclockwise angle with respect to East-West Line, following the sign convention for direction of vector placement in all four quadrants.






share|cite|improve this answer





















  • that doesn;t seem to work. Am I doing it wrong? For example if I have an angle of -45 degrees in the bottom right quadrant, multiplying by 180/pi gives me -2578.
    – theforestecologist
    Aug 5 '15 at 14:55










  • You got -45 only after multiplying by $ 180/pi ! $
    – Narasimham
    Aug 5 '15 at 15:02










  • Oh I see. So you're just talking about converting radians to degrees. My question, though, is how would I make a -45 degree angle in the bottom left quadrant, for example, to equal 135 degrees? (or 225 degrees -- whichever is easier).
    – theforestecologist
    Aug 5 '15 at 15:16






  • 1




    All the four quadrants are equally needed and are equally legitimate. They need not be shifted away anywhere else after determining their quadrant location.. let them stay where they should be. A rule for each of 4 quadrants trig functions sign is AllSilverTeaCups ( all, sine tan, cos) so they are positive. I suppose the thick magnetic index pointer part can be rotated into all the 4 quadrants of a direction finder compass with equal ease.
    – Narasimham
    Aug 5 '15 at 15:48




















up vote
0
down vote













First time posting, so apologies in advance for newbie-ness.

Another example may be the following (assuming unit circle):

When the angle is from 0 to pi/2 (or 90 degrees), use: 90 - (angle * 180/pi)
When the angle is from pi/2 (90 degrees) to 2pi (or 360 degrees), use: 450 - (angle * 180/pi)

Examples:
Angle of 0: 90 - (0pi * 180/pi) = bearing of 90
Angle of pi/4 (45 degrees): 90 - (pi/4 * 180/pi) = bearing of 45
Angle of pi/2 (90 degrees): 90 - (pi/2 * 180/pi) = bearing of 0
Angle of 3pi/4 (135 degrees): 450 - (3pi/4 * 180/pi) = bearing of 315
Angle of pi (180 degrees): 450 - (pi * 180/pi) = bearing of 270
Angle of 7pi/4 (315 degrees): 450 - (7pi/4 * 180/pi) = bearing of 135





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: 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%2f1385006%2fhow-do-i-convert-a-line-angle-to-a-navigational-bearing-scale-i-e-with-range%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Here is a way to get a direction angle for your line, where $0le theta<180°$, $0°$ means straight up (due north), and $90°$ means to the right (due east). This is the standard for bearings in navigation. Let me know if you mean something else: your comments have not been clear.



    $$theta = begin{cases}
    90°-dfrac{180°}{pi}cdottan^{-1}left(dfrac{y_2-y_1}{x_2-x_1}right), & text{if }x_1ne x_2 \[2ex]
    0°, & text{if }x_1=x_2
    end{cases}
    $$



    Here's the explanation:




    • The internal fraction $dfrac{y_2-y_1}{x_2-x_1}$ is the slope of the line

    • The arctangent of that slope is the direction angle of the line, in standard trigonometric form (measured in radians, $0$ is to the right, positive angles are counterclockwise).

    • Multiplying that radians angle by $dfrac{180°}{pi}$ converts it to degrees.

    • Subtracting that degree angle from $90°$ changes the orientation to match that of bearings in navigation.

    • That calculation fails for a vertical line, since the $x$-coordinates are equal and the slope is undefined. My formula makes that a special case: vertical lines have bearing $0°$.


    There is one problem with that formula: if your two given points are identical, there is no well-defined line through them so no well-defined angle, but my formula gives an answer of $0°$. A slight modification can easily take care of that special case.





    You ask about the angle of the line determined by the points $(-0.019,0.406)$ and $(-0.287,-0.353)$. Here is the calculation from my formula:



    Angle calculation in TI-Nspire CX calculator



    And here is what the angle looks like on a graph:



    Angle calculation in Geogebra graph



    You see that the two agree. I hope the graph shows you more clearly exactly which angle my formula gives.



    As for your different answers: I can't speak about your "nav bearings scale" since I don't know what that is. Check my graph to make sure we are talking about the same angle.



    My formula gives values $0°<theta<90°$ for lines with positive slope and values $90°<theta<180°$ for lines with negative slope. However, the answer does depend on which point is point 1 and which is point 2. If you do want a formula that distinguishes between them, and also gives angles up to $360°$, here is an alternate formula that uses the atan2 function.



    $$theta = 90°-dfrac{180°}{pi}cdotoperatorname{atan2}left(x_2-x_1,y_2-y_1right)$$



    This gives an undefined value if the two points are identical. Is this what you want? (Be careful, some systems that have the atan2 function swap the $x$ and $y$ parameters.)






    share|cite|improve this answer























    • Great! My initial confusion was simply due to having typed numbers in incorrectly!
      – theforestecologist
      Aug 5 '15 at 16:10










    • Ok so now I have a secondary question. I have two points: (-0.019,0.406) and (-0.287,-0.353) that appear to have an angle ~= 205 on my nav. bearings scale. However your equation gives me an angle of ~19.5. Can you help me figure out what's going on here? My equation matches yours: 90 - arctan((y2-y1)/(x2-x1))*180/pi
      – theforestecologist
      Aug 5 '15 at 16:45












    • I guess the issue lays in the fact that the position of all of the negative values creates essentially a positive slope. How do I get around this problem (which should arise, for example, whenever point1 is in quad 2 and point 2 is in quad 3)? ....or, now lookign at it further, I guess your solution only splits my scale into repeating 180 deg segments??
      – theforestecologist
      Aug 5 '15 at 17:05















    up vote
    1
    down vote













    Here is a way to get a direction angle for your line, where $0le theta<180°$, $0°$ means straight up (due north), and $90°$ means to the right (due east). This is the standard for bearings in navigation. Let me know if you mean something else: your comments have not been clear.



    $$theta = begin{cases}
    90°-dfrac{180°}{pi}cdottan^{-1}left(dfrac{y_2-y_1}{x_2-x_1}right), & text{if }x_1ne x_2 \[2ex]
    0°, & text{if }x_1=x_2
    end{cases}
    $$



    Here's the explanation:




    • The internal fraction $dfrac{y_2-y_1}{x_2-x_1}$ is the slope of the line

    • The arctangent of that slope is the direction angle of the line, in standard trigonometric form (measured in radians, $0$ is to the right, positive angles are counterclockwise).

    • Multiplying that radians angle by $dfrac{180°}{pi}$ converts it to degrees.

    • Subtracting that degree angle from $90°$ changes the orientation to match that of bearings in navigation.

    • That calculation fails for a vertical line, since the $x$-coordinates are equal and the slope is undefined. My formula makes that a special case: vertical lines have bearing $0°$.


    There is one problem with that formula: if your two given points are identical, there is no well-defined line through them so no well-defined angle, but my formula gives an answer of $0°$. A slight modification can easily take care of that special case.





    You ask about the angle of the line determined by the points $(-0.019,0.406)$ and $(-0.287,-0.353)$. Here is the calculation from my formula:



    Angle calculation in TI-Nspire CX calculator



    And here is what the angle looks like on a graph:



    Angle calculation in Geogebra graph



    You see that the two agree. I hope the graph shows you more clearly exactly which angle my formula gives.



    As for your different answers: I can't speak about your "nav bearings scale" since I don't know what that is. Check my graph to make sure we are talking about the same angle.



    My formula gives values $0°<theta<90°$ for lines with positive slope and values $90°<theta<180°$ for lines with negative slope. However, the answer does depend on which point is point 1 and which is point 2. If you do want a formula that distinguishes between them, and also gives angles up to $360°$, here is an alternate formula that uses the atan2 function.



    $$theta = 90°-dfrac{180°}{pi}cdotoperatorname{atan2}left(x_2-x_1,y_2-y_1right)$$



    This gives an undefined value if the two points are identical. Is this what you want? (Be careful, some systems that have the atan2 function swap the $x$ and $y$ parameters.)






    share|cite|improve this answer























    • Great! My initial confusion was simply due to having typed numbers in incorrectly!
      – theforestecologist
      Aug 5 '15 at 16:10










    • Ok so now I have a secondary question. I have two points: (-0.019,0.406) and (-0.287,-0.353) that appear to have an angle ~= 205 on my nav. bearings scale. However your equation gives me an angle of ~19.5. Can you help me figure out what's going on here? My equation matches yours: 90 - arctan((y2-y1)/(x2-x1))*180/pi
      – theforestecologist
      Aug 5 '15 at 16:45












    • I guess the issue lays in the fact that the position of all of the negative values creates essentially a positive slope. How do I get around this problem (which should arise, for example, whenever point1 is in quad 2 and point 2 is in quad 3)? ....or, now lookign at it further, I guess your solution only splits my scale into repeating 180 deg segments??
      – theforestecologist
      Aug 5 '15 at 17:05













    up vote
    1
    down vote










    up vote
    1
    down vote









    Here is a way to get a direction angle for your line, where $0le theta<180°$, $0°$ means straight up (due north), and $90°$ means to the right (due east). This is the standard for bearings in navigation. Let me know if you mean something else: your comments have not been clear.



    $$theta = begin{cases}
    90°-dfrac{180°}{pi}cdottan^{-1}left(dfrac{y_2-y_1}{x_2-x_1}right), & text{if }x_1ne x_2 \[2ex]
    0°, & text{if }x_1=x_2
    end{cases}
    $$



    Here's the explanation:




    • The internal fraction $dfrac{y_2-y_1}{x_2-x_1}$ is the slope of the line

    • The arctangent of that slope is the direction angle of the line, in standard trigonometric form (measured in radians, $0$ is to the right, positive angles are counterclockwise).

    • Multiplying that radians angle by $dfrac{180°}{pi}$ converts it to degrees.

    • Subtracting that degree angle from $90°$ changes the orientation to match that of bearings in navigation.

    • That calculation fails for a vertical line, since the $x$-coordinates are equal and the slope is undefined. My formula makes that a special case: vertical lines have bearing $0°$.


    There is one problem with that formula: if your two given points are identical, there is no well-defined line through them so no well-defined angle, but my formula gives an answer of $0°$. A slight modification can easily take care of that special case.





    You ask about the angle of the line determined by the points $(-0.019,0.406)$ and $(-0.287,-0.353)$. Here is the calculation from my formula:



    Angle calculation in TI-Nspire CX calculator



    And here is what the angle looks like on a graph:



    Angle calculation in Geogebra graph



    You see that the two agree. I hope the graph shows you more clearly exactly which angle my formula gives.



    As for your different answers: I can't speak about your "nav bearings scale" since I don't know what that is. Check my graph to make sure we are talking about the same angle.



    My formula gives values $0°<theta<90°$ for lines with positive slope and values $90°<theta<180°$ for lines with negative slope. However, the answer does depend on which point is point 1 and which is point 2. If you do want a formula that distinguishes between them, and also gives angles up to $360°$, here is an alternate formula that uses the atan2 function.



    $$theta = 90°-dfrac{180°}{pi}cdotoperatorname{atan2}left(x_2-x_1,y_2-y_1right)$$



    This gives an undefined value if the two points are identical. Is this what you want? (Be careful, some systems that have the atan2 function swap the $x$ and $y$ parameters.)






    share|cite|improve this answer














    Here is a way to get a direction angle for your line, where $0le theta<180°$, $0°$ means straight up (due north), and $90°$ means to the right (due east). This is the standard for bearings in navigation. Let me know if you mean something else: your comments have not been clear.



    $$theta = begin{cases}
    90°-dfrac{180°}{pi}cdottan^{-1}left(dfrac{y_2-y_1}{x_2-x_1}right), & text{if }x_1ne x_2 \[2ex]
    0°, & text{if }x_1=x_2
    end{cases}
    $$



    Here's the explanation:




    • The internal fraction $dfrac{y_2-y_1}{x_2-x_1}$ is the slope of the line

    • The arctangent of that slope is the direction angle of the line, in standard trigonometric form (measured in radians, $0$ is to the right, positive angles are counterclockwise).

    • Multiplying that radians angle by $dfrac{180°}{pi}$ converts it to degrees.

    • Subtracting that degree angle from $90°$ changes the orientation to match that of bearings in navigation.

    • That calculation fails for a vertical line, since the $x$-coordinates are equal and the slope is undefined. My formula makes that a special case: vertical lines have bearing $0°$.


    There is one problem with that formula: if your two given points are identical, there is no well-defined line through them so no well-defined angle, but my formula gives an answer of $0°$. A slight modification can easily take care of that special case.





    You ask about the angle of the line determined by the points $(-0.019,0.406)$ and $(-0.287,-0.353)$. Here is the calculation from my formula:



    Angle calculation in TI-Nspire CX calculator



    And here is what the angle looks like on a graph:



    Angle calculation in Geogebra graph



    You see that the two agree. I hope the graph shows you more clearly exactly which angle my formula gives.



    As for your different answers: I can't speak about your "nav bearings scale" since I don't know what that is. Check my graph to make sure we are talking about the same angle.



    My formula gives values $0°<theta<90°$ for lines with positive slope and values $90°<theta<180°$ for lines with negative slope. However, the answer does depend on which point is point 1 and which is point 2. If you do want a formula that distinguishes between them, and also gives angles up to $360°$, here is an alternate formula that uses the atan2 function.



    $$theta = 90°-dfrac{180°}{pi}cdotoperatorname{atan2}left(x_2-x_1,y_2-y_1right)$$



    This gives an undefined value if the two points are identical. Is this what you want? (Be careful, some systems that have the atan2 function swap the $x$ and $y$ parameters.)







    share|cite|improve this answer














    share|cite|improve this answer



    share|cite|improve this answer








    edited Aug 5 '15 at 17:37

























    answered Aug 5 '15 at 15:44









    Rory Daulton

    29.2k53254




    29.2k53254












    • Great! My initial confusion was simply due to having typed numbers in incorrectly!
      – theforestecologist
      Aug 5 '15 at 16:10










    • Ok so now I have a secondary question. I have two points: (-0.019,0.406) and (-0.287,-0.353) that appear to have an angle ~= 205 on my nav. bearings scale. However your equation gives me an angle of ~19.5. Can you help me figure out what's going on here? My equation matches yours: 90 - arctan((y2-y1)/(x2-x1))*180/pi
      – theforestecologist
      Aug 5 '15 at 16:45












    • I guess the issue lays in the fact that the position of all of the negative values creates essentially a positive slope. How do I get around this problem (which should arise, for example, whenever point1 is in quad 2 and point 2 is in quad 3)? ....or, now lookign at it further, I guess your solution only splits my scale into repeating 180 deg segments??
      – theforestecologist
      Aug 5 '15 at 17:05


















    • Great! My initial confusion was simply due to having typed numbers in incorrectly!
      – theforestecologist
      Aug 5 '15 at 16:10










    • Ok so now I have a secondary question. I have two points: (-0.019,0.406) and (-0.287,-0.353) that appear to have an angle ~= 205 on my nav. bearings scale. However your equation gives me an angle of ~19.5. Can you help me figure out what's going on here? My equation matches yours: 90 - arctan((y2-y1)/(x2-x1))*180/pi
      – theforestecologist
      Aug 5 '15 at 16:45












    • I guess the issue lays in the fact that the position of all of the negative values creates essentially a positive slope. How do I get around this problem (which should arise, for example, whenever point1 is in quad 2 and point 2 is in quad 3)? ....or, now lookign at it further, I guess your solution only splits my scale into repeating 180 deg segments??
      – theforestecologist
      Aug 5 '15 at 17:05
















    Great! My initial confusion was simply due to having typed numbers in incorrectly!
    – theforestecologist
    Aug 5 '15 at 16:10




    Great! My initial confusion was simply due to having typed numbers in incorrectly!
    – theforestecologist
    Aug 5 '15 at 16:10












    Ok so now I have a secondary question. I have two points: (-0.019,0.406) and (-0.287,-0.353) that appear to have an angle ~= 205 on my nav. bearings scale. However your equation gives me an angle of ~19.5. Can you help me figure out what's going on here? My equation matches yours: 90 - arctan((y2-y1)/(x2-x1))*180/pi
    – theforestecologist
    Aug 5 '15 at 16:45






    Ok so now I have a secondary question. I have two points: (-0.019,0.406) and (-0.287,-0.353) that appear to have an angle ~= 205 on my nav. bearings scale. However your equation gives me an angle of ~19.5. Can you help me figure out what's going on here? My equation matches yours: 90 - arctan((y2-y1)/(x2-x1))*180/pi
    – theforestecologist
    Aug 5 '15 at 16:45














    I guess the issue lays in the fact that the position of all of the negative values creates essentially a positive slope. How do I get around this problem (which should arise, for example, whenever point1 is in quad 2 and point 2 is in quad 3)? ....or, now lookign at it further, I guess your solution only splits my scale into repeating 180 deg segments??
    – theforestecologist
    Aug 5 '15 at 17:05




    I guess the issue lays in the fact that the position of all of the negative values creates essentially a positive slope. How do I get around this problem (which should arise, for example, whenever point1 is in quad 2 and point 2 is in quad 3)? ....or, now lookign at it further, I guess your solution only splits my scale into repeating 180 deg segments??
    – theforestecologist
    Aug 5 '15 at 17:05










    up vote
    0
    down vote













    Multiply your formula result with $180/pi$ to obtain counterclockwise angle with respect to East-West Line, following the sign convention for direction of vector placement in all four quadrants.






    share|cite|improve this answer





















    • that doesn;t seem to work. Am I doing it wrong? For example if I have an angle of -45 degrees in the bottom right quadrant, multiplying by 180/pi gives me -2578.
      – theforestecologist
      Aug 5 '15 at 14:55










    • You got -45 only after multiplying by $ 180/pi ! $
      – Narasimham
      Aug 5 '15 at 15:02










    • Oh I see. So you're just talking about converting radians to degrees. My question, though, is how would I make a -45 degree angle in the bottom left quadrant, for example, to equal 135 degrees? (or 225 degrees -- whichever is easier).
      – theforestecologist
      Aug 5 '15 at 15:16






    • 1




      All the four quadrants are equally needed and are equally legitimate. They need not be shifted away anywhere else after determining their quadrant location.. let them stay where they should be. A rule for each of 4 quadrants trig functions sign is AllSilverTeaCups ( all, sine tan, cos) so they are positive. I suppose the thick magnetic index pointer part can be rotated into all the 4 quadrants of a direction finder compass with equal ease.
      – Narasimham
      Aug 5 '15 at 15:48

















    up vote
    0
    down vote













    Multiply your formula result with $180/pi$ to obtain counterclockwise angle with respect to East-West Line, following the sign convention for direction of vector placement in all four quadrants.






    share|cite|improve this answer





















    • that doesn;t seem to work. Am I doing it wrong? For example if I have an angle of -45 degrees in the bottom right quadrant, multiplying by 180/pi gives me -2578.
      – theforestecologist
      Aug 5 '15 at 14:55










    • You got -45 only after multiplying by $ 180/pi ! $
      – Narasimham
      Aug 5 '15 at 15:02










    • Oh I see. So you're just talking about converting radians to degrees. My question, though, is how would I make a -45 degree angle in the bottom left quadrant, for example, to equal 135 degrees? (or 225 degrees -- whichever is easier).
      – theforestecologist
      Aug 5 '15 at 15:16






    • 1




      All the four quadrants are equally needed and are equally legitimate. They need not be shifted away anywhere else after determining their quadrant location.. let them stay where they should be. A rule for each of 4 quadrants trig functions sign is AllSilverTeaCups ( all, sine tan, cos) so they are positive. I suppose the thick magnetic index pointer part can be rotated into all the 4 quadrants of a direction finder compass with equal ease.
      – Narasimham
      Aug 5 '15 at 15:48















    up vote
    0
    down vote










    up vote
    0
    down vote









    Multiply your formula result with $180/pi$ to obtain counterclockwise angle with respect to East-West Line, following the sign convention for direction of vector placement in all four quadrants.






    share|cite|improve this answer












    Multiply your formula result with $180/pi$ to obtain counterclockwise angle with respect to East-West Line, following the sign convention for direction of vector placement in all four quadrants.







    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered Aug 5 '15 at 14:50









    Narasimham

    20.5k52158




    20.5k52158












    • that doesn;t seem to work. Am I doing it wrong? For example if I have an angle of -45 degrees in the bottom right quadrant, multiplying by 180/pi gives me -2578.
      – theforestecologist
      Aug 5 '15 at 14:55










    • You got -45 only after multiplying by $ 180/pi ! $
      – Narasimham
      Aug 5 '15 at 15:02










    • Oh I see. So you're just talking about converting radians to degrees. My question, though, is how would I make a -45 degree angle in the bottom left quadrant, for example, to equal 135 degrees? (or 225 degrees -- whichever is easier).
      – theforestecologist
      Aug 5 '15 at 15:16






    • 1




      All the four quadrants are equally needed and are equally legitimate. They need not be shifted away anywhere else after determining their quadrant location.. let them stay where they should be. A rule for each of 4 quadrants trig functions sign is AllSilverTeaCups ( all, sine tan, cos) so they are positive. I suppose the thick magnetic index pointer part can be rotated into all the 4 quadrants of a direction finder compass with equal ease.
      – Narasimham
      Aug 5 '15 at 15:48




















    • that doesn;t seem to work. Am I doing it wrong? For example if I have an angle of -45 degrees in the bottom right quadrant, multiplying by 180/pi gives me -2578.
      – theforestecologist
      Aug 5 '15 at 14:55










    • You got -45 only after multiplying by $ 180/pi ! $
      – Narasimham
      Aug 5 '15 at 15:02










    • Oh I see. So you're just talking about converting radians to degrees. My question, though, is how would I make a -45 degree angle in the bottom left quadrant, for example, to equal 135 degrees? (or 225 degrees -- whichever is easier).
      – theforestecologist
      Aug 5 '15 at 15:16






    • 1




      All the four quadrants are equally needed and are equally legitimate. They need not be shifted away anywhere else after determining their quadrant location.. let them stay where they should be. A rule for each of 4 quadrants trig functions sign is AllSilverTeaCups ( all, sine tan, cos) so they are positive. I suppose the thick magnetic index pointer part can be rotated into all the 4 quadrants of a direction finder compass with equal ease.
      – Narasimham
      Aug 5 '15 at 15:48


















    that doesn;t seem to work. Am I doing it wrong? For example if I have an angle of -45 degrees in the bottom right quadrant, multiplying by 180/pi gives me -2578.
    – theforestecologist
    Aug 5 '15 at 14:55




    that doesn;t seem to work. Am I doing it wrong? For example if I have an angle of -45 degrees in the bottom right quadrant, multiplying by 180/pi gives me -2578.
    – theforestecologist
    Aug 5 '15 at 14:55












    You got -45 only after multiplying by $ 180/pi ! $
    – Narasimham
    Aug 5 '15 at 15:02




    You got -45 only after multiplying by $ 180/pi ! $
    – Narasimham
    Aug 5 '15 at 15:02












    Oh I see. So you're just talking about converting radians to degrees. My question, though, is how would I make a -45 degree angle in the bottom left quadrant, for example, to equal 135 degrees? (or 225 degrees -- whichever is easier).
    – theforestecologist
    Aug 5 '15 at 15:16




    Oh I see. So you're just talking about converting radians to degrees. My question, though, is how would I make a -45 degree angle in the bottom left quadrant, for example, to equal 135 degrees? (or 225 degrees -- whichever is easier).
    – theforestecologist
    Aug 5 '15 at 15:16




    1




    1




    All the four quadrants are equally needed and are equally legitimate. They need not be shifted away anywhere else after determining their quadrant location.. let them stay where they should be. A rule for each of 4 quadrants trig functions sign is AllSilverTeaCups ( all, sine tan, cos) so they are positive. I suppose the thick magnetic index pointer part can be rotated into all the 4 quadrants of a direction finder compass with equal ease.
    – Narasimham
    Aug 5 '15 at 15:48






    All the four quadrants are equally needed and are equally legitimate. They need not be shifted away anywhere else after determining their quadrant location.. let them stay where they should be. A rule for each of 4 quadrants trig functions sign is AllSilverTeaCups ( all, sine tan, cos) so they are positive. I suppose the thick magnetic index pointer part can be rotated into all the 4 quadrants of a direction finder compass with equal ease.
    – Narasimham
    Aug 5 '15 at 15:48












    up vote
    0
    down vote













    First time posting, so apologies in advance for newbie-ness.

    Another example may be the following (assuming unit circle):

    When the angle is from 0 to pi/2 (or 90 degrees), use: 90 - (angle * 180/pi)
    When the angle is from pi/2 (90 degrees) to 2pi (or 360 degrees), use: 450 - (angle * 180/pi)

    Examples:
    Angle of 0: 90 - (0pi * 180/pi) = bearing of 90
    Angle of pi/4 (45 degrees): 90 - (pi/4 * 180/pi) = bearing of 45
    Angle of pi/2 (90 degrees): 90 - (pi/2 * 180/pi) = bearing of 0
    Angle of 3pi/4 (135 degrees): 450 - (3pi/4 * 180/pi) = bearing of 315
    Angle of pi (180 degrees): 450 - (pi * 180/pi) = bearing of 270
    Angle of 7pi/4 (315 degrees): 450 - (7pi/4 * 180/pi) = bearing of 135





    share|cite|improve this answer

























      up vote
      0
      down vote













      First time posting, so apologies in advance for newbie-ness.

      Another example may be the following (assuming unit circle):

      When the angle is from 0 to pi/2 (or 90 degrees), use: 90 - (angle * 180/pi)
      When the angle is from pi/2 (90 degrees) to 2pi (or 360 degrees), use: 450 - (angle * 180/pi)

      Examples:
      Angle of 0: 90 - (0pi * 180/pi) = bearing of 90
      Angle of pi/4 (45 degrees): 90 - (pi/4 * 180/pi) = bearing of 45
      Angle of pi/2 (90 degrees): 90 - (pi/2 * 180/pi) = bearing of 0
      Angle of 3pi/4 (135 degrees): 450 - (3pi/4 * 180/pi) = bearing of 315
      Angle of pi (180 degrees): 450 - (pi * 180/pi) = bearing of 270
      Angle of 7pi/4 (315 degrees): 450 - (7pi/4 * 180/pi) = bearing of 135





      share|cite|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        First time posting, so apologies in advance for newbie-ness.

        Another example may be the following (assuming unit circle):

        When the angle is from 0 to pi/2 (or 90 degrees), use: 90 - (angle * 180/pi)
        When the angle is from pi/2 (90 degrees) to 2pi (or 360 degrees), use: 450 - (angle * 180/pi)

        Examples:
        Angle of 0: 90 - (0pi * 180/pi) = bearing of 90
        Angle of pi/4 (45 degrees): 90 - (pi/4 * 180/pi) = bearing of 45
        Angle of pi/2 (90 degrees): 90 - (pi/2 * 180/pi) = bearing of 0
        Angle of 3pi/4 (135 degrees): 450 - (3pi/4 * 180/pi) = bearing of 315
        Angle of pi (180 degrees): 450 - (pi * 180/pi) = bearing of 270
        Angle of 7pi/4 (315 degrees): 450 - (7pi/4 * 180/pi) = bearing of 135





        share|cite|improve this answer












        First time posting, so apologies in advance for newbie-ness.

        Another example may be the following (assuming unit circle):

        When the angle is from 0 to pi/2 (or 90 degrees), use: 90 - (angle * 180/pi)
        When the angle is from pi/2 (90 degrees) to 2pi (or 360 degrees), use: 450 - (angle * 180/pi)

        Examples:
        Angle of 0: 90 - (0pi * 180/pi) = bearing of 90
        Angle of pi/4 (45 degrees): 90 - (pi/4 * 180/pi) = bearing of 45
        Angle of pi/2 (90 degrees): 90 - (pi/2 * 180/pi) = bearing of 0
        Angle of 3pi/4 (135 degrees): 450 - (3pi/4 * 180/pi) = bearing of 315
        Angle of pi (180 degrees): 450 - (pi * 180/pi) = bearing of 270
        Angle of 7pi/4 (315 degrees): 450 - (7pi/4 * 180/pi) = bearing of 135






        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Mar 15 '17 at 15:30









        John Pylate

        1




        1






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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.


            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%2f1385006%2fhow-do-i-convert-a-line-angle-to-a-navigational-bearing-scale-i-e-with-range%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

            Ellipse (mathématiques)

            Quarter-circle Tiles

            Mont Emei