Here you can find the source of absAngleDifference(double angle1Radians, double angle2Radians)
public static double absAngleDifference(double angle1Radians, double angle2Radians)
//package com.java2s; //License from project: Open Source License public class Main { public static final double PI2 = Math.PI * 2; public static double absAngleDifference(double angle1Radians, double angle2Radians) { double diff = angle1Radians - angle2Radians; while (diff > Math.PI) diff -= PI2;/*from ww w .ja v a 2 s .c om*/ while (diff < -Math.PI) diff += PI2; return Math.abs(diff); } }