Java examples for 2D Graphics:Angle
Returns the difference between two angles in degrees between -180 and 180
//package com.java2s; public class Main { /**//from ww w .ja va2 s .c om * Returns the difference between two angles in degrees between -180 and 180 */ public static double minimumDifference(double a, double b) { double diffAngle = b - a; if (diffAngle > 180) diffAngle -= 360; else if (diffAngle < -180) diffAngle += 360; return diffAngle; } }