Java Number Min Value findMinAngularDistance(double angle1, double angle2)

Here you can find the source of findMinAngularDistance(double angle1, double angle2)

Description

Finds the minimum angular distance between two angles.

License

Open Source License

Parameter

Parameter Description
angle1 a parameter
angle2 a parameter

Declaration

private static double findMinAngularDistance(double angle1, double angle2) 

Method Source Code

//package com.java2s;
/*/*from  ww  w .  j  a va 2 s . c  o m*/
 * Copyright (C) 2011 apurv
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Finds the minimum angular distance between two angles.
     * @param angle1
     * @param angle2
     * @return
     */
    private static double findMinAngularDistance(double angle1, double angle2) {
        double angDistance = 0.0;
        if (Math.signum(angle2) == Math.signum(angle1)) {
            angDistance = Math.abs(angle2 - angle1);
        } else {
            double sumAngle = Math.abs(angle1) + Math.abs(angle2);
            angDistance = Math.min(sumAngle, 360 - sumAngle);
        }
        return angDistance;
    }
}

Related

  1. findMin(double newNumber, double currentMin)
  2. findMin(int a, int b, int c, int d)
  3. min( final double p_first, final double p_second, final double p_third )
  4. min(Comparable c1, Comparable c2)
  5. min(Comparable c1, Comparable c2)
  6. min(double a, double b)