Example usage for java.lang Math PI

List of usage examples for java.lang Math PI

Introduction

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

Prototype

double PI

To view the source code for java.lang Math PI.

Click Source Link

Document

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Usage

From source file:Main.java

public static double calDistance(double latX, double lngX, double latY, double lngY) {
    double scale = 6400 * 1000 * (Math.PI / 180);
    double dX = scale * Math.abs((latX - latY));
    double dY = scale * Math.abs((lngX - lngY));
    return Math.sqrt(dX * dX + dY * dY);
}

From source file:Main.java

public static double rotationalSpeedToSpeed(float rotationalSpeed, float wheelDiameter) {
    return (double) rotationalSpeed * Math.PI * (double) wheelDiameter * 6.0 / 100000.0;
}

From source file:Main.java

private static double validateAngle(double angle) {
    angle = (angle % (2 * Math.PI));
    if (angle <= -Math.PI) {
        angle = angle + (2 * Math.PI);
    } else if (angle > Math.PI) {
        angle = angle - (2 * Math.PI);
    }/*from   w  ww.ja va  2s.c  o  m*/
    return angle;
}

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;
    rLat = lat * Math.PI / 180;/*from   ww w .  j  a  v a  2 s. c o  m*/
    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 };
}

From source file:Main.java

public static float getCirclePathLength(float radius, float angle) {
    angle = changeAngleToSingle(angle);//from   w  w w .jav  a  2s. c  o m
    return (float) (Math.PI * radius * angle / 180);
}

From source file:Main.java

public static int latitudeToPixelY(double latitude, double zoomLevel, int tileSize) {
    double sinLatitude = Math.sin(latitude * (Math.PI / 180));
    int mapSize = getMapSize(zoomLevel, tileSize);
    return (int) Math
            .round((0.5d - Math.log((1d + sinLatitude) / (1d - sinLatitude)) / (4d * Math.PI)) * mapSize);
}

From source file:Main.java

private static void multTwiddleFactor(int index, float[] real, float[] img, int pos, int sum) {

    float cosArg = (float) Math.cos(-2.0f * Math.PI * pos / (float) sum);
    float sinArg = (float) Math.sin(-2.0f * Math.PI * pos / (float) sum);

    float r = real[index] * cosArg - img[index] * sinArg;
    float i = real[index] * sinArg + img[index] * cosArg;

    real[index] = r;//from   ww  w  .  ja  v a  2 s .  c om
    img[index] = i;
}

From source file:Main.java

static double DegreesToRadians(double degrees) {
    return degrees * Math.PI / 180;
}

From source file:Main.java

static double RadiansToDegrees(double radians) {
    return radians * 180 / Math.PI;
}

From source file:Main.java

public static float[] position_on_circle(final float centerX, final float centerY, float pDegree,
        float pRadius) {
    double radian = (pDegree / 180) * Math.PI;
    float x = ((float) (centerX + Math.cos(radian) * pRadius));//-this.getWidth()/2;
    float y = ((float) (centerY - Math.sin(radian) * pRadius));//-this.getHeight()/2; 
    return new float[] { x, y };
}