Jump to content

Atan2()

From OpenBOR

Accepts Y and X components and returns their directional angle in degrees using the C atan2() function: atan2(y, x) * 180 / π.

float y = -1.0;
float x = 1.0;

float result = atan2(y, x);

// result = -45.0


Unlike atan(), the function uses the signs of both components to determine the correct quadrant. The result ranges from -180 through 180 degrees.

For a result normalized to the range of 0 through less than 360, use angle().