Android examples for java.lang:Math
Constrain a given degree to between 0-359
//package com.java2s; public class Main { /**// w w w. j a v a 2 s . c o 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; } }