forked from dojo/dgauges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_circularUtils.js
executable file
·91 lines (83 loc) · 1.62 KB
/
_circularUtils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
define(function(){
// module:
// dojox/dgauges/components/_circularUtils
// summary:
// Internal circular utilities.
// tags:
// private
return {
computeTotalAngle: function(start, end, orientation){
// summary:
// Internal method.
// tags:
// private
if(start == end){
return 360;
}else{
return this.computeAngle(start, end, orientation, 360);
}
},
modAngle: function(angle, base){
// summary:
// Internal method.
// tags:
// private
if(base == undefined){
base = 6.28318530718;
}
if(angle >= base){
do {
angle -= base;
}
while (angle >= base);
}else{
while (angle < 0){
angle += base;
}
}
return angle;
},
computeAngle: function(startAngle, endAngle, orientation, base){
// summary:
// Internal method.
// tags:
// private
if(base == undefined){
base = 6.28318530718;
}
var totalAngle;
if(endAngle == startAngle){
return base;
}
if(orientation == "clockwise"){
if(endAngle < startAngle){
totalAngle = base - (startAngle - endAngle);
}else{
totalAngle = endAngle - startAngle;
}
}
else{
if(endAngle < startAngle){
totalAngle = startAngle - endAngle;
}else{
totalAngle = base - (endAngle - startAngle);
}
}
return this.modAngle(totalAngle, base);
},
toRadians: function(deg){
// summary:
// Internal method.
// tags:
// private
return deg * Math.PI / 180;
},
toDegrees: function(rad){
// summary:
// Internal method.
// tags:
// private
return rad * 180 / Math.PI;
}
}
});