File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Radian : https://en.wikipedia.org/wiki/Radian
3+ * Degree : https://en.wikipedia.org/wiki/Degree_(angle)
4+ *
5+ * Angle in Radian = ( Angle in Degree ) x ( pi / 180 )
6+ *
7+ * Example :
8+ * Question : Convert 90 degree to radian
9+ * So, Angle in Degree = 90
10+ *
11+ * Solution :
12+ * Angle in Radian = ( 90 ) x ( pi / 180 ) = pi / 2
13+ *
14+ * So, 90 degree is equal to pi / 2 radian
15+ */
16+
17+ /**
18+ * @param {number } degree
19+ * @return {number }
20+ */
21+ export function degreeToRadian ( degree ) {
22+ return degree * ( Math . PI / 180 )
23+ }
Original file line number Diff line number Diff line change 1+ import { degreeToRadian } from '../DegreeToRadian'
2+
3+ test ( 'should convert degree to radian:' , ( ) => {
4+ const radianEqual = degreeToRadian ( 0 )
5+ expect ( radianEqual ) . toBe ( 0 )
6+ } )
7+
8+ test ( 'should convert degree to radian:' , ( ) => {
9+ const radianEqual = degreeToRadian ( 45 )
10+ expect ( radianEqual ) . toBe ( Math . PI / 4 )
11+ } )
12+
13+ test ( 'should convert degree to radian:' , ( ) => {
14+ const radianEqual = degreeToRadian ( 90 )
15+ expect ( radianEqual ) . toBe ( Math . PI / 2 )
16+ } )
17+
18+ test ( 'should convert degree to radian:' , ( ) => {
19+ const radianEqual = degreeToRadian ( 180 )
20+ expect ( radianEqual ) . toBe ( Math . PI )
21+ } )
You can’t perform that action at this time.
0 commit comments