Skip to content

Instantly share code, notes, and snippets.

@ajzeigert
Last active March 3, 2016 17:29
Show Gist options
  • Save ajzeigert/d01db17e8821190d5840 to your computer and use it in GitHub Desktop.
Save ajzeigert/d01db17e8821190d5840 to your computer and use it in GitHub Desktop.
Function that converts degrees to cardinal and intercardinal directions
// I used this for aspect specifically
function getDirection(d){
if (d < 22.5 ) {
return 'N';
} else if ( d < 67.5 ) {
return 'NE';
} else if ( d < 112.5 ) {
return 'E';
} else if ( d < 157.5 ) {
return 'SE';
} else if ( d < 202.5 ) {
return 'S';
} else if ( d < 247.5 ) {
return 'SW';
} else if ( d < 292.5 ) {
return 'W';
} else if ( d < 337.5 ) {
return 'NW';
} else {
return 'N';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment