Here you can find the source of findMinAngularDistance(double angle1, double angle2)
Parameter | Description |
---|---|
angle1 | a parameter |
angle2 | a parameter |
private static double findMinAngularDistance(double angle1, double angle2)
//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; } }