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
The Ektron Intranet
lets you do everything you need to do on your corporate intranet and everything you want to do... all with just one application.
What can you do with the Ektron Intranet? |

|
Navigate through content, documents, assets, colleagues and workgroups quickly and intuitively with enterprise search |

|
Communicate with friends and colleagues with forums, message boards and corporate blogging using the new Social Networking Platform |

|
Promote collaboration among coworkers in your organization through project workspaces where others can efficiently find information and work together |

|
Personalize your company profile by bookmarking and organizing favorite content, uploading assets, posting photos, blogging, and more |

|
Interact with features like tagging, flagging, wikis and ratings found in the Web 2.0 Toolbox |
 |
Author/edit content, manage navigation, menus, audit trails, workflow and approvals with the best in breed Content Management |
|
|
|
|
See why there are 20,000+ Ektron integrations worldwide. Request an
INSTANT DEMO or download a
FREE TRIAL today. |
|