
Math.atan2() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
603
Returns
The angle, in radians, whose tangent is x.
Description
The arc tangent function (sometimes written as tan
-1
) is the inverse of the tangent func-
tion. It returns the angle whose tangent has the specified value, in radians. The return value
is in the range of –π/2 to π/2.
Example
trace (Math.atan(1.0)); // Displays: 0.78539...
trace (Math.atan(0.0)); // Displays: 0
trace (Math.atan(-Infinity)); // Displays: -1.5707... (i.e., -pi/2)
See Also
Math.acos( ), Math.asin( ), Math.tan( )
Math.atan2() Method
determine an angle based on a point
Flash 5; may be used when exporting Flash 4 movies
Math.atan2(y, x)
Arguments
y The y-coordinate of the point.
x The x-coordinate of the point.
Returns
The angle, in radians, of the point (x, y) from the center of a circle, measured counterclock-
wise from the circle’s positive horizontal axis (i.e., the X-axis). Ranges from π to -π.
(Negative values indicate angles below the X-axis).
Description
The atan2( ) method, like atan( ), performs an arc tangent calculation but uses x- and y-
coordinates, rather than their ratio, as arguments. That is, calculating an arc tangent with
atan2( ) as:
Math.atan2(9, 3); // Yields 1.24904577239825
is equivalent to calculating the arc tangent with atan( ), using the ratio ...