1 |
|
2 |
|
3 | # Function atan2
|
4 |
|
5 | Calculate the inverse tangent function with two arguments, y/x.
|
6 | By providing two arguments, the right quadrant of the computed angle can be
|
7 | determined.
|
8 |
|
9 | For matrices, the function is evaluated element wise.
|
10 |
|
11 |
|
12 | ## Syntax
|
13 |
|
14 | ```js
|
15 | math.atan2(y, x)
|
16 | ```
|
17 |
|
18 | ### Parameters
|
19 |
|
20 | Parameter | Type | Description
|
21 | --------- | ---- | -----------
|
22 | `y` | number | Array | Matrix | Second dimension
|
23 | `x` | number | Array | Matrix | First dimension
|
24 |
|
25 | ### Returns
|
26 |
|
27 | Type | Description
|
28 | ---- | -----------
|
29 | number | Array | Matrix | Four-quadrant inverse tangent
|
30 |
|
31 |
|
32 | ## Examples
|
33 |
|
34 | ```js
|
35 | math.atan2(2, 2) / math.pi // returns number 0.25
|
36 |
|
37 | const angle = math.unit(60, 'deg') // returns Unit 60 deg
|
38 | const x = math.cos(angle)
|
39 | const y = math.sin(angle)
|
40 |
|
41 | math.atan(2) // returns Complex 1.5707963267948966 -1.3169578969248166 i
|
42 | ```
|
43 |
|
44 |
|
45 | ## See also
|
46 |
|
47 | [tan](tan.md),
|
48 | [atan](atan.md),
|
49 | [sin](sin.md),
|
50 | [cos](cos.md)
|