List of usage examples for java.lang Math atan2
@HotSpotIntrinsicCandidate public static double atan2(double y, double x)
From source file:IK.G.java
public static double atan2(double a, double b) { return Math.atan2(a, b); }
From source file:org.netxilia.functions.MathFunctions.java
public double ATAN2(double number_x, double number_y) { return Math.atan2(number_x, number_y); }
From source file:uk.ac.diamond.scisoft.analysis.roi.fitting.EllipseFitterTest.java
@Test public void testOrthoDist() { AngleDerivativeFunction angleDerivative = new AngleDerivativeFunction(); BrentSolver solver = new BrentSolver(); double a = 10.2; double b = 3.1; final double twopi = 2 * Math.PI; double alpha = twopi * 10. / 360; // 0 to 2 pi angleDerivative.setRadii(a, b);/*from ww w .ja v a 2s . c o m*/ angleDerivative.setAngle(alpha); // final double ca = 0; // final double cb = b-0.5; final double Xc = -5.; // Math.cos(alpha)*ca + Math.sin(alpha)*cb; final double Yc = 5.5; //Math.sin(alpha)*ca + Math.cos(alpha)*cb; angleDerivative.setCoordinate(Xc, Yc); try { // find quadrant to use double p = Math.atan2(Yc, Xc); if (p < 0) p += twopi; p -= alpha; final double end; final double halfpi = 0.5 * Math.PI; p /= halfpi; end = Math.ceil(p) * halfpi; final double angle = solver.solve(100, angleDerivative, end - halfpi, end); // final double cos = Math.cos(angle); // final double sin = Math.sin(angle); Assert.assertEquals("Angle found is not close enough", 1.930, angle, 0.001); // double dx = a*cos + Xc; // double dy = b*sin + Yc; // // System.out.println("Bracket angle = " + Math.ceil(p)); // System.out.println("Delta angle = " + 180.*angle/Math.PI); // System.out.println(dx + ", " + dy); } catch (TooManyEvaluationsException e) { // TODO System.err.println(e); } catch (MathIllegalArgumentException e) { // TODO System.err.println(e); } }
From source file:edu.mit.fss.tutorial.part2.MobileElement.java
@Override public double getLatitude() { return Math.toDegrees(Math.atan2(position.getZ(), position.getX())); }
From source file:demo.support.NavUtils.java
/** * Returns bearing of position 2 from position 1. * @param pt1//from w ww . j a v a 2 s .co m * @param pt2 * @return */ public static double getBearing(Point pt1, Point pt2) { double longitude1 = pt1.getLongitude(); double longitude2 = pt2.getLongitude(); double latitude1 = Math.toRadians(pt1.getLatitude()); double latitude2 = Math.toRadians(pt2.getLatitude()); double longDiff = Math.toRadians(longitude2 - longitude1); double y = Math.sin(longDiff) * Math.cos(latitude2); double x = Math.cos(latitude1) * Math.sin(latitude2) - Math.sin(latitude1) * Math.cos(latitude2) * Math.cos(longDiff); return (Math.toDegrees(Math.atan2(y, x)) + 360) % 360; }
From source file:org.renjin.primitives.MathExt.java
@Deferrable @Internal//from w w w. j a v a 2 s . c o m @DataParallel public static double atan2(double y, double x) { return (Math.atan2(y, x)); }
From source file:it.inserpio.mapillary.gopro.importer.matcher.Image2GeoMatcher.java
/** * Determine GPSImgDirection/*from ww w.j av a2 s . com*/ * * @param dateTimePoint1 * @param dateTimePoint2 * @return */ public static double computeGPSImgDirection(GPXDateTimePoint dateTimePoint1, GPXDateTimePoint dateTimePoint2) { double deltaY = dateTimePoint1.getLatitude() - dateTimePoint2.getLatitude(); double deltaX = dateTimePoint1.getLongitude() - dateTimePoint2.getLongitude(); double degrees = Math.toDegrees(Math.atan2(deltaY, deltaX)); if (degrees < 0) { degrees = 360 + degrees; } return degrees; }
From source file:uk.ac.diamond.scisoft.analysis.diffraction.powder.PixelIntegrationUtils.java
public static Dataset generateAzimuthalArray(double[] beamCentre, int[] shape, boolean radians) { Dataset out = DatasetFactory.zeros(shape, Dataset.FLOAT64); PositionIterator iter = out.getPositionIterator(); int[] pos = iter.getPos(); //+0.5 for centre of pixel while (iter.hasNext()) { double val = Math.atan2(pos[0] + 0.5 - beamCentre[1], pos[1] + 0.5 - beamCentre[0]); if (radians) out.set(val, pos); else//ww w .ja va2s .c o m out.set(Math.toDegrees(val), pos); } return out; }
From source file:webservice.ImportantPlacesWorker.java
private String calculateSpeed(long t1, double lat1, double lng1, long t2, double lat2, double lng2) { int R = 6371000; // meters double dLat = Math.toRadians(lat2 - lat1); double dLon = Math.toRadians(lng2 - lng1); lat1 = Math.toRadians(lat1);/* www .ja v a2 s. c o 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.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double distance = R * c; double speed = Math.round((distance / (t2 - t1)) * 3.6); if (0 <= speed && speed < 5) { return "0-5"; } else if (5 <= speed && speed < 15) { return "5-15"; } else if (15 <= speed && speed < 50) { return "15-50"; } else if (50 <= speed && speed < 120) { return "50-120"; } else { return "120<=x"; } }
From source file:org.gearvrf.keyboard.util.Util.java
public static float getYRotationAngle(GVRSceneObject rotatingObject, GVRTransform targetObject) { return (float) Math .toDegrees(Math.atan2(targetObject.getPositionX() - rotatingObject.getTransform().getPositionX(), targetObject.getPositionZ() - rotatingObject.getTransform().getPositionZ())); }