Java Angle Difference angleDif(double a1, double a2)

Here you can find the source of angleDif(double a1, double a2)

Description

Compute the difference between two angles.

License

Open Source License

Declaration

public static double angleDif(double a1, double a2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /** Compute the difference between two angles.
     * The resulting angle is in the range of -pi..+pi if the input angle are
     * also in this range.//from  w  w w . j  a  v  a  2  s  .c  o  m
     */
    public static double angleDif(double a1, double a2) {
        double val = a1 - a2;
        if (val > Math.PI) {
            val -= 2. * Math.PI;
        }
        if (val < -Math.PI) {
            val += 2. * Math.PI;
        }
        return val;
    }
}

Related

  1. angleDif(float a, float b)
  2. angleDif(float a1, float a2)
  3. angleDiff(double a, double b)
  4. angleDiff(double alpha, double beta)