Jump to content

Angle()

From OpenBOR

Accepts Y and X components and returns their directional angle in degrees. The function calculates atan2(y, x), converts the result from radians to degrees, and normalizes it to the range of 0 through less than 360.

float y = 1.0;
float x = 1.0;

float result = angle(y, x);

// result = 45.0

The resulting directions are:

  • 0 degrees - Positive X.
  • 90 degrees - Positive Y.
  • 180 degrees - Negative X.
  • 270 degrees - Negative Y.

When used with screen coordinates, where positive Y points downward, the resulting angle increases clockwise.