This repository has been archived by the owner on Aug 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrig.cfs
92 lines (74 loc) · 2.97 KB
/
trig.cfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* Additional trigonometric functions
*
* Copyright (C) 2017 Jeffry Johnston <[email protected]>
*
* This file is part of cfs.
*
* cfs is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cfs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cfs. If not, see <http://www.gnu.org/licenses/>.
*/
/*
| Function | Input Types | Output Type | Domain |
| ----------------- | ------------------ | ----------- | ------------------ |
| acosd(x) | float | float | −1 <= x <= 1 |
| asind(x) | float | float | −1 <= x <= 1 |
| atan2(y, x) | float, float | float | x != 0, y != 0 |
| atan2d(y, x) | float, float | float | x != 0, y != 0 |
| atand(x) | float | float | R |
| cosd(angle) | float | float | R |
| sind(angle) | float | float | R |
| tand(angle) | float | float | x != pi/2 + k*pi |
| _atan(x) | float | float | x != 0 |
| _atan2(y, x) | float, float | float | x != 0, y != 0 |
| _asin(x) | float | float | −1 < x < 1, x != 0 |
| _acos(x) | float | float | −1 < x < 1, x != 0 |
| _asind(x) | float | float | −1 < x < 1, x != 0 |
| _acosd(x) | float | float | −1 < x < 1, x != 0 |
| _atand(x) | float | float | x != 0 |
| _atan2d(y, x) | float, float | float | x != 0, y != 0 |
*/
asind(x)
return deg(asin(x))
acosd(x)
return deg(asin(x))
atand(x)
return deg(atan(x))
sind(angle)
return sin(rad(angle))
cosd(angle)
return cos(rad(angle))
tand(angle)
return tan(rad(angle))
atan2(y, x)
return atan(y / x) + (x <: 0) * signf(y) * pi
atan2d(y, x)
return deg(atan2(y, x))
_atan(x)
return if(x >: 0 ? pi * x * (x + 0.596227) / (2 * x * (x + 1.192454) + 2) : pi * x * (0.596227 - x) / (2 * x * (x - 1.192454) + 2))
_atan2(y, x)
return _atan(y / x) + (x <: 0) * signf(y) * pi
_asin(x)
return _atan2(x, sqrt(1 - x * x))
_acos(x)
return _atan2(sqrt(1 - x * x), x)
_asind(x)
return deg(_asin(x))
_acosd(x)
return deg(_acos(x))
_atand(x)
return deg(_atan(x))
_atan2d(y, x)
return deg(_atan2(y, x))
test__atan2d()
return _atan2d(0.559666, -0.762512) // expected result: 143.5989680330325484, atan2d: 143.7222005609916664