Created
January 18, 2016 18:39
-
-
Save iansvo/e09c29e80190a37334a1 to your computer and use it in GitHub Desktop.
Simple PHP function that turns directional degrees into cardinal directions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @param $int - degree integer value | |
function get_dir_from_deg($int) | |
{ | |
$calc = (int) ($int / 22.5 ) + .5; | |
$dirs = ["N","NNE","NE","ENE","E","ESE", "SE", "SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"]; | |
$index = $calc % 16; | |
return $dirs[$index]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment