Example usage for java.lang StrictMath atan2

List of usage examples for java.lang StrictMath atan2

Introduction

In this page you can find the example usage for java.lang StrictMath atan2.

Prototype

public static native double atan2(double y, double x);

Source Link

Document

Returns the angle theta from the conversion of rectangular coordinates ( x ,  y ) to polar coordinates (r, theta).

Usage

From source file:Main.java

public static void main(String[] args) {

    double d1 = 0.6, d2 = 90.00;

    System.out.println("arc tangent value after conversion = " + StrictMath.atan2(d1, d2));

    System.out.println("arc tangent value after conversion = " + StrictMath.atan2(d2, d1));
}

From source file:org.esa.beam.util.math.FastMathPerformance.java

public void testAtan2() {
    System.gc();//  w  w w . j  a  v  a 2s  .c o m
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.atan2(i * F1, i * F1);
    long strictTime = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.atan2(i * F1, i * F1);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.atan2(i * F1, i * F1);
    long mathTime = System.nanoTime() - time;

    report("atan2", x + y + z, strictTime, fastTime, mathTime);
}