Here you can find the source of constrainAngle(float degree)
public static float constrainAngle(float degree)
//package com.java2s; public class Main { /**//ww w. j a v a 2 s.co m * Constrain a given degree to between 0-359 */ public static float constrainAngle(float degree) { while (degree < 0.0f || degree >= 360.0f) { if (degree < 0.0f) degree = 360.0f + degree; else if (degree >= 360.0f) degree -= 360.0f; } return degree; } }