The Math.atan2 () method in JavaScript uses a detailed knowledge of the basics

Source: Internet
Author: User

This method returns the inverse tangent of its parameter quotient. The ATAN2 method returns the value between the angle theta of the-pi and Pi (x,y) points.
Grammar

Math.atan2 (x, y);

The following are the details of the parameters:

    • X and Y: a number.

return value:

Returns the tangent value of a number of radians

Math.atan2 (±,-0) returns±pi.
Math.atan2 (±, +0) returns±0.
Math.atan2 (±, x) returns±pi for x < 0.
Math.atan2 (±, x) returns±0 for x > 0.
Math.atan2 (y,±0) returns-pi/2 for y > 0.
Math.atan2 (±y,-infinity) returns±pi for finite y > 0.
Math.atan2 (±y, +infinity) returns±0 for finite y > 0.
Math.atan2 (±infinity, +x) Returns±pi/2 for finite x.
Math.atan2 (±infinity,-infinity) Returns±3*pi/4.
Math.atan2 (±infinity, +infinity) Returns±pi/4.

Example:

 
 

This will produce the following results:

The value:1.4056476493802698
Second test value:0.16514867741462683
Third Test value:3.1415926535897
Fourth Test value:2.356194490192345 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.