Java Distance Calculate distHalf(double angA, double angB)

Here you can find the source of distHalf(double angA, double angB)

Description

Angular distance between two half circle angles.

License

Open Source License

Parameter

Parameter Description
angA Angle between -pi/2 and pi/2.
angB Angle between -pi/2 and pi/2.

Return

Acute angle between the two input angles.

Declaration

public static double distHalf(double angA, double angB) 

Method Source Code

//package com.java2s;
/*//from   www.  java  2 s .co m
 * Copyright (c) 2011-2012, Peter Abeles. All Rights Reserved.
 *
 * This file is part of Geometric Regression Library (GeoRegression).
 *
 * GeoRegression is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * JGRL 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GeoRegression.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Angular distance between two half circle angles.
     *
     * @param angA Angle between -pi/2 and pi/2.
     * @param angB Angle between -pi/2 and pi/2.
     * @return Acute angle between the two input angles.
     */
    public static double distHalf(double angA, double angB) {
        double a = Math.abs(angA - angB);
        if (a <= Math.PI / 2)
            return a;
        else
            return Math.PI - a;
    }
}

Related

  1. distence(double lat1, double lon1, double lat2, double lon2, double radius)
  2. distEucl(float[] x1, float[] x2)
  3. distExtraBits(int dist)
  4. distFrom(double lat1, double lng1, double lat2, double lng2)
  5. distFrom(double lat1, double lng1, double lat2, double lng2)
  6. distHaversineRAD(double lat1, double lon1, double lat2, double lon2)
  7. distinctFrom(String string, String other)
  8. distL1(double[] h1, double[] h2)
  9. distL1(int[] h1, int[] h2)