List of usage examples for java.lang Math asin
public static double asin(double a)
From source file:Main.java
public static float asin(float value) { return (float) Math.asin(value); }
From source file:Main.java
/** * Receives a quaternion and returns the same in Euler angles. * /* w ww.j a v a 2s. c om*/ * @param q0 First component of the quaternion, the independent term. * @param q1 Second component of the quaternion, the i term. * @param q2 Third component of the quaternion, the j term. * @param q3 Forth component of the quaternion, th k term. * @return A 3 position array which contains the x, y and z in this order. */ public static final float[] quatenionToEuler(float q0, float q1, float q2, float q3) { float[] euler = new float[3]; euler[0] = (float) Math.atan2(2 * (q0 * q1 + q2 * q3), 1 - 2 * (q1 * q1 + q2 * q2)); euler[1] = (float) Math.asin(2 * (q0 * q2 - q3 * q1)); euler[2] = (float) Math.atan2(2 * (q0 * q3 + q1 * q2), 1 - 2 * (q2 * q2 + q3 * q3)); return euler; }
From source file:Main.java
public static BigDecimal asin(BigDecimal val) { return BigDecimal.valueOf(Math.asin(val.doubleValue())); }
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 . jav a2 s. c o m s = Math.round(s * 10000d) / 10000d; s = s * 1000; return s; }
From source file:Main.java
public static double getGeoDistance(double longitude1, double latitude1, double longitude2, double latitude2) { double EARTH_RADIUS = 6378137; double radLat1 = rad(latitude1); double radLat2 = rad(latitude2); double a = radLat1 - radLat2; double b = rad(longitude1) - rad(longitude2); 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 ww . j a v a 2 s .c o m s = Math.round(s * 10000) / 10000; return s; }
From source file:Data.Utilities.java
public static Double haversine(double lat1, double lon1, double lat2, double lon2) { double dLat = Math.toRadians(lat2 - lat1); double dLon = Math.toRadians(lon2 - lon1); lat1 = Math.toRadians(lat1);/*w w w. j a v a 2 s . co m*/ lat2 = Math.toRadians(lat2); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2); double c = 2 * Math.asin(Math.sqrt(a)); return R * c; }
From source file:Main.java
/** * Waypoint projection using haversine formula * http://en.wikipedia.org/wiki/Haversine_formula See discussion here for * further information: http://www.movable-type.co.uk/scripts/latlong.html *//*from w w w . j av a 2 s . c o m*/ public static double[] project(double distance, double bearing, double startLat, double startLon) { double distanceRad = distance / EARTH_RADIUS_KM; double bearingRad = Math.toRadians(bearing); double startLatRad = Math.toRadians(startLat); double startLonRad = Math.toRadians(startLon); double endLat = Math.asin(Math.sin(startLatRad) * Math.cos(distanceRad) + Math.cos(startLatRad) * Math.sin(distanceRad) * Math.cos(bearingRad)); double endLon = startLonRad + Math.atan2(Math.sin(bearingRad) * Math.sin(distanceRad) * Math.cos(startLatRad), Math.cos(distanceRad) - Math.sin(startLatRad) * Math.sin(endLat)); // Adjust projections crossing the 180th meridian: double endLonDeg = Math.toDegrees(endLon); if (endLonDeg > 180 || endLonDeg < -180) { endLonDeg = endLonDeg % 360; // Just in case we circle the earth // more than once. if (endLonDeg > 180) { endLonDeg = endLonDeg - 360; } else if (endLonDeg < -180) { endLonDeg = endLonDeg + 360; } } double[] endCoords = new double[] { Math.toDegrees(endLat), endLonDeg }; return endCoords; }
From source file:Main.java
static double arcInRadians(Location A, Location B) { double latitudeArc = (A.getLatitude() - B.getLatitude()) * DEG_TO_RAD; double longitudeArc = (A.getLongitude() - B.getLongitude()) * DEG_TO_RAD; double latitudeH = Math.sin(latitudeArc * 0.5); latitudeH *= latitudeH;// ww w .jav a 2s .c om double lontitudeH = Math.sin(longitudeArc * 0.5); lontitudeH *= lontitudeH; double tmp = Math.cos(A.getLatitude() * DEG_TO_RAD) * Math.cos(B.getLatitude() * DEG_TO_RAD); return 2.0 * Math.asin(Math.sqrt(latitudeH + tmp * lontitudeH)); }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
public static double asin(final double x) { return Math.asin(x); }
From source file:org.apache.hadoop.hive.ql.udf.UDFAsin.java
public DoubleWritable evaluate(DoubleWritable a) { if (a == null) { return null; } else {/* w w w . j ava 2 s.c om*/ result.set(Math.asin(a.get())); return result; } }