File tree 5 files changed +74
-0
lines changed
src/algorithms/math/radian
5 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Radian
2
+
3
+ The ** radian** (symbol ** rad** ) is the unit for measuring angles, and is the
4
+ standard unit of angular measure used in many areas of mathematics.
5
+
6
+ The length of an arc of a unit circle is numerically equal to the measurement
7
+ in radians of the angle that it subtends; one radian is just under ` 57.3 ` degrees.
8
+
9
+ An arc of a circle with the same length as the radius of that circle subtends an
10
+ angle of ` 1 radian ` . The circumference subtends an angle of ` 2π radians ` .
11
+
12
+ ![ Radian] ( https://upload.wikimedia.org/wikipedia/commons/4/4e/Circle_radians.gif )
13
+
14
+ A complete revolution is 2π radians (shown here with a circle of radius one and
15
+ thus circumference ` 2π ` ).
16
+
17
+ ![ 2 pi Radian] ( https://upload.wikimedia.org/wikipedia/commons/6/67/2pi-unrolled.gif )
18
+
19
+ ** Conversions**
20
+
21
+ | Radians | Degrees |
22
+ | :-----: | :-----: |
23
+ | 0 | 0° |
24
+ | π/12 | 15° |
25
+ | π/6 | 30° |
26
+ | π/4 | 45° |
27
+ | 1 | 57.3° |
28
+ | π/3 | 60° |
29
+ | π/2 | 90° |
30
+ | π | 180° |
31
+ | 2π | 360° |
32
+
33
+
34
+ ## References
35
+
36
+ - [ Wikipedia] ( https://en.wikipedia.org/wiki/Radian )
Original file line number Diff line number Diff line change
1
+ import degreeToRadian from '../degreeToRadian' ;
2
+
3
+ describe ( 'degreeToRadian' , ( ) => {
4
+ it ( 'should convert degree to radian' , ( ) => {
5
+ expect ( degreeToRadian ( 0 ) ) . toBe ( 0 ) ;
6
+ expect ( degreeToRadian ( 45 ) ) . toBe ( Math . PI / 4 ) ;
7
+ expect ( degreeToRadian ( 90 ) ) . toBe ( Math . PI / 2 ) ;
8
+ expect ( degreeToRadian ( 180 ) ) . toBe ( Math . PI ) ;
9
+ expect ( degreeToRadian ( 270 ) ) . toBe ( 3 * Math . PI / 2 ) ;
10
+ expect ( degreeToRadian ( 360 ) ) . toBe ( 2 * Math . PI ) ;
11
+ } ) ;
12
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import radianToDegree from '../radianToDegree' ;
2
+
3
+ describe ( 'radianToDegree' , ( ) => {
4
+ it ( 'should convert radian to degree' , ( ) => {
5
+ expect ( radianToDegree ( 0 ) ) . toBe ( 0 ) ;
6
+ expect ( radianToDegree ( Math . PI / 4 ) ) . toBe ( 45 ) ;
7
+ expect ( radianToDegree ( Math . PI / 2 ) ) . toBe ( 90 ) ;
8
+ expect ( radianToDegree ( Math . PI ) ) . toBe ( 180 ) ;
9
+ expect ( radianToDegree ( 3 * Math . PI / 2 ) ) . toBe ( 270 ) ;
10
+ expect ( radianToDegree ( 2 * Math . PI ) ) . toBe ( 360 ) ;
11
+ } ) ;
12
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } degree
3
+ * @return {number }
4
+ */
5
+ export default function degreeToRadian ( degree ) {
6
+ return degree * ( Math . PI / 180 ) ;
7
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } radian
3
+ * @return {number }
4
+ */
5
+ export default function radianToDegree ( radian ) {
6
+ return radian * ( 180 / Math . PI ) ;
7
+ }
You can’t perform that action at this time.
0 commit comments