atan function and atan2 function

Source: Internet
Author: User

Atan function: Portal.

atan2 function: Portal.

Atan and atan2 are all seeking the inverse tangent function, such as: There are two points (x1,y1), and Point (X2,y2);

Then the angle calculation method of the slope formed by these two points is:

float angle = Atan ((y2-y1)/(X2-X1));

Or

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

The range of domains is different, atan:+-π/2,atan2:+-π

Atan and atan2 differences:

1: The parameters are filled in different ways;

The advantage of 2:atan2 is that if x2-x1 equals 0 can still be calculated, but the Atan function will cause the program error;

It is recommended to use the ATAN2 function.

atan function and atan2 function

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.