MathArctan2

Return the angle (in radians) whose tangent is the quotient of two specified numbers.

double MathArctan2(
 double y     // The y coordinate of a point
 double x     // The x coordinate of a point
  );

Parameters

y

[in]  Y coordinate value.

x

[in]  X coordinate value.

Return Value

MathArctan2 returns an angle, θ, within the range from -π to π radians, so that MathTan(θ)=y/x.

Please note as follows:

  • For (x, y) in quadrant 1, 0< θ < π/2
  • For (x, y) in quadrant 2, π/2< θ ≤ π
  • For (x, y) in quadrant 3, -π < θ < -π/2
  • For (x, y) in quadrant 4, -π/2 < θ < 0

For points on the boundaries of the quadrants, the return value is the following:

  • If y is 0 and x is not negative, θ = 0.
  • If y is 0 and x is negative, θ = π.
  • If y is positive and x is 0, θ = π/2.
  • If y is negative and x is 0, θ = -π/2.
  • If y is 0 and x is 0, θ = 0.

Note

Instead of the MathArctan2() function, you can use the atan2() function.