List of usage examples for java.lang Math acos
public static double acos(double a)
From source file:Main.java
public static void main(String[] args) { double x = Math.PI / 2; x = Math.toRadians(x);/*from ww w.ja v a2 s .c o m*/ System.out.println("Math.acos(" + x + ")=" + Math.acos(x)); }
From source file:TrigonometricDemo.java
public static void main(String[] args) { double degrees = 45.0; double radians = Math.toRadians(degrees); System.out.format("The value of pi is %.4f%n", Math.PI); System.out.format("The sine of %.1f degrees is %.4f%n", degrees, Math.sin(radians)); System.out.format("The cosine of %.1f degrees is %.4f%n", degrees, Math.cos(radians)); System.out.format("The tangent of %.1f degrees is %.4f%n", degrees, Math.tan(radians)); System.out.format("The arcsine of %.4f is %.4f degrees %n", Math.sin(radians), Math.toDegrees(Math.asin(Math.sin(radians)))); System.out.format("The arccosine of %.4f is %.4f degrees %n", Math.cos(radians), Math.toDegrees(Math.acos(Math.cos(radians)))); System.out.format("The arctangent of %.4f is %.4f degrees %n", Math.tan(radians), Math.toDegrees(Math.atan(Math.tan(radians)))); }
From source file:TrigonometricDemo.java
public static void main(String[] args) { double degrees = 45.0; double radians = Math.toRadians(degrees); System.out.println("The value of pi is " + Math.PI); System.out.println("The sine of " + degrees + " is " + Math.sin(radians)); System.out.println("The cosine of " + degrees + " is " + Math.cos(radians)); System.out.println("The tangent of " + degrees + " is " + Math.tan(radians)); System.out.println("The arc sine of " + Math.sin(radians) + " is " + Math.toDegrees(Math.asin(Math.sin(radians))) + " degrees"); System.out.println("The arc cosine of " + Math.cos(radians) + " is " + Math.toDegrees(Math.acos(Math.cos(radians))) + " degrees"); System.out.println("The arc tangent of " + Math.tan(radians) + " is " + Math.toDegrees(Math.atan(Math.tan(radians))) + " degrees"); }
From source file:Main.java
public static float acos(double value) { return (float) Math.toDegrees(Math.acos(value)); }
From source file:Main.java
public static float acos(float x) { return (float) Math.acos(x); }
From source file:Main.java
public static Map<Double, Double> findAngles(double a, double b, double c) { Map<Double, Double> sideToAngleMap = new HashMap<Double, Double>(); sideToAngleMap.put(a, Math.toDegrees(Math.acos((b * b + c * c - a * a) / (2 * b * c)))); sideToAngleMap.put(b, Math.toDegrees(Math.acos((a * a + c * c - b * b) / (2 * a * c)))); sideToAngleMap.put(c, 180 - sideToAngleMap.get(a) - sideToAngleMap.get(b)); return sideToAngleMap; }
From source file:Main.java
public static double distance(double lat1, double lon1, double lat2, double lon2) { Double theta = lon1 - lon2;/*from www . java 2 s. co m*/ 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; // M // dist = dist * 1.609344 * 1000; // m dist = dist * 1.609344; // km // dist = dist * 0.8684; //n return dist; }
From source file:Main.java
public static double GetDistance(double pLatitude1, double pLongitude1, double pLatitude2, double pLongitude2) { double vDist = Math.sin(deg2rad(pLatitude1)) * Math.sin(deg2rad(pLatitude2)) + Math.cos(deg2rad(pLatitude1)) * Math.cos(deg2rad(pLatitude2)) * Math.cos(deg2rad(pLongitude1 - pLongitude2)); vDist = Math.acos(vDist); vDist = rad2deg(vDist);//w ww . j ava 2 s . c om vDist = vDist * 111189.57696;// * 60 * 1.1515 * 1.609344 * 1000; return vDist; }
From source file:Main.java
/** * Calculates the angle between two points on a cartesian plane */// ww w. j a v a 2 s . c o m public static float getAngle(float center_x, float center_y, float post_x, float post_y) { float tmpv_x = post_x - center_x; float tmpv_y = post_y - center_y; float d = (float) Math.sqrt(tmpv_x * tmpv_x + tmpv_y * tmpv_y); float cos = tmpv_x / d; float angle = (float) Math.toDegrees(Math.acos(cos)); angle = (tmpv_y < 0) ? angle * -1 : angle; return angle; }
From source file:Main.java
private static double getDistanceFromXtoY(double lat_a, double lng_a, double lat_b, double lng_b) { double pk = 180 / 3.14169; double a1 = lat_a / pk; double a2 = lng_a / pk; double b1 = lat_b / pk; double b2 = lng_b / pk; double t1 = Math.cos(a1) * Math.cos(a2) * Math.cos(b1) * Math.cos(b2); double t2 = Math.cos(a1) * Math.sin(a2) * Math.cos(b1) * Math.sin(b2); double t3 = Math.sin(a1) * Math.sin(b1); double tt = Math.acos(t1 + t2 + t3); return 6366000 * tt; }