Advertisement
Drakia

Untitled

Apr 8th, 2011
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. /**
  2. * Converts a rotation to a cardinal direction name.
  3. * Author: sk89q - Original function from CommandBook plugin
  4. * @param rot
  5. * @return
  6. */
  7. private static String getDirection(double rot) {
  8. if (0 <= rot && rot < 22.5) {
  9. return "North";
  10. } else if (22.5 <= rot && rot < 67.5) {
  11. return "Northwest";
  12. } else if (67.5 <= rot && rot < 112.5) {
  13. return "West";
  14. } else if (112.5 <= rot && rot < 157.5) {
  15. return "Southwest";
  16. } else if (157.5 <= rot && rot < 202.5) {
  17. return "South";
  18. } else if (202.5 <= rot && rot < 247.5) {
  19. return "Southeast";
  20. } else if (247.5 <= rot && rot < 292.5) {
  21. return "East";
  22. } else if (292.5 <= rot && rot < 337.5) {
  23. return "Northeast";
  24. } else if (337.5 <= rot && rot < 360.0) {
  25. return "North";
  26. } else {
  27. return null;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement