Java cos cos(final double value)

Here you can find the source of cos(final double value)

Description

cos

License

Open Source License

Declaration

public static final double cos(final double value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static float[] COS_TABLE = new float[361];

    public static final float cos(final float value) {
        final int temp;
        if (value > 0) {
            if ((int) value > 360f) {
                if ((temp = ((int) value - ((int) (value / 360f)) * 360)) != 0) {
                    return COS_TABLE[temp];
                } else {
                    return COS_TABLE[360];
                }//from  ww  w  .  j  a  v  a 2  s  .  c  o  m
            } else {
                return COS_TABLE[(int) (value)];
            }
        } else if ((-(int) value) > 360f) {
            if ((temp = (-((int) value - ((int) (value / 360f)) * 360))) != 0) {
                return COS_TABLE[temp];
            } else {
                return COS_TABLE[360];
            }
        } else {
            return COS_TABLE[-(int) (value)];
        }
        //return COS_TABLE[(int)(value)];
    }

    public static final double cos(final double value) {
        final int temp;
        if (value > 0) {
            if ((int) value > 360d) {
                if ((temp = ((int) value - ((int) (value / 360d)) * 360)) != 0) {
                    return (double) COS_TABLE[temp];
                } else {
                    return (double) COS_TABLE[360];
                }
            } else {
                return (double) COS_TABLE[(int) (value)];
            }
        } else if ((-(int) value) > 360d) {
            if ((temp = (-((int) value - ((int) (value / 360d)) * 360))) != 0) {
                return (double) COS_TABLE[temp];
            } else {
                return (double) COS_TABLE[360];
            }
        } else {
            return (double) COS_TABLE[-(int) (value)];
        }
        //return (double)COS_TABLE[(int)(value)];
    }
}

Related

  1. cos(double anAngle)
  2. cos(double d)
  3. cos(double radians)
  4. cos(double[] v1, double[] v2)
  5. cos(double[] v1, double[] v2)
  6. cos(final float angle)
  7. cos(final float value)
  8. cos(float angle)
  9. cos(float f)