Example usage for java.lang Math asin

List of usage examples for java.lang Math asin

Introduction

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

Prototype

public static double asin(double a) 

Source Link

Document

Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2.

Usage

From source file:Main.java

public static void main(String[] args) {

    // get a variable x which is equal to PI/2
    double x = Math.PI / 2;

    // convert x to Radians
    x = Math.toRadians(x);//from   w w  w  .ja  va2s  .com

    // get the arc sine of x
    System.out.println("Math.asin(" + x + ")=" + Math.asin(x));
}

From source file:TrigonometricDemo.java

public static void main(String[] args) {
    double degrees = 45.0;
    double radians = Math.toRadians(degrees);

    System.out.format("The value of pi is %.4f%n", Math.PI);
    System.out.format("The sine of %.1f degrees is %.4f%n", degrees, Math.sin(radians));
    System.out.format("The cosine of %.1f degrees is %.4f%n", degrees, Math.cos(radians));
    System.out.format("The tangent of %.1f degrees is %.4f%n", degrees, Math.tan(radians));
    System.out.format("The arcsine of %.4f is %.4f degrees %n", Math.sin(radians),
            Math.toDegrees(Math.asin(Math.sin(radians))));
    System.out.format("The arccosine of %.4f is %.4f degrees %n", Math.cos(radians),
            Math.toDegrees(Math.acos(Math.cos(radians))));
    System.out.format("The arctangent of %.4f is %.4f degrees %n", Math.tan(radians),
            Math.toDegrees(Math.atan(Math.tan(radians))));

}

From source file:TrigonometricDemo.java

public static void main(String[] args) {
    double degrees = 45.0;
    double radians = Math.toRadians(degrees);

    System.out.println("The value of pi is " + Math.PI);
    System.out.println("The sine of " + degrees + " is " + Math.sin(radians));
    System.out.println("The cosine of " + degrees + " is " + Math.cos(radians));
    System.out.println("The tangent of " + degrees + " is " + Math.tan(radians));
    System.out.println("The arc sine of " + Math.sin(radians) + " is "
            + Math.toDegrees(Math.asin(Math.sin(radians))) + " degrees");
    System.out.println("The arc cosine of " + Math.cos(radians) + " is "
            + Math.toDegrees(Math.acos(Math.cos(radians))) + " degrees");
    System.out.println("The arc tangent of " + Math.tan(radians) + " is "
            + Math.toDegrees(Math.atan(Math.tan(radians))) + " degrees");
}

From source file:Main.java

public static float asin(float x) {
    return (float) Math.asin(x);
}

From source file:Main.java

public static void getEulerAngles(float[] headView, float[] output) {
    float pitch = (float) Math.asin((double) headView[6]);
    float yaw;/*w ww  . ja  v a 2 s .  com*/
    float roll;
    if (Math.abs(headView[6]) < 0.9999999999D) {
        yaw = (float) Math.atan2((double) (-headView[2]), (double) headView[10]);
        roll = (float) Math.atan2((double) (-headView[4]), (double) headView[5]);
    } else {
        yaw = 0.0F;
        roll = (float) Math.atan2((double) headView[1], (double) headView[0]);
    }
    output[0] = -pitch;
    output[1] = -yaw;
    output[2] = -roll;
    float pitchAngle = (float) Math.toDegrees(output[0]);
    float yawAngle = (float) Math.toDegrees(output[1]);
    float rollAngle = (float) Math.toDegrees(output[2]);

    Log.e(TAG, String.format("pitchAngle=%f, yawAngle=%f, rollAngle=%f", pitchAngle, yawAngle, rollAngle));
}

From source file:Main.java

public static double getLat(int inY, int zoom) {
    double y = Math.floor(inY * 256);
    double efactor = Math.exp((0.5 - y / 256 / Math.pow(2, zoom)) * 4 * Math.PI);
    double latitude = Math.asin((efactor - 1) / (efactor + 1)) * 180 / Math.PI;
    if (latitude < -90.0) {
        latitude = -90.0;/*from ww  w .  j ava2 s  .  c o  m*/
    } else if (latitude > 90.0) {
        latitude = 90.0;
    }
    return latitude;
}

From source file:Main.java

public static double[] geoToMercator(double[] g) {
    double d = g[0] * Math.PI / 180, m = g[1] * Math.PI / 180, l = 6378137, k = 0.0818191908426,
            f = k * Math.sin(m);//from   www . ja v  a  2 s  . c o m
    double h = Math.tan(Math.PI / 4 + m / 2), j = Math.pow(Math.tan(Math.PI / 4 + Math.asin(f) / 2), k),
            i = h / j;
    // return new DoublePoint(Math.round(l * d), Math.round(l *
    // Math.log(i)));
    return new double[] { l * d, l * Math.log(i) };
}

From source file:Main.java

/**
 * Calculates the angle A given length a and circle radius r, according to
 * the law of sines ([a/sin(A) = 2R], thus [A = arcsin(a/2r)])
 * //w  w  w .  j  a va 2s.  co m
 * @param a
 * @param r
 * @return angle A in radians
 */
public static float calcAngle(float a, float r) {
    return (float) Math.asin(a / (2 * r));
}

From source file:Main.java

/**
 * Calculates the angle A given length a and circle radius r, according to
 * the law of sines ([a/sin(A) = 2R], thus [A = arcsin(a/2r)])
 * //w  w  w. j a  v a2s .c o  m
 * @param a
 * @param r
 * @return angle A in radians
 */
public static float calcAngleClamp(float a, float r) {
    return (float) Math.asin(Math.min(1, Math.max(-1, a / (2 * r))));
}

From source file:Main.java

public static long[] getTileFromGeo(double lat, double lon, int zoom) {
    double rLon, rLat, a, k, z;
    rLon = lon * Math.PI / 180;/*from   w ww  . j  a  v  a 2  s  . com*/
    rLat = lat * Math.PI / 180;
    a = 6378137;
    k = 0.0818191908426;
    z = Math.pow(Math.tan(Math.PI / 4 + rLat / 2) / (Math.tan(Math.PI / 4 + Math.asin(k * Math.sin(rLat)) / 2)),
            k);
    return new long[] { (int) (((20037508.342789 + a * rLon) * 53.5865938 / Math.pow(2, (23 - zoom))) / 256),
            (int) (((20037508.342789 - a * Math.log(z)) * 53.5865938 / Math.pow(2, (23 - zoom)))) / 256 };
}