JavaScript atan() and atan2() Methods
Complete Math Object Reference
Definition and Usage
The atan() method returns the arctangent of a number as a numeric
value between -PI/2 and PI/2 radians.
The atan2() method returns the angle theta of an (x,y) point as a numeric
value between -PI and PI radians.
Syntax
Math.atan(x)
Math.atan2(x,y)
|
Parameter |
Description |
x |
Required. A number |
y |
Required. A number |
Example 1 - atan()
The following example returns the arctangent of different numbers with
the atan() method:
<script type="text/javascript">
document.write(Math.atan(0.50) + "<br />");
document.write(Math.atan(-0.50) + "<br />");
document.write(Math.atan(5) + "<br />");
document.write(Math.atan(10) + "<br />");
document.write(Math.atan(-5) + "<br />");
document.write(Math.atan(-10));
</script>
|
The output of the code above will be:
0.4636476090008061
-0.4636476090008061
1.373400766945016
1.4711276743037347
-1.373400766945016
-1.4711276743037347
|
Example 2 - atan2()
The following example returns the angle theta of different (x,y) points with
the atan2() method:
<script type="text/javascript">
document.write(Math.atan2(0.50,0.50) + "<br />");
document.write(Math.atan2(-0.50,-0.50) + "<br />");
document.write(Math.atan2(5,5) + "<br />");
document.write(Math.atan2(10,20) + "<br />");
document.write(Math.atan2(-5,-5) + "<br />");
document.write(Math.atan2(-10,10));
</script>
|
The output of the code above will be:
0.7853981633974483
-2.356194490192345
0.7853981633974483
0.4636476090008061
-2.356194490192345
-0.7853981633974483
|
Try-It-Yourself Demos
atan()
How to use atan() to return the arctangent of different numbers.
atan2()
How to use atan2() to return the angle theta of different (x,y) points.
Complete Math Object Reference
Learn how your website performs under various load conditions
|
|
WAPT
is a load, stress and performance testing tool for websites and web-based applications.
In contrast to "800-pound gorilla" load testing tools, it is designed to minimize the learning
curve and give you an ability to create a heavy load from a regular workstation.
WAPT is able to generate up to 3000 simultaneously acting virtual users using standard hardware configuration.
Virtual users in each profile are fully customizable. Basic and NTLM authentication methods are supported.
Graphs and reports are shown in real-time at different levels of detail, thus helping to manage the testing process.
Download the free 30-day trial!
|
|