Here you can find the source of clampAngle(int angle)
public static int clampAngle(int angle)
//package com.java2s; //License from project: LGPL public class Main { /**/*from ww w. j av a2 s .co m*/ * Adjust the angle so that his value is in range [-180;180[ */ public static int clampAngle(int angle) { angle = angle % 360; if (angle >= 180) { angle -= 360; } if (angle < -180) { angle += 360; } return angle; } }