Skip to content

Commit 10ce0f5

Browse files
committed
Angle conversions
1 parent a0ea3b3 commit 10ce0f5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Math/Trig.scope

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import "Math/Core";
22

33
namespace Math;
44

5+
/%
6+
The result of @"PI" / 180.
7+
%/
8+
const dec DEG_TO_RAD = 0.017453292519943;
9+
510
/%
611
@approx: This function uses the Taylor series expansion of sine. This function
712
is not 100% accurate but will provide a very good approximation.
@@ -119,4 +124,18 @@ Please note that an input of @"PI" **will not** return *exactly* `0.0`.
119124
%/
120125
func dec cot(dec x) {
121126
ret 1.0 / tan(x);
127+
}
128+
129+
/%
130+
Returns @"degrees" converted into radians.
131+
%/
132+
func dec degToRad(dec degrees) {
133+
ret degrees * DEG_TO_RAD;
134+
}
135+
136+
/%
137+
Returns @"radians" converted into degrees.
138+
%/
139+
func dec radToDeg(dec radians) {
140+
ret radians / DEG_TO_RAD;
122141
}

0 commit comments

Comments
 (0)