normalize Angle - Java java.lang

Java examples for java.lang:Math Radian

Description

normalize Angle

Demo Code


//package com.java2s;

public class Main {


    /**//  w ww . j a  v  a 2  s  .  c om
     *
     * @param angle
     * @return
     */
    public static float normalizeAngle(float angle) {
        angle = angle % 360.0f;
        return angle < 0 ? angle + 360.0f : angle;
    }

    /**
     *
     * @param angle
     * @return
     */
    public static double normalizeAngle(double angle) {
        angle = angle % 360.0;
        return angle < 0 ? angle + 360.0 : angle;
    }
}

Related Tutorials