Example usage for java.lang Math tan

List of usage examples for java.lang Math tan

Introduction

In this page you can find the example usage for java.lang Math tan.

Prototype

@HotSpotIntrinsicCandidate
public static double tan(double a) 

Source Link

Document

Returns the trigonometric tangent of an angle.

Usage

From source file:Main.java

/**
 * Calculate the difference between true solar time and mean. The "equation
 * of time" is a term accounting for changes in the time of solar noon for
 * a given location over the course of a year. Earth's elliptical orbit and
 * Kepler's law of equal areas in equal times are the culprits behind this
 * phenomenon. See the//from  ww  w. j  a va  2 s .c  o m
 * <A HREF="http://www.analemma.com/Pages/framesPage.html">Analemma page</A>.
 * Below is a plot of the equation of time versus the day of the year.
 *
 * <P align="center"><img src="doc-files/EquationOfTime.png"></P>
 *
 * @param  t number of Julian centuries since J2000.
 * @return Equation of time in minutes of time.
 */
private static double equationOfTime(final double t) {
    double eps = Math.toRadians(obliquityCorrected(t));
    double l0 = Math.toRadians(sunGeometricMeanLongitude(t));
    double m = Math.toRadians(sunGeometricMeanAnomaly(t));
    double e = eccentricityEarthOrbit(t);
    double y = Math.tan(eps / 2);
    y *= y;

    double sin2l0 = Math.sin(2 * l0);
    double cos2l0 = Math.cos(2 * l0);
    double sin4l0 = Math.sin(4 * l0);
    double sin1m = Math.sin(m);
    double sin2m = Math.sin(2 * m);

    double etime = y * sin2l0 - 2 * e * sin1m + 4 * e * y * sin1m * cos2l0 - 0.5 * y * y * sin4l0
            - 1.25 * e * e * sin2m;

    return Math.toDegrees(etime) * 4.0;
}

From source file:Main.java

static public final float tan(float angle) {
    return (float) Math.tan(angle);
}

From source file:Main.java

/**
 * @return The tile index for the latitude at the given zoom
 *///from   ww w .j a  va2 s .c  o  m
public static int toTileY(double lat, int zoom) {
    lat = 0.5 - ((Math.log(Math.tan((Math.PI / 4) + ((0.5 * Math.PI * lat) / 180))) / Math.PI) / 2.0);
    int scale = 1 << zoom;
    return (int) (lat * scale);
}

From source file:Main.java

public static double polarFunction(double t, double A, double B, double N) {
    return A / Math.log(B * Math.tan(t / (2 * N)));
}

From source file:uk.co.modularaudio.util.math.FastMath.java

public final static double tan(final double theta) {
    //      return org.apache.commons.math3.util.FastMath.tan( theta );
    //      return 0.0000000001d;
    //      return StrictMath.tan( theta );
    return Math.tan(theta);
}

From source file:edu.columbia.sel.grout.util.TileUtils.java

/**
 * For a description see:/*w ww  .j a  v  a 2s . com*/
 * 
 * @see http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames For a
 *      code-description see:
 * @see http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames#
 *      compute_bounding_box_for_tile_number
 * @param aLat
 *            latitude to get the {@link OSMTileInfo} for.
 * @param aLon
 *            longitude to get the {@link OSMTileInfo} for.
 * @return The {@link OSMTileInfo} providing 'x' 'y' and 'z'(oom) for the
 *         coordinates passed.
 */
public static OSMTileInfo getMapTileFromCoordinates(final double aLat, final double aLon, final int zoom) {
    final int y = (int) Math
            .floor((1 - Math.log(Math.tan(aLat * Math.PI / 180) + 1 / Math.cos(aLat * Math.PI / 180)) / Math.PI)
                    / 2 * (1 << zoom));
    final int x = (int) Math.floor((aLon + 180) / 360 * (1 << zoom));

    return new OSMTileInfo(x, y, zoom);
}

From source file:Main.java

static double distanceFromPointOnArc(double dA, double dB, double dAB) {
    // In spherical trinagle ABC
    // a is length of arc BC, that is dB
    // b is length of arc AC, that is dA
    // c is length of arc AB, that is dAB
    // We rename parameters so following formulas are more clear:
    double a = dB;
    double b = dA;
    double c = dAB;

    // First, we calculate angles alpha and beta in spherical triangle ABC
    // and based on them we decide how to calculate the distance:
    if (Math.sin(b) * Math.sin(c) == 0.0 || Math.sin(c) * Math.sin(a) == 0.0) {
        // It probably means that one of distance is n*pi, which gives around 20000km for n = 1,
        // unlikely for Denmark, so we should be fine.
        return -1.0;
    }//  w w w . jav a2 s .com

    double alpha = Math.acos((Math.cos(a) - Math.cos(b) * Math.cos(c)) / (Math.sin(b) * Math.sin(c)));
    double beta = Math.acos((Math.cos(b) - Math.cos(c) * Math.cos(a)) / (Math.sin(c) * Math.sin(a)));

    // It is possible that both sinuses are too small so we can get nan when dividing with them
    if (Double.isNaN(alpha) || Double.isNaN(beta)) {
        return -1.0;
    }

    // If alpha or beta are zero or pi, it means that C is on the same circle as arc AB,
    // we just need to figure out if it is between AB:
    if (alpha == 0.0 || beta == 0.0) {
        return (dA + dB > dAB) ? Math.min(dA, dB) : 0.0;
    }

    // If alpha is obtuse and beta is acute angle, then
    // distance is equal to dA:
    if (alpha > Math.PI / 2 && beta < Math.PI / 2)
        return -1;

    // Analogously, if beta is obtuse and alpha is acute angle, then
    // distance is equal to dB:
    if (beta > Math.PI / 2 && alpha < Math.PI / 2)
        return -1;

    // Again, unlikely, since it would render at least pi/2*EARTH_RADIUS_IN_METERS, which is too much.
    if (Math.cos(a) == 0.0)
        return -1;

    double x = Math.atan(-1.0 / Math.tan(c) + (Math.cos(b) / (Math.cos(a) * Math.sin(c))));

    return x;
}

From source file:uk.me.berndporr.iirj.HighPassTransform.java

public HighPassTransform(double fc, LayoutBase digital, LayoutBase analog) {
    digital.reset();/*ww w.ja  v a 2  s. c  o  m*/

    // prewarp
    f = 1. / Math.tan(Math.PI * fc);

    int numPoles = analog.getNumPoles();
    int pairs = numPoles / 2;
    for (int i = 0; i < pairs; ++i) {
        PoleZeroPair pair = analog.getPair(i);
        digital.addPoleZeroConjugatePairs(transform(pair.poles.first), transform(pair.zeros.first));
    }

    if ((numPoles & 1) == 1) {
        PoleZeroPair pair = analog.getPair(pairs);
        digital.add(transform(pair.poles.first), transform(pair.zeros.first));
    }

    digital.setNormal(Math.PI - analog.getNormalW(), analog.getNormalGain());
}

From source file:com.cloudmade.api.Utils.java

/**
 * Convert latitude, longitude pair to tile coordinates
 * /*  w w w.  j  av a 2s . co m*/
 * @param latitude
 * @param longitude
 * @param zoom
 * @return Tile coordinates [x, y]
 */
public static final int[] latlon2tilenums(double latitude, double longitude, int zoom) {
    int factor = 1 << (zoom - 1);
    latitude = Math.toRadians(latitude);
    longitude = Math.toRadians(longitude);
    double xtile = 1 + longitude / Math.PI;
    double ytile = 1 - Math.log(Math.tan(latitude) + (1 / Math.cos(latitude))) / Math.PI;
    return new int[] { (int) (xtile * factor), (int) (ytile * factor) };
}

From source file:uk.me.berndporr.iirj.LowPassTransform.java

public LowPassTransform(double fc, LayoutBase digital, LayoutBase analog) {
    digital.reset();/*from   w  ww.  ja va2 s .  c  om*/

    // prewarp
    f = Math.tan(Math.PI * fc);

    int numPoles = analog.getNumPoles();
    int pairs = numPoles / 2;
    for (int i = 0; i < pairs; ++i) {
        PoleZeroPair pair = analog.getPair(i);
        digital.addPoleZeroConjugatePairs(transform(pair.poles.first), transform(pair.zeros.first));
    }

    if ((numPoles & 1) == 1) {
        PoleZeroPair pair = analog.getPair(pairs);
        digital.add(transform(pair.poles.first), transform(pair.zeros.first));
    }

    digital.setNormal(analog.getNormalW(), analog.getNormalGain());
}