/** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis * (typically counter-clockwise) and between 0 and 360. */ public float angle () { float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; }
/** @return the angle in radians of this vector (point) relative to the x-axis. Angles are towards the positive y-axis. * (typically counter-clockwise) */ public float angleRad () { return (float)Math.atan2(y, x); }
/** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis * (typically counter-clockwise) and between 0 and 360. */ public float angle () { float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; }
/** @return the angle in radians of this vector (point) relative to the x-axis. Angles are towards the positive y-axis. * (typically counter-clockwise) */ public float angleRad () { return (float)Math.atan2(y, x); }
public float getRotation () { return (float)Math.atan2(vals[SIN], vals[COS]); } /** @return A vector 2 pointing to where the body is facing */
public float getRotation () { return (float)Math.atan2(vals[SIN], vals[COS]); } /** @return A vector 2 pointing to where the body is facing */
public float getRotationRad () { return (float)Math.atan2(val[M10], val[M00]); }
public float getRotationRad () { return (float)Math.atan2(val[M10], val[M00]); }
public float getRotation () { return MathUtils.radiansToDegrees * (float)Math.atan2(val[M10], val[M00]); }
public float getRotation () { return MathUtils.radiansToDegrees * (float)Math.atan2(val[M10], val[M00]); }
public static double atan2(double y, double x) { return Math.atan2(y,x); }
var rad = function(x) { return x * Math.PI / 180; }; var getDistance = function(p1, p2) { var R = 6378137; // Earth’s mean radius in meter var dLat = rad(p2.lat() - p1.lat()); var dLong = rad(p2.lng() - p1.lng()); var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * Math.sin(dLong / 2) * Math.sin(dLong / 2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); var d = R * c; return d; // returns the distance in meter };
public double distance(double latitude2, double longitude2) { double radianLatitude2 = toRadians(latitude2); double sin2 = sin(radianLatitude2); double cos2 = cos(radianLatitude2); double deltaLongitude = radianLongitude - toRadians(longitude2); double cosDeltaLongitude = cos(deltaLongitude); double t1 = cos2 * sin(deltaLongitude); double t2 = cosLatitude * sin2 - sinLatitude * cos2 * cosDeltaLongitude; double t3 = sinLatitude * sin2 + cosLatitude * cos2 * cosDeltaLongitude; return atan2(sqrt(t1 * t1 + t2 * t2), t3) * EARTH_RADIUS_KM; } }
@Override protected ExprEval eval(double y, double x) { return ExprEval.of(Math.atan2(y, x)); } }
/** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the positive y-axis * (typically counter-clockwise.) between -180 and +180 */ public float angle (Vector2 reference) { return (float)Math.atan2(crs(reference), dot(reference)) * MathUtils.radiansToDegrees; }
/** @return the angle in radians of this vector (point) relative to the given vector. Angles are towards the positive y-axis. * (typically counter-clockwise.) */ public float angleRad (Vector2 reference) { return (float)Math.atan2(crs(reference), dot(reference)); }
/** @return the angle in radians of this vector (point) relative to the given vector. Angles are towards the positive y-axis. * (typically counter-clockwise.) */ public float angleRad (Vector2 reference) { return (float)Math.atan2(crs(reference), dot(reference)); }
/** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the positive y-axis * (typically counter-clockwise.) between -180 and +180 */ public float angle (Vector2 reference) { return (float)Math.atan2(crs(reference), dot(reference)) * MathUtils.radiansToDegrees; }
@Description("arc tangent of given fraction") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double atan2(@SqlType(StandardTypes.DOUBLE) double num1, @SqlType(StandardTypes.DOUBLE) double num2) { return Math.atan2(num1, num2); }
@Test public void testAtan2() { for (double doubleValue : DOUBLE_VALUES) { assertFunction("atan2(" + doubleValue + ", " + doubleValue + ")", DOUBLE, Math.atan2(doubleValue, doubleValue)); assertFunction("atan2(REAL '" + (float) doubleValue + "', REAL '" + (float) doubleValue + "')", DOUBLE, Math.atan2((float) doubleValue, (float) doubleValue)); } assertFunction("atan2(NULL, NULL)", DOUBLE, null); assertFunction("atan2(1.0E0, NULL)", DOUBLE, null); assertFunction("atan2(NULL, 1.0E0)", DOUBLE, null); }