@@ -10,75 +10,72 @@ Math.avg = function(...a){
10
10
11
11
const { sin, cos, PI , sqrt, pow, max, min, round, random, sum, avg } = Math ;
12
12
13
- export default class calculateMethods {
14
-
15
- /*
16
- * Get a dot coordinate on the given circle
17
- * All of these params are necessary for generating.
18
- * @param deg should in radian( 2*PI ) format.NOT angle( 360° ).
19
- *
20
- **/
21
-
22
- static getCirclePoint (
23
- radius : Number = 0 ,
24
- originX : Number = 0 ,
25
- originY : Number = 0 ,
26
- deg : Number = 0
27
- ) {
28
-
29
- return {
30
- x :radius * cos ( PI / 2 - deg ) + originX ,
31
- y :- radius * sin ( PI / 2 - deg ) + originY
32
- }
13
+ /*
14
+ * Get a dot coordinate on the given circle
15
+ * All of these params are necessary for generating.
16
+ * @param deg should in radian( 2*PI ) format.NOT angle( 360° ).
17
+ *
18
+ **/
19
+
20
+ export function getCirclePoint (
21
+ radius = 0 ,
22
+ originX = 0 ,
23
+ originY = 0 ,
24
+ deg = 0
25
+ ) {
26
+
27
+ return {
28
+ x :radius * cos ( PI / 2 - deg ) + originX ,
29
+ y :- radius * sin ( PI / 2 - deg ) + originY
33
30
}
31
+ }
34
32
35
- /*
36
- * Convert angle number to raduan number.
37
- **/
33
+ /*
34
+ * Convert angle number to raduan number.
35
+ **/
38
36
39
- static angleToRadian ( angle : Number = 0 ) {
40
- return angle / 180 * PI
41
- }
37
+ export function angleToRadian ( angle = 0 ) {
38
+ return angle / 180 * PI
39
+ }
42
40
43
41
44
- /*
45
- * Mathod to varify whether dot withing a sector filed.
46
- **/
47
-
48
- static isDotWithinPie (
49
- radius : Number = 0 ,
50
- originX : Number = 0 ,
51
- originY : Number = 0 ,
52
- shapeDeg : Number = 0 ,
53
- pointX : Number = 0 ,
54
- pointY : Number = 0 ,
55
- startDeg : Number = 0 ,
56
- endDeg : Number = 0
57
- ) {
58
- const pointDelta = sqrt ( pow ( pointX - originX , 2 ) + pow ( pointY - originY , 2 ) ) ;
59
- const deg = ( pointX - originX / radius )
60
- }
42
+ /*
43
+ * Mathod to varify whether dot withing a sector filed.
44
+ **/
45
+
46
+ export function isDotWithinPie (
47
+ radius = 0 ,
48
+ originX = 0 ,
49
+ originY = 0 ,
50
+ shapeDeg = 0 ,
51
+ pointX = 0 ,
52
+ pointY = 0 ,
53
+ startDeg = 0 ,
54
+ endDeg = 0
55
+ ) {
56
+ const pointDelta = sqrt ( pow ( pointX - originX , 2 ) + pow ( pointY - originY , 2 ) ) ;
57
+ const deg = ( pointX - originX / radius )
58
+ }
61
59
62
- /*
63
- * Get a larger 10ex number of given number array to be y axis range.
64
- **/
60
+ /*
61
+ * Get a larger 10ex number of given number array to be y axis range.
62
+ **/
65
63
66
- static roundingRange (
67
- datas : Array = [ ]
68
- ) {
69
- if ( ! datas . length ) return ;
64
+ export function roundingRange (
65
+ datas = [ ]
66
+ ) {
67
+ if ( ! datas . length ) return ;
70
68
71
- const maxValue = max . apply ( null , datas )
72
- const minValue = min . apply ( null , datas )
69
+ const maxValue = max . apply ( null , datas )
70
+ const minValue = min . apply ( null , datas )
73
71
74
- const maxValueLength = ( '' + maxValue ) . length
75
- const minValueLength = ( '' + minValue ) . length
72
+ const maxValueLength = ( '' + maxValue ) . length
73
+ const minValueLength = ( '' + minValue ) . length
76
74
77
- const delta = maxValueLength - minValueLength ;
78
- const deltaRound = pow ( 10 , delta ) ;
75
+ const delta = maxValueLength - minValueLength ;
76
+ const deltaRound = pow ( 10 , delta ) ;
79
77
80
- return (
81
- parseInt ( maxValue / deltaRound ) + 1
82
- ) * deltaRound ;
83
- }
78
+ return (
79
+ parseInt ( maxValue / deltaRound ) + 1
80
+ ) * deltaRound ;
84
81
}
0 commit comments