Skip to content

Instantly share code, notes, and snippets.

@jimjeffers
Created November 20, 2013 20:15
Show Gist options
  • Save jimjeffers/7570222 to your computer and use it in GitHub Desktop.
Save jimjeffers/7570222 to your computer and use it in GitHub Desktop.
Get direction from bearing.
//
// Get direction
//
this.getDirectionFromBearing = function(bearing) {
if (bearing > 330 || bearing <= 15) {
return "N";
} else if (bearing > 15 || bearing <= 60) {
return "NE";
} else if (bearing > 60 || bearing <= 105) {
return "E";
} else if (bearing > 105|| bearing <= 150) {
return "SE";
} else if (bearing > 150 || bearing <= 195) {
return "S";
} else if (bearing > 195 || bearing <= 240) {
return "SW";
} else if (bearing > 240 || bearing <= 285) {
return "W";
} else if (bearing > 285 || bearing <= 330) {
return "NW";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment