Computes cosine for some angle represented in degrees [0, 360]. - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

Computes cosine for some angle represented in degrees [0, 360].

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        double deg = 2.45678;
        System.out.println(cos(deg));
    }//from   ww  w.  jav  a 2 s .  co  m

    /**
     * Computes cosine for some angle represented in degrees [0, 360].
     * @param deg An angle in degrees.
     * @return 
     */
    public static final double cos(double deg) {
        return Math.cos(Math.toRadians(deg));
    }
}

Related Tutorials