Function in prelude::math auto-imported

atan2

fn atan2(float y, float x) -> float
Source: compiler/src/builtin_docs/prelude/math.hy

Returns the angle of the point (x, y) from the positive x axis, in radians in -pi..=pi.

Note the argument order: y first, then x. Unlike atan(y / x) it uses the signs of both arguments to pick the right quadrant.

Parameters#

NameType
yfloat
xfloat

Returns#

float

Examples#

use tests::assert;
let pi = 3.141592653589793;
assert!(atan2(0.0, 1.0) == 0.0);
assert!(atan2(1.0, 0.0) == pi / 2.0);
assert!(atan2(0.0, -1.0) == pi);

See also#

  • sin: Returns the sine of x (in radians).
  • cos: Returns the cosine of x (in radians).
  • tan: Returns the tangent of x (in radians).
  • sqrt: Returns the square root of x.
  • floor: Returns the largest whole number less than or equal to x, as a float.
  • ceil: Returns the smallest whole number greater than or equal to x, as a float.
  • exp: Returns e raised to the power x.
  • ln: Returns the natural logarithm of x.
↑ ↓ navigate ↵ open