Differences between the atan function and the atan2 Function

Source: Internet
Author: User
Both atan and atan2 are antitangent functions, such as two vertices (x1, y1) and point (x2, y2 ); then the two points form the slope angle calculation method is: floatangleatan (y2-y1) (x2-x1); or floatangleatan2 (y2-y1, x2-x1); atan and atan2 difference: 1: parameter filling method not

Both atan and atan2 are antitangent functions, such as two vertices (x1, y1) and point (x2, y2 ); then the two points form the slope of the angle calculation method is: floatangle = atan (y2-y1)/(x2-x1); or float angle = atan2 (y2-y1, x2-x1 ); differences between atan and atan2: 1: The parameter filling method is not

Both atan and atan2 are antitangent functions, such as two vertices (x1, y1) and point (x2, y2 );

The Angle Calculation Method for the slope formed by these two points is:

Float angle = atan (y2-y1)/(x2-x1 ));

Or

Float angle = atan2 (y2-y1, x2-x1 );

Differences between atan and atan2:

1: parameters are entered in different ways;

2: atan2 advantage is that if the x2-x1 is equal to 0 can still be calculated, but the atan function will cause program errors;

Conclusion: atan and atan2 functions are recommended;

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.