Java Angle Reduce reduceAngle(double theta)

Here you can find the source of reduceAngle(double theta)

Description

reduce Angle

License

Open Source License

Declaration

public static final double reduceAngle(double theta) 

Method Source Code

//package com.java2s;

public class Main {
    public static final double PI = Math.PI;
    public static final double TWOPI = Math.PI * 2;
    public static final double HALF_PI = PI / 2;

    public static final double reduceAngle(double theta) {
        theta %= TWOPI;//from   ww  w.  ja v a 2 s.co  m
        if (Math.abs(theta) > PI) {
            theta = theta - TWOPI;
        }
        if (Math.abs(theta) > HALF_PI) {
            theta = PI - theta;
        }
        return theta;
    }
}

Related

  1. reduceAngle(double theta)
  2. reduceAngle(float angle)
  3. reduceAngle(float theta)