Normalize the angle to the range 0 <= value < 360. - Android java.lang

Android examples for java.lang:Math Geometry

Description

Normalize the angle to the range 0 <= value < 360.

Demo Code

// Licensed under the Apache License, Version 2.0 (the "License");
//package com.java2s;

public class Main {
    /**// ww  w.  j av a  2s  . c  om
     * Normalize the angle to the range 0 <= value < 360.
     */
    public static double normalizeAngle(double angle) {
        double remainder = angle % 360;
        if (remainder < 0)
            remainder += 360;
        return remainder;
    }
}

Related Tutorials