Well yea. Here's basically whats up,
Here's the enum:
public enum Direction { EAST, NORTHEAST, NORTH, NORTHWEST, WEST, SOUTHWEST, SOUTH, SOUTHEAST, UNDEFINED; }
I need a method to return a "Direction" ^ based on 2 points i.e:
All are in perspective to "Me"
Anypoint in the DarkRed box is north,
Anypoint in the purple box is north-west
Anypoint in the Orange box is north-east
etc etc,
How the method signature would look like:
public static Direction getDirection(Point startPoint, Point endPoint) { String dirs[] = {"EAST", "NORTHEAST", "NORTH", "NORTHWEST", "WEST", "SOUTHWEST", "SOUTH", "SOUTHEAST"}; String direction = dirs[ (int) degree % 8]; for(Direction dir : Direction.values()) { if(dir.toString().equalsIgnoreCase(direction)) { return dir; } } return Direction.UNDEFINED; }
Any ideas?