atan2
host callCapy
function atan2(y : f32, x : f32) f32 function atan2(y : f64, x : f64) f64
Description
atan2() handles every quadrant and x == 0.0, unlike a plain arctangent of y / x. It is the function for converting a direction vector to a heading. Degrees are atan2(y, x) * 180.0 / 3.141592653589793.
Parameters
y : the vertical component
x : the horizontal component, in the same type
Return Values
The angle in radians between the positive x axis and the point (x, y), from -π to π.
Example
Capy
print(atan2(1.0, 1.0), " ", atan2(1.0, 0.0), " ", atan2(0.0, -1.0), "\n")
Output
0.78539816339744828 1.5707963267948966 3.1415926535897931