Here you can find the source of clampAngle(double angle)
public static double clampAngle(double angle)
//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; } }