Browse the docs

atan2

Returns the angle of a point from the x axis, in radians, in the right quadrant.

Keyboard Maestro: ATAN2

Details #

atan2(y, x) takes exactly two arguments, y first and then x, and returns an angle in radians from -3.14159 to 3.14159. Unlike atan of a ratio, it uses the signs of both numbers to give the right quadrant.

The angle is measured counterclockwise from the positive x axis. To get degrees, multiply by 180 and divide by 3.14159265.

Parameters #

Takes 2 arguments. {{ atan2(text, b) }}

Examples #

atan2(1, 1)
→ 0.785398
round(atan2(dy, dx) * 180 / 3.14159265, 1)
→ 135
Sample variableValue
dx-1
dy1

Gotchas #

  • Calling it with the wrong number of arguments is an error, for example atan2() takes 2 arguments, got 1.

  • The order is y then x, the reverse of how you might say "x, y".

  • Both arguments must be numbers: atan2() needs a number, got text.