Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * Returns the smallest angle between two angles. * * @param alpha First angle in degrees * @param beta Second angle in degrees * @return Smallest angle between two angles. */ public static double differenceBetweenAngles(double alpha, double beta) { double phi = Math.abs(beta - alpha) % 360; return phi > 180 ? 360 - phi : phi; } }