Method

# ATan2

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Returns the arctangent of the point whose coordinates are *x* and *y*. The arctangent is the angle from the x-axis to a line drawn through the origin (0,0) and a point with coordinates *x*, *y*.

## Usage

``` xojo
result = ATan2(y, x)
```

| Part   | Type                             | Description                                    |
|--------|----------------------------------|------------------------------------------------|
| result | `Double</api/data_types/double>` | Arctangent of the point (*y*, *x*) in radians. |
| y      | `Double</api/data_types/double>` | y coordinate of the point.                     |
| x      | `Double</api/data_types/double>` | x coordinate of the point.                     |

## Notes

The result is expressed in radians. To convert it to degrees, multiply it by 180/PI.

The converse operations are done with `Cos</api/math/cos>` and `Sin</api/math/sin>`. That is, if you have an angle and want to find an *x*, *y* pair along the line described by 0,0 and x,y, you can do so with:

``` xojo
x = Cos(angle) * radius
y = Sin(angle) * radius
```

## Sample code

This example uses the <span class="title-ref">ATan2</span> function to return the arctangent of a point directly above the origin.

``` xojo
Var d As Double
Const Pi = 3.14159265358979323846264338327950
d = ATan2(1, 0) ' returns 1.57
d = ATan2(1, 0) * 180 / PI ' returns 90
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Atan</api/math/atan>`, `Tan</api/math/tan>` functions

</div>
