Java Double Number Clamp clampAngle(double angle)

Here you can find the source of clampAngle(double angle)

Description

Clamps the angle in the interval [0, 360), performing 360*N shift if needed.

License

Open Source License

Declaration

public static double clampAngle(double angle) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

public class Main {
    /** Clamps the angle in the interval [0, 360), performing 360*N shift if needed. */
    public static double clampAngle(double angle) {
        if (angle >= 0)
            return angle % 360;
        return 360 * ceiling(-angle / 360) + angle;
    }//from   w  w w. j  a  v  a2  s  .c o  m

    public static int ceiling(float a) {
        int ceil = (int) a;
        return a > (float) ceil ? ceil + 1 : ceil;
    }

    public static int ceiling(double a) {
        int ceil = (int) a;
        return a > (double) ceil ? ceil + 1 : ceil;
    }
}

Related

  1. clamp255d(double d)
  2. clamp_double(double num, double min, double max)
  3. clamp_double(double p_151237_0_, double p_151237_2_, double p_151237_4_)
  4. clamp_doubleback(double a, double x, double y)
  5. clamp_latitude(double lat)
  6. clampedLerp(double lowerBnd, double upperBnd, double slide)
  7. clampFloat(double in)
  8. clampMax(double val, double max)
  9. clampMax(final double MAX, final double VALUE)