Android Angle Convert normalize(final float angle)

Here you can find the source of normalize(final float angle)

Description

Normalize an angle so that it belongs to the [0, 360[ range.

License

Apache License

Parameter

Parameter Description
angle the angle in degrees

Return

the same angle in the [0, 360[ range

Declaration

public static float normalize(final float angle) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//w ww  . j  a v  a  2s .co m
     * Normalize an angle so that it belongs to the [0, 360[ range.
     * @param angle the angle in degrees
     * @return the same angle in the [0, 360[ range
     */
    public static float normalize(final float angle) {
        return (angle >= 0 ? angle : (360 - ((-angle) % 360))) % 360;
    }
}

Related

  1. constrainAngle(float degree)
  2. difference(final float from, final float to)