Tabnine Logo
Math.atan2
Code IndexAdd Tabnine to your IDE (free)

How to use
atan2
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.atan2 (Showing top 20 results out of 8,064)

origin: libgdx/libgdx

/** @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;
}
origin: libgdx/libgdx

/** @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);
}
origin: libgdx/libgdx

/** @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;
}
origin: libgdx/libgdx

/** @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);
}
origin: libgdx/libgdx

public float getRotation () {
  return (float)Math.atan2(vals[SIN], vals[COS]);
}
/** @return A vector 2 pointing to where the body is facing */
origin: libgdx/libgdx

public float getRotation () {
  return (float)Math.atan2(vals[SIN], vals[COS]);
}
/** @return A vector 2 pointing to where the body is facing */
origin: libgdx/libgdx

public float getRotationRad () {
  return (float)Math.atan2(val[M10], val[M00]);
}
origin: libgdx/libgdx

public float getRotationRad () {
  return (float)Math.atan2(val[M10], val[M00]);
}
origin: libgdx/libgdx

public float getRotation () {
  return MathUtils.radiansToDegrees * (float)Math.atan2(val[M10], val[M00]);
}
origin: libgdx/libgdx

public float getRotation () {
  return MathUtils.radiansToDegrees * (float)Math.atan2(val[M10], val[M00]);
}
origin: libgdx/libgdx

public static double atan2(double y, double x) {
 return Math.atan2(y,x);
}

origin: stackoverflow.com

 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
};
origin: prestodb/presto

  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;
  }
}
origin: apache/incubator-druid

 @Override
 protected ExprEval eval(double y, double x)
 {
  return ExprEval.of(Math.atan2(y, x));
 }
}
origin: libgdx/libgdx

/** @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;
}
origin: libgdx/libgdx

/** @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));
}
origin: libgdx/libgdx

/** @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));
}
origin: libgdx/libgdx

/** @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;
}
origin: prestodb/presto

@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);
}
origin: prestodb/presto

@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);
}
java.langMathatan2

Javadoc

Returns the closest double approximation of the arc tangent of y/x within the range [-pi..pi]. This is the angle of the polar representation of the rectangular coordinates (x,y). The returned result is within 2 ulps (units in the last place) of the real result.

Special cases:

  • atan2((anything), NaN ) = NaN;
  • atan2(NaN , (anything) ) = NaN;
  • atan2(+0.0, +(anything but NaN)) = +0.0
  • atan2(-0.0, +(anything but NaN)) = -0.0
  • atan2(+0.0, -(anything but NaN)) = +pi
  • atan2(-0.0, -(anything but NaN)) = -pi
  • atan2(+(anything but 0 and NaN), 0) = +pi/2
  • atan2(-(anything but 0 and NaN), 0) = -pi/2
  • atan2(+(anything but infinity and NaN), +infinity) = +0.0
  • atan2(-(anything but infinity and NaN), +infinity) = -0.0
  • atan2(+(anything but infinity and NaN), -infinity) = +pi
  • atan2(-(anything but infinity and NaN), -infinity) = -pi
  • atan2(+infinity, +infinity ) = +pi/4
  • atan2(-infinity, +infinity ) = -pi/4
  • atan2(+infinity, -infinity ) = +3pi/4
  • atan2(-infinity, -infinity ) = -3pi/4
  • atan2(+infinity, (anything but,0, NaN, and infinity)) = +pi/2
  • atan2(-infinity, (anything but,0, NaN, and infinity)) = -pi/2

Popular methods of Math

  • min
    Returns the smaller of two long values. That is, the result is the argument closer to the value of L
  • max
    Returns the greater of two long values. That is, the result is the argument closer to the value of L
  • abs
    Returns the absolute value of a long value. If the argument is not negative, the argument is returne
  • round
    Returns the closest int to the argument, with ties rounding up. Special cases: * If the argument is
  • pow
    Returns the value of the first argument raised to the power of the second argument. Special cases: *
  • sqrt
    Returns the correctly rounded positive square root of a double value. Special cases: * If the argume
  • ceil
    Returns the smallest (closest to negative infinity) double value that is greater than or equal to th
  • floor
    Returns the largest (closest to positive infinity) double value that is less than or equal to the ar
  • random
    Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returne
  • sin
    Returns the trigonometric sine of an angle. Special cases: * If the argument is NaN or an infinit
  • cos
    Returns the trigonometric cosine of an angle. Special cases: * If the argument is NaN or an infin
  • log
    Returns the natural logarithm (base e) of a doublevalue. Special cases: * If the argument is NaN
  • cos,
  • log,
  • exp,
  • toRadians,
  • log10,
  • acos,
  • tan,
  • toDegrees,
  • atan

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • onCreateOptionsMenu (Activity)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • IsNull (org.hamcrest.core)
    Is the value null?
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now