Here you can find the source of angleToCompass(double angleIn)
public static String angleToCompass(double angleIn)
//package com.java2s; //License from project: Open Source License public class Main { public static String angleToCompass(double angleIn) { double angle = angleIn % 360.0; if (angle < 22.5) return "N "; else if (angle < 67.5) return "NE"; else if (angle < 112.5) return "E "; else if (angle < 157.5) return "SE"; else if (angle < 202.5) return "S "; else if (angle < 247.5) return "SW"; else if (angle < 292.5) return "W "; else if (angle < 337.5) return "NW"; else/*from w w w .j a v a2s . c o m*/ return "N "; } }