Concept

Atan2

Summary
In computing and mathematics, the function atan2 is the 2-argument arctangent. By definition, is the angle measure (in radians, with ) between the positive -axis and the ray from the origin to the point in the Cartesian plane. Equivalently, is the argument (also called phase or angle) of the complex number The function first appeared in the programming language Fortran in 1961. It was originally intended to return a correct and unambiguous value for the angle θ in converting from Cartesian coordinates (x, y) to polar coordinates (r, θ). If and , then and If x > 0, the desired angle measure is However, when x < 0, the angle is diametrically opposite the desired angle, and ±pi (a half turn) must be added to place the point in the correct quadrant. Using the function does away with this correction, simplifying code and mathematical formulas. The ordinary single-argument arctangent function only returns angle measures in the interval and when invoking it to find the angle measure between the x-axis and an arbitrary vector in the Cartesian plane, there is no simple way to indicate a direction in the left half-plane (that is, a point with ). Diametrically opposite angle measures have the same tangent because so the tangent is not in itself sufficient to uniquely specify an angle. To determine an angle measure using the arctangent function given a point or vector mathematical formulas or computer code must handle multiple cases; at least one for positive values of and one for negative values of and sometimes additional cases when is negative or one coordinate is zero. Finding angle measures and converting Cartesian to polar coordinates are common in scientific computing, and this code is redundant and error-prone. To remedy this, computer programming languages introduced the atan2 function, at least as early as the Fortran IV language of the 1960s. The quantity atan2(y,x) is the angle measure between the x-axis and a ray from the origin to a point (x, y) anywhere in the Cartesian plane.
About this result
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.