List of usage examples for java.lang Math acos
public static double acos(double a)
From source file:org.getspout.commons.util.FastVector.java
public float angle(Vector other) { double dot = dot(other) / (length() * other.length()); return (float) Math.acos(dot); }
From source file:com.duy.pascal.interperter.libraries.math.MathLib.java
@PascalMethod(description = "Return inverse cosine") public double ArcCos(double x) { return Math.acos(x); }
From source file:edu.csun.ecs.cs.multitouchj.ui.utility.PointUtility.java
public static float getAngle(Point point, boolean isCartesianCoordinateSystem) { Point targetPoint = new Point(point); if (!isCartesianCoordinateSystem) { targetPoint.setY((-1 * targetPoint.getY())); }/*www .j a v a2s . c o m*/ Point origin = new Point(0.0f, 0.0f); float distance = PointUtility.getDistance(origin, targetPoint); float deltaX = Math.abs(targetPoint.getX()); float angle = (float) Math.toDegrees(Math.acos((deltaX / distance))); if (targetPoint.getX() > 0.0f) { if (targetPoint.getY() > 0.0f) { // nothing to do } else { angle = (360.0f - angle); } } else { if (targetPoint.getY() > 0.0f) { angle = (180.0f - angle); } else { angle = (180.0f + angle); } } return angle; }
From source file:com.autodomum.daylight.algorithm.DaylightAlgorithm.java
/** * Calculate length of the day for a specific day * //from w w w . j a v a 2 s . com * @param latitude * the latitude * @param day * the day * @return time in hours */ public double length(double latitude, int day) { final double p = Math .asin(.39795 * Math.cos(.2163108 + 2 * Math.atan(.9671396 * Math.tan(.00860 * (day - 186))))); return (24.0d - (24.0d / Math.PI) * Math .acos((Math.sin(0.8333d * Math.PI / 180d) + Math.sin(latitude * Math.PI / 180.0d) * Math.sin(p)) / (Math.cos(latitude * Math.PI / 180.0d) * Math.cos(p)))); }
From source file:org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord.java
public double distance(ZipcodeRecord other) { if (other.getZipcode().equals(zipcode)) return 0.0; Pair<Double, Double> otherCoords = other.getCoordinates(); double dist = Math.sin(Math.toRadians(coordinates.getLeft())) * Math.sin(Math.toRadians(otherCoords.getLeft())) + Math.cos(Math.toRadians(coordinates.getLeft())) * Math.cos(Math.toRadians(otherCoords.getLeft())) * Math.cos(Math.toRadians(coordinates.getRight() - otherCoords.getRight())); dist = Math.toDegrees(Math.acos(dist)) * 69.09; return dist;// www. j ava 2 s .c om }
From source file:org.moeaframework.util.tree.NodeTest.java
@Test public void testAcos() { Node node = new Acos().setArgument(0, new Constant(Math.PI / 4.0)); Assert.assertTrue(//from w ww .j a v a2s .c o m NumberArithmetic.equals(Math.acos(Math.PI / 4.0), (Number) node.evaluate(new UnusedEnvironment()))); }
From source file:org.apache.bigtop.datagenerators.locations.Location.java
public double distance(Pair<Double, Double> otherCoords) { if (Math.abs(coordinates.getLeft() - otherCoords.getLeft()) < 1e-5 || Math.abs(coordinates.getRight() - otherCoords.getRight()) < 1e-5) return 0.0; double dist = Math.sin(Math.toRadians(coordinates.getLeft())) * Math.sin(Math.toRadians(otherCoords.getLeft())) + Math.cos(Math.toRadians(coordinates.getLeft())) * Math.cos(Math.toRadians(otherCoords.getLeft())) * Math.cos(Math.toRadians(coordinates.getRight() - otherCoords.getRight())); dist = Math.toDegrees(Math.acos(dist)) * 69.09; return dist;//from w w w . ja v a 2s . c om }
From source file:org.jcurl.model.PathSegment.java
protected PathSegment(boolean isRockCoordinates, double t0, Point2D x0, Point2D v0, final R1R1Function[] c) { super(c);//w w w . j av a2 s.c om if (c.length != 3) throw new IllegalArgumentException("rock path curve must have 3 dimensions, but had " + c.length); this.isRockCoordinates = isRockCoordinates; this.rc2wc = new AffineTransform(); final double vabs = v0.distance(0, 0); if (vabs != 0.0) rc2wc.rotate(-Math.acos((v0.getX() * 0 + v0.getY() * 1) / vabs), x0.getX(), x0.getY()); rc2wc.translate(x0.getX(), x0.getY()); this.t0 = t0; }
From source file:org.apache.bigtop.bigpetstore.datagenerator.generators.locations.Location.java
public double distance(Pair<Double, Double> otherCoords) { double eps = 1e-3; if (Math.abs(coordinates.getLeft() - otherCoords.getLeft()) < eps && Math.abs(coordinates.getRight() - otherCoords.getRight()) < eps) return 0.0; double dist = Math.sin(Math.toRadians(coordinates.getLeft())) * Math.sin(Math.toRadians(otherCoords.getLeft())) + Math.cos(Math.toRadians(coordinates.getLeft())) * Math.cos(Math.toRadians(otherCoords.getLeft())) * Math.cos(Math.toRadians(coordinates.getRight() - otherCoords.getRight())); dist = Math.toDegrees(Math.acos(dist)) * 69.09; return dist;//from w ww.j a v a2 s . c o m }
From source file:com.jh.blockcanarydemo.DemoFragment.java
private double compute() { double result = 0; for (int i = 0; i < 1000000; ++i) { result += Math.acos(Math.cos(i)); result -= Math.asin(Math.sin(i)); }//from w w w .j a v a2 s.co m return result; }