Here you can find the source of angleDifference(double angle1, double angle2)
public static double angleDifference(double angle1, double angle2)
//package com.java2s; //License from project: Open Source License public class Main { /** Returns the difference between the two angles in degrees (-180 to 180). */ public static double angleDifference(double angle1, double angle2) { return ((angle2 - angle1) % 360 + 540) % 360 - 180; }//w w w . j a va 2s . c o m }