Here you can find the source of angleDiff(int angle1, int angle2)
public static double angleDiff(int angle1, int angle2)
//package com.java2s; //License from project: Apache License public class Main { public static double angleDiff(int angle1, int angle2) { double diff = Math.abs(angle1 - angle2); if (diff <= 180) { return diff; } else {//from w w w . j a v a 2 s .c om return 360 - diff; } } }