Given the and coordinates of a point, returns the angle associated with the point in radians. If the point’s -coordinate is negative, meaning that the point is in quadrant or , the function returns a negative angle.

`atan2(y,x)`

Name | Description |
---|---|

y | A number representing the vertical component of a point in the Cartesian Plane |

x | A number representing the horizontal component of a point in the Cartesian Plane |

The improved arctangent function takes in a and coordinate as input and returns the angle associated with the point . For example, given the point as input the function returns the angle of . This is illustrated by figure below.

```
= atan2( 1, 1) = 0.785... // (1/8)*TAU
```

Many programming languages provide both the `tan2`

function and the `atan`

function. The difference between the two functions is the range of possible return values for real number input. The range of is while the range of is . In other words, the `atan`

function returns angles on the right half of the circle and `atan2`

returns angles on the whole circle.

Input | Behavior |
---|---|

Quadrant 1 | Same |

Quadrant 2 | Different |

Quadrant 3 | Different |

Quadrant 4 | Same |

The different behavior is visualized below in the second quadrant when given the same point as input. The `atan2`

function returns the corresponding angle that is greater than a perpendicular while the `atan`

function returns the corresponding angle that is less than a perpendicular angle.

One way to reconcile the difference between the two functions is to extend the input of `atan`

to accept numbers in the complex number system. In this case, the `atan`

function will return angles on the full circle.