This weekend I spend a few minutes thrashing together an algorithm that would take in a heading (in degrees) and return a String for the cardinal direction (I\'m using it in an
in java:
String _directions[] = {"N", "NE", "E", "SE", "S", "SW", "W", "NW"};
public String getHeading(int hea) {
return _directions[(int)Math.floor((hea % 360) / 45)];
}
In "java" case u must need to create a Class.
in javascript:
var _directions = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
function getDirection (hea) {
return _directions[Math.floor((hea % 360) / 45)];
};