public static double normalize(double a) {
        return a >= 360 ? a - (360 * (int) (a / 360))
                : a < 0 ? a - (360 * ((int) (a / 360) - 1)) : a;
    }
Calculate the angle defined by 3 points
(and deliver it's cosine on the fly)
main/src/main/java/cgeo/geocaching/brouter/util/CheapAngleMeter.java