Java tan tan(int f)

Here you can find the source of tan(int f)

Description

tan

License

Artistic License

Declaration

public static int tan(int f) 

Method Source Code

//package com.java2s;
/*//from  w w  w.j av a2s . c o m
    
 FP version 3.1
    
 Copyright (c) 2004 Andre de Leiradella <leiradella@bigfoot.com>
    
 This program is licensed under the Artistic License.
    
 See http://www.opensource.org/licenses/artistic-license.html for details.
    
 Uses parts or ideas from FPMath. FPMath is copyright (c) 2001 Beartronics and
 is authored by Henry Minsky.
 http://bearlib.sourceforge.net/
    
 Uses parts or ideas from oMathFP. oMathFP is copyright (c) 2004 Dan Carter.
 http://orbisstudios.com/
    
 */

public class Main {
    public static int tan(int f) {
        int s, c;
        s = sin(f);
        c = cos(f);
        if (c != 0)
            return ((int) (((((long) s) << 32) / c) >> 16));
        return s < 0 ? -2147483648 : 2147483647;
    }

    public static int sin(int f) {
        boolean neg;
        f = (f % 411774);
        if (neg = f < 0)
            f = -f;
        if (f < 102943) {
            ;
        } else if (f < 205887) {
            f = (205887 - f);
        } else if (f < 308830) {
            f = (f - 205887);
            neg = !neg;
        } else {
            f = (411774 - f);
            neg = !neg;
        }
        int g = ((int) ((((long) f) * ((long) f)) >> 16));
        g = ((int) ((((long) f)
                * (65536 + ((((long) g) * (((((long) g) * ((long) 498)) >> 16) - 10881)) >> 16))) >> 16));
        return neg ? -g : g;
    }

    public static int cos(int f) {
        return sin(f + 102943);
    }
}

Related

  1. tan(final float value)
  2. tan(float angle)
  3. tan(float angle)
  4. tan(float angle)
  5. tan(float f)
  6. tan(Number x)
  7. tan(Short a)
  8. tanD(double arg)
  9. tand(double x)