Package java.lang
Class Math
Public Method atan2
static float atan2(float a, float b)
_INSERT_METHOD_SIGNATURE_HERE_
Description:
Converts rectangular coordinates (a, b) to polar (r, theta) coordinates.
This method computes the phase theta by computing an arc tangent of a/b in the range of -pi to pi.
Note
- If either argument is NaN, then the result is NaN.
- If the first argument is positive zero and the second argument is positive, or the first argument is positive and finite and the second argument is positive infinity, then the result is positive zero.
- If the first argument is negative zero and the second argument is positive, or the first argument is negative and finite and the second argument is positive infinity, then the result is negative zero.
- If the first argument is positive zero and the second argument is negative, or the first argument is positive and finite and the second argument is negative infinity, then the result is the float value closest to pi.
- If the first argument is negative zero and the second argument is negative, or the first argument is negative and finite and the second argument is negative infinity, then the result is the float value closest to -pi.
- If the first argument is positive and the second argument is positive zero or negative zero, or the first argument is positive infinity and the second argument is finite, then the result is the float value closest to pi/2.
- If the first argument is negative and the second argument is positive zero or negative zero, or the first argument is negative infinity and the second argument is finite, then the result is the float value closest to -pi/2.
- If both arguments are positive infinity, then the result is the float value closest to pi/4.
- If the first argument is positive infinity and the second argument is negative infinity, then the result is the float value closest to 3*pi/4.
- If the first argument is negative infinity and the second argument is positive infinity, then the result is the float value closest to -pi/4.
- If both arguments are negative infinity, then the result is the float value closest to -3*pi/4.
Draw.writeText("atan2: " + Math.atan2(0.02344f), 0.45632f));
The example above draws the calculated value to the screen.