List of usage examples for java.lang Math sin
@HotSpotIntrinsicCandidate public static double sin(double a)
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 www . j a v a2 s . c om img[index] = i; }
From source file:Main.java
public static double[] bd_encrypt(double gg_lat, double gg_lon) { double x = gg_lon, y = gg_lat; double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi); double bd_lon = z * Math.cos(theta) + 0.0065; double bd_lat = z * Math.sin(theta) + 0.006; return new double[] { bd_lon, bd_lat }; }
From source file:Main.java
public static double[] getGaoDePos(double[] baiDu) { double X_PI = 3.14159265358979324 * 3000.0 / 180.0; double x = baiDu[0] - 0.0065, y = baiDu[1] - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI); double[] gaode = new double[2]; gaode[0] = z * Math.cos(theta); gaode[1] = z * Math.sin(theta); return gaode; }
From source file:Main.java
public static double transformLon(double x, double y) { double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0; ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0; return ret;// www. ja va 2 s. co m }
From source file:Main.java
public static double[] bd_decrypt(double bd_lat, double bd_lon) { double x = bd_lon - 0.0065, y = bd_lat - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi); double gg_lon = z * Math.cos(theta); double gg_lat = z * Math.sin(theta); return new double[] { gg_lon, gg_lat }; }
From source file:Main.java
public static double transformLat(double x, double y) { double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0; ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0; return ret;//from w w w .j a v a 2 s . co m }
From source file:Main.java
public static double distFrom(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 3958.75; double dLat = Math.toRadians(lat2 - lat1); double dLng = Math.toRadians(lng2 - lng1); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLng / 2) * Math.sin(dLng / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double dist = earthRadius * c; int meterConversion = 1609; return dist * meterConversion; }
From source file:Main.java
public static double distance(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 6371000; //meters double dLat = Math.toRadians(lat2 - lat1); double dLng = Math.toRadians(lng2 - lng1); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLng / 2) * Math.sin(dLng / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double distance = (double) (earthRadius * c); return distance; }
From source file:Main.java
public static float getAngleToCoordinates(double _direction, float _startX, float _startY, char _type) { if (_type == 'x') { return _startX + (float) Math.cos((_direction * Math.PI) / 180); } else {//from w ww . j av a 2s . c o m return _startY + (float) Math.sin((_direction * Math.PI) / 180); } }
From source file:Main.java
public static double distFrom(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 3958.75; double dLat = Math.toRadians(lat2 - lat1); double dLng = Math.toRadians(lng2 - lng1); double sindLat = Math.sin(dLat / 2); double sindLng = Math.sin(dLng / 2); double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) * Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double dist = earthRadius * c; if (dist >= 1000) { int distInInt = (int) dist; dist = (int) distInInt; } else if (dist >= 100) { dist = (((int) (dist * 10)) / 10.0); } else {/*from www . ja v a2 s. c o m*/ dist = (((int) (dist * 100)) / 100.0); } return dist; }