Add degreesToRads and radsToDegrees

This commit is contained in:
Angelos Chalaris
2018-02-14 12:24:50 +02:00
parent 566653206b
commit 4590cf2b95
11 changed files with 77 additions and 12 deletions

13
snippets/degreesToRads.md Normal file
View File

@ -0,0 +1,13 @@
### degreesToRads
Converts an angle from degrees to radians.
Use `Math.PI` and the degree to radian formula to convert the angle from degrees to radians.
```js
const degreesToRads = deg => deg * Math.PI / 180.0;
```
```js
degreesToRads(90.0); // ~1.5708
```

13
snippets/radsToDegrees.md Normal file
View File

@ -0,0 +1,13 @@
### radsToDegrees
Converts an angle from radians to degrees.
Use `Math.PI` and the radian to degree formula to convert the angle from radians to degrees.
```js
const radsToDegrees = rad => rad * 180.0 / Math.PI;
```
```js
radsToDegrees(Math.PI / 2); // 90
```