List of usage examples for java.lang Math sin
@HotSpotIntrinsicCandidate public static double sin(double a)
From source file:Main.java
public static double getDistance(double lat1, double lng1, double lat2, double lng2) { double radLat1 = rad(lat1); double radLat2 = rad(lat2); double a = radLat1 - radLat2; double b = rad(lng1) - rad(lng2); double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((double) a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); s = s * EARTH_RADIUS;//from ww w .jav a 2 s. c om return s; }
From source file:Main.java
private static double getBreathingY(long time, int n, int t) { float k = 1.0f / 3; float pi = 3.1415f; float x = time / 1000.0f; t = (int) (t / 1000.0f); if (x >= ((n - 1) * t) && x < ((n - (1 - k)) * t)) { double i = pi / (k * t) * ((x - (0.5f * k * t)) - (n - 1) * t); return 0.5f * Math.sin(i) + 0.5f; } else if (x >= ((n - (1 - k)) * t) && x < n * t) { double j = pi / ((1 - k) * t) * ((x - (0.5f * (3 - k) * t)) - (n - 1) * t); double one = 0.5f * Math.sin(j) + 0.5f; return one * one; }//from w ww . j av a2s . c o m return 0; }
From source file:Main.java
public static double GetDistance(double lat1, double lng1, double lat2, double lng2) { double radLat1 = rad(lat1); double radLat2 = rad(lat2); double a = radLat1 - radLat2; double b = rad(lng1) - rad(lng2); double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); s = s * EARTH_RADIUS;//from w w w .j a va 2 s. co m s = Math.round(s * 10000) / 10000; return s; }
From source file:Main.java
public static double DistanceOfTwoPoints(double lat1, double lng1, double lat2, double lng2) { double radLat1 = rad(lat1); double radLat2 = rad(lat2); double a = radLat1 - radLat2; double b = rad(lng1) - rad(lng2); double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); s = s * EARTH_RADIUS;/*w w w. j a v a 2s. co m*/ s = Math.round(s * 10000) / 10000; return s; }
From source file:Main.java
public static double getBearing(double lat1, double lng1, double lat2, double lng2) { double dLat = Math.toRadians(lat2 - lat1); double dLng = Math.toRadians(lng2 - lng1); lat1 = Math.toRadians(lat1);// ww w .j av a 2 s . co m lat2 = Math.toRadians(lat2); lng1 = Math.toRadians(lng1); lng2 = Math.toRadians(lng2); double y = Math.sin(dLng) * Math.cos(lat2); double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLng); double brng = Math.toDegrees(Math.atan2(y, x)); return brng; }
From source file:Main.java
public static float getActionSpot(int _direction, int _distance, float _x, float _y, char _type, float _xOffset, float _yOffset) { // Palautetaan x- tai y-arvo _typen mukaan if (_type == 'x') { return _x + _xOffset + (float) Math.cos((_direction * Math.PI) / 180) * _distance; } else {/*from w w w. ja v a 2s .c o m*/ return _y + _yOffset + (float) Math.sin((_direction * Math.PI) / 180) * _distance; } }
From source file:Main.java
/** * http://snippets.dzone.com/posts/show/10687 * @param lat1// w w w. jav a2 s .c o m * @param lon1 * @param lat2 * @param lon2 * @param unit "M":miles, "K":kilometers, "N":Nautical Miles * @return */ public static double distance(double lat1, double lon1, double lat2, double lon2, String unit) { double theta = lon1 - lon2; double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2)) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.cos(deg2rad(theta)); dist = Math.acos(dist); dist = rad2deg(dist); dist = dist * 60 * 1.1515; if (unit == "K") { dist = dist * 1.609344; } else if (unit == "N") { dist = dist * 0.8684; } return (dist); }
From source file:Main.java
public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) { double Lat1 = rad(latitude1); double Lat2 = rad(latitude2); double a = Lat1 - Lat2; double b = rad(longitude1) - rad(longitude2); double s = 2 * Math.asin(Math.sqrt( Math.pow(Math.sin(a / 2), 2) + Math.cos(Lat1) * Math.cos(Lat2) * Math.pow(Math.sin(b / 2), 2))); s = s * EARTH_RADIUS;/*from www .ja va2s. c o m*/ s = Math.round(s * 10000) / 10000; return s; }
From source file:Main.java
public static void setRotateM(float[] rm, float a, float x, float y, float z) { rm[3] = 0;// ww w. j a va2 s.c o m rm[7] = 0; rm[11] = 0; rm[12] = 0; rm[13] = 0; rm[14] = 0; rm[15] = 1; a *= (float) (Math.PI / 180.0f); float s = (float) Math.sin(a); float c = (float) Math.cos(a); if (1.0f == x && 0.0f == y && 0.0f == z) { rm[5] = c; rm[10] = c; rm[6] = s; rm[9] = -s; rm[1] = 0; rm[2] = 0; rm[4] = 0; rm[8] = 0; rm[0] = 1; } else if (0.0f == x && 1.0f == y && 0.0f == z) { rm[0] = c; rm[10] = c; rm[8] = s; rm[2] = -s; rm[1] = 0; rm[4] = 0; rm[6] = 0; rm[9] = 0; rm[5] = 1; } else if (0.0f == x && 0.0f == y && 1.0f == z) { rm[0] = c; rm[5] = c; rm[1] = s; rm[4] = -s; rm[2] = 0; rm[6] = 0; rm[8] = 0; rm[9] = 0; rm[10] = 1; } else { float len = length(x, y, z); if (1.0f != len) { float recipLen = 1.0f / len; x *= recipLen; y *= recipLen; z *= recipLen; } float nc = 1.0f - c; float xy = x * y; float yz = y * z; float zx = z * x; float xs = x * s; float ys = y * s; float zs = z * s; rm[0] = x * x * nc + c; rm[4] = xy * nc - zs; rm[8] = zx * nc + ys; rm[1] = xy * nc + zs; rm[5] = y * y * nc + c; rm[9] = yz * nc - xs; rm[2] = zx * nc - ys; rm[6] = yz * nc + xs; rm[10] = z * z * nc + c; } }
From source file:Main.java
/** * Calculate the apparent longitude of the sun. * * @param t number of Julian centuries since J2000. * @return Sun's apparent longitude in degrees. *//*from ww w .j a v a 2 s . co m*/ private static double sunApparentLongitude(final double t) { final double omega = Math.toRadians(125.04 - 1934.136 * t); return sunTrueLongitude(t) - 0.00569 - 0.00478 * Math.sin(omega); }