2025-01-30 13:58:20 +01:00

62 lines
1.6 KiB
Markdown

---
layout: default
---
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
<h1 id="function-atan2">Function atan2 <a href="#function-atan2" title="Permalink">#</a></h1>
Calculate the inverse tangent function with two arguments, y/x.
By providing two arguments, the right quadrant of the computed angle can be
determined.
For matrices, the function is evaluated element wise.
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.atan2(y, x)
```
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`y` | number &#124; Array &#124; Matrix | Second dimension
`x` | number &#124; Array &#124; Matrix | First dimension
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
number &#124; Array &#124; Matrix | Four-quadrant inverse tangent
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
Type | Description
---- | -----------
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
```js
math.atan2(2, 2) / math.pi // returns number 0.25
const angle = math.unit(60, 'deg')
const x = math.cos(angle)
const y = math.sin(angle)
math.atan2(y, x) * 180 / math.pi // returns 60
math.atan(2) // returns number 1.1071487177940904
```
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
[tan](tan.html),
[atan](atan.html),
[sin](sin.html),
[cos](cos.html)