Java Integer Clamp clampAngle(int angle)

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

Description

Adjust the angle so that his value is in range [-180;180[

License

LGPL

Declaration

public static int clampAngle(int angle) 

Method Source Code

//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;
    }
}

Related

  1. clamp(int x, int min, int max)
  2. clamp(int x, int min, int max)
  3. clamp(String string, int maxChars)
  4. clamp_int(int num, int min, int max)
  5. clamp_wrap(int a, int x, int y)
  6. clampByte(int in)
  7. clampColor(int c)
  8. clampColorInt(int color)
  9. CLAMPED_Wr(long ITERW, int FBZCP)