Here you can find the source of angleDiff(final double a1, final double a2)
Parameter | Description |
---|---|
a1 | a parameter |
a2 | a parameter |
public static final double angleDiff(final double a1, final double a2)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w.j a v a 2 s .c o m*/ * Get the difference of angles (radians) as given from angle(x,z), from a1 to a2, i.e. rather a2 - a1 in principle. * @param a1 * @param a2 * @return Difference of angle from -pi to pi */ public static final double angleDiff(final double a1, final double a2) { if (Double.isNaN(a1) || Double.isNaN(a1)) return Double.NaN; final double diff = a2 - a1; if (diff < -Math.PI) return diff + 2.0 * Math.PI; else if (diff > Math.PI) return diff - 2.0 * Math.PI; else return diff; } }