Garry's Mod Wiki

math.atan2

number math.atan2( number y, number x )

Description

functions like math.atan(y / x), except it also takes into account the quadrant of the angle and so doesn't have a limited range of output.

The Y argument comes first!

Arguments

1 number y
Y coordinate.
2 number x
X coordinate.

Returns

1 number
The angle of the line from (0, 0) to (x, y) in radians, in the range -pi to pi.

Example

atan( 1 ) and atan2( 1, 1 ) are both math.pi / 4

atan2( -1, -1 ) equals to ( (-3) * math.pi ) / 4

print( atan( 1 ) ) print( ata2( 1, 1 ) ) print( atan2( -1, -1 ) )
Output: 0.7853981633974483

0.7853981633974483

-2.356194490192345

Page Links


Special Pages


Wikis

?

Render Time: 59ms

DB GetPage 8
Generate Html 10
SaveChanges 19
Render Body 0
Render Sidebar 19