https://github.com/semibran/radians
:pizza: Convert between degrees and radians
https://github.com/semibran/radians
convert degrees math radians trigonometry
Last synced: 6 months ago
JSON representation
:pizza: Convert between degrees and radians
- Host: GitHub
- URL: https://github.com/semibran/radians
- Owner: semibran
- License: mit
- Created: 2017-05-23T21:39:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-27T20:48:30.000Z (over 8 years ago)
- Last Synced: 2025-02-12T18:59:21.628Z (8 months ago)
- Topics: convert, degrees, math, radians, trigonometry
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# radians
In JavaScript, methods like `Math.sin`, `Math.atan2`, and `CanvasRenderingContext2D.arc` use [radians](https://en.wikipedia.org/wiki/Radian) instead of degrees. It may be helpful to have functions to convert between the two to reduce instances of `Math.PI / 180` in your code, as they may appear misleading.
The API for this module is based off of [Elm](http://elm-lang.org)'s [built-in angle conversion functions](http://package.elm-lang.org/packages/elm-lang/core/5.1.1/Basics#angle-conversions).
## usage
[](https://www.npmjs.com/package/radians)
```js
> const { degrees, radians } = require('radians')
> var angle = 45
> radians(degrees(angle)) === angle
true
```### `degrees(degrees)`
Converts `degrees` to its corresponding value in radians.
```js
> degrees(30)
0.5235987755982988
```### `radians(radians)`
Converts `radians` to its corresponding value in degrees.
```js
> radians(0.5235987755982988)
29.999999999999996> radians(0.5235987755982989)
30.000000000000004
```## see also
- [`scijs/almost-equal`](https://github.com/scijs/almost-equal) - determine if two floats are nearly equal## license
[MIT](https://opensource.org/licenses/MIT) © [Brandon Semilla](https://git.io/semibran)