subtract 180 Angle - Java 2D Graphics

Java examples for 2D Graphics:Angle

Description

subtract 180 Angle

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        double angle = 2.45678;
        System.out.println(sub180Angle(angle));
    }//from ww w  . j a va2s.  co m

    public static double sub180Angle(double angle) {
        while (angle > 180.) {
            angle = angle - 360.;
        }
        while (angle < -180.) {
            angle = angle + 360.;
        }
        return angle;
    }
}

Related Tutorials