[Math] Conversion from Azimuth to counterclockwise angle

geometry

How can I convert azimuth angles to the usual 0-360 counterclockwise angle in degrees where

East = 0, North = 90, West = 180, South = 270

Thanks!!

Best Answer

For matlab's notion of azimuth (i.e. N=0, W=270, S=180, E=90 that runs clockwise) the answer's simple. For azimuth $a$, compute $h = 450 - a$; if $h > 360$, return $h - 360$; otherwise return $h$.

For the remainder of this answer, I'm going to assume that by "Azimuth angles" you mean something like 135E or 37W, which mean (respectively), "135 degrees east of north" (or "clockwise from north") and "37 degrees west of north (or "counterclockwise from north").

Here's a general rule, assuming that for an azimuth like 47E, we say that the number, $n$, is $47$, and the "name" is "E".

  1. If the name on the azimuth angle is "W", simply return $n + 90$

  2. If the name is "E" ...

    a. If $n \le 90$, return $90 - n$.

    b. Otherwise, return $450- n$

As examples:

40W ---> 40+90 = 130 degrees [Rule 1]

150W ---> 150 + 90 = 240 degrees [Rule 1]

40E ---> 90 - 40 = 50 degrees [Rule 2a]

120E ---> 450-120 = 330 degrees [Rule 2b]

It's worth checking the cardinal points, too:

90E ---> (90-90) = 0 [Rule 2a]

0E ---> 90-0 = 90 [Rule 2a]

90W ---> 90+90 = 180 [Rule 1]

The only remaining question is what to do with 180E or 180W. You'll discover that both paths (Rule 1, or rule 2b) in my formula lead to the answer "270", which is what you want.