Java examples for java.lang:Math Geometry
subtract 180 Difference
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { double angle = 2.45678; double from_angle = 2.45678; System.out.println(sub180Diff(angle, from_angle)); }/*ww w . j av a 2s . com*/ public static double sub180Diff(double angle, double from_angle) { while (Math.abs(angle - from_angle) > 180.) { if (angle > 0) { angle = angle - 360.; } else { angle = angle + 360.; } } return angle; } }