Add Radian.

This commit is contained in:
Oleksii Trekhleb 2018-08-14 22:31:13 +03:00
parent b3315966e5
commit 096d5a8b5b
5 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# Radian
The **radian** (symbol **rad**) is the unit for measuring angles, and is the
standard unit of angular measure used in many areas of mathematics.
The length of an arc of a unit circle is numerically equal to the measurement
in radians of the angle that it subtends; one radian is just under `57.3` degrees.
An arc of a circle with the same length as the radius of that circle subtends an
angle of `1 radian`. The circumference subtends an angle of `2π radians`.
![Radian](https://upload.wikimedia.org/wikipedia/commons/4/4e/Circle_radians.gif)
A complete revolution is 2π radians (shown here with a circle of radius one and
thus circumference `2π`).
![2 pi Radian](https://upload.wikimedia.org/wikipedia/commons/6/67/2pi-unrolled.gif)
**Conversions**
| Radians | Degrees |
| :-----: | :-----: |
| 0 | 0° |
| π/12 | 15° |
| π/6 | 30° |
| π/4 | 45° |
| 1 | 57.3° |
| π/3 | 60° |
| π/2 | 90° |
| π | 180° |
| 2π | 360° |
## References
- [Wikipedia](https://en.wikipedia.org/wiki/Radian)

View File

@ -0,0 +1,12 @@
import degreeToRadian from '../degreeToRadian';
describe('degreeToRadian', () => {
it('should convert degree to radian', () => {
expect(degreeToRadian(0)).toBe(0);
expect(degreeToRadian(45)).toBe(Math.PI / 4);
expect(degreeToRadian(90)).toBe(Math.PI / 2);
expect(degreeToRadian(180)).toBe(Math.PI);
expect(degreeToRadian(270)).toBe(3 * Math.PI / 2);
expect(degreeToRadian(360)).toBe(2 * Math.PI);
});
});

View File

@ -0,0 +1,12 @@
import radianToDegree from '../radianToDegree';
describe('radianToDegree', () => {
it('should convert radian to degree', () => {
expect(radianToDegree(0)).toBe(0);
expect(radianToDegree(Math.PI / 4)).toBe(45);
expect(radianToDegree(Math.PI / 2)).toBe(90);
expect(radianToDegree(Math.PI)).toBe(180);
expect(radianToDegree(3 * Math.PI / 2)).toBe(270);
expect(radianToDegree(2 * Math.PI)).toBe(360);
});
});

View File

@ -0,0 +1,7 @@
/**
* @param {number} degree
* @return {number}
*/
export default function degreeToRadian(degree) {
return degree * (Math.PI / 180);
}

View File

@ -0,0 +1,7 @@
/**
* @param {number} radian
* @return {number}
*/
export default function radianToDegree(radian) {
return radian * (180 / Math.PI);
}