Here you can find the source of clampAngle(float var, float min, float max)
public static float clampAngle(float var, float min, float max)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . j a v a 2 s. c o m * Clamps the angles to a min max by adding or subtracting the min max. This way it maintanes * the change in angle in the chance it goes out of bounds */ public static float clampAngle(float var, float min, float max) { while (var < min) { var += 360; } while (var > max) { var -= 360; } return var; } public static double clampAngle(double var, double min, float max) { while (var < min) { var += max; } while (var > max) { var -= max; } return var; } }