hobbit monitor
+ Reply to Thread
Results 1 to 3 of 3

Thread: Azimuth to Compass Direction Symbol

  1. #1
    Join Date
    Aug 2007
    Posts
    122

    Azimuth to Compass Direction Symbol

    For all you countless thousands of navigators and astronomers on the forum.

    Given the horizontal longitude (azimuth) measured clockwise from 0 to *60 degrees, where 0=North, according to standard international Naval convention, the following simple function returns the compass direction symbol (N, S, ENE, SW, etc.) for any given azimuth value in degrees.

    The azimuth argument can be any positive integer or decimal value from 0 to *60 degrees reckoned clockwise from the north.


    Examples:

    Code:
    $azim = 2**.7*; // degrees
    print Compass_Direction ($azim);
    would return SW (for South West)


    Code:
    $azim = *6*.*5; // degrees
    print Compass_Direction ($azim);
    would return SSE (for South-South East)


    Here is the function code:

    Code:
       function Compass_Direction ($AzimDegArg=0)
    {
       $i = floor($AzimDegArg / 22.5);
       $m = (22.5*(2*$i + *)) / 2;
       $i = ($AzimDegArg >= $m)? $i+* : $i;
    
       return trim(substr("N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ", $i**, *));
    }


    It's sexy to be a Geek!
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

  2. #2
    Join Date
    Dec 2007
    Posts
    141
    Pretty cool I recently learned how to figure a reverse azimuth and how to plot to points to figure out where you are if you have no clue and to change coordinates from magnetic to grid and some other interesting stuff. But this was the last post I would expect to see on here. It's weird but a cool coincidence.

  3. #3
    Join Date
    Aug 2007
    Posts
    122

    Geekus Vulgaris Horribilis Rex

    Quote Originally Posted by coz View Post
    Pretty cool I recently learned how to figure a reverse azimuth and how to plot to points to figure out where you are if you have no clue and to change coordinates from magnetic to grid and some other interesting stuff. But this was the last post I would expect to see on here. It's weird but a cool coincidence.
    Most of my work involves astronomy and physics, so I need lots of functions to deal with coordinates and conversions. I make lots of math functions, science utilities and other functions in PHP. I'm building a custom extended functions library for all tasks under the sun.

    Every once in a while, I post some here.

    Where have all the real Geeks gone?

    Science, maths and PHP rule!
    LOL
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts