Math.atan2()

JavaScript 1.0+, ECMAScript 1.0+, Jscript 3.0+ Nav2+, NES2+, IE4+ Syntax

							math.atan2(num1, num2)
						

Description

The atan2() method of the Math object is used to calculate the arctangent of the quotient of its parameters. It returns a numeric value between –PI and PI representing the angle theta of an (x,y) point.

Example

Listing 6.155 shows an example how the atan2() method is used. The two inputs are taken and stored in variables, inputNum1 and inputNum2. The atan2() method is then called using the user input, and the result is stored in the variable result.

Listing 6.155 Example of the atan2() Method
 <html> <body> <script language="JavaScript"> <!–– Hide // function calculates the arctangent of the // quotient of the two ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.