Java Radian Calculation radianAdd(double a, double b)

Here you can find the source of radianAdd(double a, double b)

Description

Adding to radians for Motion library.

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter

Return

a+b radians according to rule

Declaration

public final static double radianAdd(double a, double b) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Serdar Ormanl?./*  w w w .  ja  v a2s .  c  om*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Serdar Ormanl? - initial API and implementation
 ******************************************************************************/

public class Main {
    /**
     * Adding to radians for Motion library. Plus operator wont give true result
     * 
     * @param a
     * @param b
     * @return a+b radians according to rule
     */
    public final static double radianAdd(double a, double b) {
        double result = 0;

        result = a + b;

        if (result < -1 * Math.PI) {
            result %= Math.PI;
            result += Math.PI;
        } else if (result > Math.PI) {
            result %= Math.PI;
            result += (-1 * Math.PI);
        }

        return result;
    }
}

Related

  1. radian2Angle(double radian)
  2. radiancheck(double x)
  3. radians(double d)
  4. radians(double w)
  5. radiansToBrads(double angleRadians)