1
+ /**
2
+ * @function degreesToRadians
3
+ * @description convert from degrees to radians
4
+ * @param {Integer } angle in degrees
5
+ * @return {Integer } degrees * pi / 180
6
+ * @see https://en.wikipedia.org/wiki/Degree_(angle)
7
+ * @example degreesToRadians(45) = 0.7853981633974483
8
+ */
9
+ function degreesToRadians ( degrees ) {
10
+ return angle = degrees * Math . PI / 180
11
+ }
12
+
13
+ /**
14
+ * @function circularArcLength
15
+ * @description calculate the length of a circular arc
16
+ * @param {Integer } radius
17
+ * @param {Integer } degrees
18
+ * @returns {Integer } radius * angle_in _adians
19
+ * @see https://en.wikipedia.org/wiki/Circular_arc
20
+ * @example circularArcLength(3, 45) = 2.356194490192345
21
+ */
22
+ function circularArcLength ( radius , degrees ) {
23
+ return length = radius * degreesToRadians ( degrees )
24
+ }
25
+ /**
26
+ * @function circularArcArea
27
+ * @description calculate the area of the sector formed by an arc
28
+ * @param {Integer } radius
29
+ * @param {Integer } degrees
30
+ * @returns {Integer } 0.5 * r * r * angle_in_radians
31
+ * @see https://en.wikipedia.org/wiki/Circular_arc
32
+ * @example circularArcArea(3,45) = 3.5342917352885173
33
+ */
34
+ function circularArcArea ( radius , degrees ) {
35
+ return area = Math . pow ( radius , 2 ) * degreesToRadians ( degrees ) / 2
36
+ }
37
+
38
+ export {
39
+ circularArcLength ,
40
+ circularArcArea
41
+ }
0 commit comments