@@ -41,21 +41,21 @@ <h2><strong>MathBox</strong>
41
41
/**
42
42
* Return the distance between the two given vectors, but squared.
43
43
*/
44
- static num distanceSquared(Vector v1, Vector v2) {
45
- num dx = (v1.x - v2.x);
46
- num dy = (v1.y - v2.y);
44
+ static double distanceSquared(Vector v1, Vector v2) {
45
+ double dx = (v1.x - v2.x);
46
+ double dy = (v1.y - v2.y);
47
47
return dx * dx + dy * dy;
48
48
}
49
49
50
50
/**
51
51
* Return the distance between the two given vectors.
52
52
*/
53
- static num distance(Vector v1, Vector v2) {
53
+ static double distance(Vector v1, Vector v2) {
54
54
return Math.sqrt(distanceSquared(v1, v2));
55
55
}
56
56
57
57
/** Returns the closest value to [a] that is in between [low] and [high] */
58
- static num clamp(num a, num low, num high) {
58
+ static double clamp(double a, double low, double high) {
59
59
return Math.max(low, Math.min(a, high));
60
60
}
61
61
@@ -65,17 +65,17 @@ <h2><strong>MathBox</strong>
65
65
* from [toMin] and [toMax]. For example, given a [val] of 2 in the
66
66
* "from range" of 0-4, and a "to range" of 10-20, would return 15.
67
67
*/
68
- static num translateAndScale(num val, num fromMin, num fromMax, num toMin ,
69
- num toMax) {
70
- final num mult = (val - fromMin) / (fromMax - fromMin);
71
- final num res = toMin + mult * (toMax - toMin);
68
+ static double translateAndScale(double val, double fromMin, double fromMax,
69
+ double toMin, double toMax) {
70
+ final double mult = (val - fromMin) / (fromMax - fromMin);
71
+ final double res = toMin + mult * (toMax - toMin);
72
72
return res;
73
73
}
74
74
75
75
/** Convert from [deg] degrees to radians. */
76
- static num degToRad(num deg) => (Math.PI / 180.0) * deg;
76
+ static double degToRad(double deg) => (Math.PI / 180.0) * deg;
77
77
/** Convert from [rad] radians to degrees. */
78
- static num radToDeg(num rad) => (180.0 / Math.PI) * rad;
78
+ static double radToDeg(double rad) => (180.0 / Math.PI) * rad;
79
79
}
80
80
</ pre >
81
81
</ div >
@@ -98,51 +98,51 @@ <h3>Static Properties</h3>
98
98
< h3 > Static Methods</ h3 >
99
99
< div class ="method "> < h4 id ="distanceSquared ">
100
100
< button class ="show-code "> Code</ button >
101
- num < strong > distanceSquared</ strong > (< a href ="../box2d/Vector.html "> Vector</ a > v1, < a href ="../box2d/Vector.html "> Vector</ a > v2) < a class ="anchor-link " href ="#distanceSquared "
101
+ double < strong > distanceSquared</ strong > (< a href ="../box2d/Vector.html "> Vector</ a > v1, < a href ="../box2d/Vector.html "> Vector</ a > v2) < a class ="anchor-link " href ="#distanceSquared "
102
102
title ="Permalink to MathBox.distanceSquared "> #</ a > </ h4 >
103
103
< div class ="doc ">
104
104
< p > Return the distance between the two given vectors, but squared.</ p >
105
105
< pre class ="source ">
106
- static num distanceSquared(Vector v1, Vector v2) {
107
- num dx = (v1.x - v2.x);
108
- num dy = (v1.y - v2.y);
106
+ static double distanceSquared(Vector v1, Vector v2) {
107
+ double dx = (v1.x - v2.x);
108
+ double dy = (v1.y - v2.y);
109
109
return dx * dx + dy * dy;
110
110
}
111
111
</ pre >
112
112
</ div >
113
113
</ div >
114
114
< div class ="method "> < h4 id ="distance ">
115
115
< button class ="show-code "> Code</ button >
116
- num < strong > distance</ strong > (< a href ="../box2d/Vector.html "> Vector</ a > v1, < a href ="../box2d/Vector.html "> Vector</ a > v2) < a class ="anchor-link " href ="#distance "
116
+ double < strong > distance</ strong > (< a href ="../box2d/Vector.html "> Vector</ a > v1, < a href ="../box2d/Vector.html "> Vector</ a > v2) < a class ="anchor-link " href ="#distance "
117
117
title ="Permalink to MathBox.distance "> #</ a > </ h4 >
118
118
< div class ="doc ">
119
119
< p > Return the distance between the two given vectors.</ p >
120
120
< pre class ="source ">
121
- static num distance(Vector v1, Vector v2) {
121
+ static double distance(Vector v1, Vector v2) {
122
122
return Math.sqrt(distanceSquared(v1, v2));
123
123
}
124
124
</ pre >
125
125
</ div >
126
126
</ div >
127
127
< div class ="method "> < h4 id ="clamp ">
128
128
< button class ="show-code "> Code</ button >
129
- num < strong > clamp</ strong > (num a, num low, num high) < a class ="anchor-link " href ="#clamp "
129
+ double < strong > clamp</ strong > (double a, double low, double high) < a class ="anchor-link " href ="#clamp "
130
130
title ="Permalink to MathBox.clamp "> #</ a > </ h4 >
131
131
< div class ="doc ">
132
132
< p > Returns the closest value to
133
133
< span class ="param "> a</ span > that is in between
134
134
< span class ="param "> low</ span > and
135
135
< span class ="param "> high</ span > </ p >
136
136
< pre class ="source ">
137
- static num clamp(num a, num low, num high) {
137
+ static double clamp(double a, double low, double high) {
138
138
return Math.max(low, Math.min(a, high));
139
139
}
140
140
</ pre >
141
141
</ div >
142
142
</ div >
143
143
< div class ="method "> < h4 id ="translateAndScale ">
144
144
< button class ="show-code "> Code</ button >
145
- num < strong > translateAndScale</ strong > (num val, num fromMin, num fromMax, num toMin, num toMax) < a class ="anchor-link " href ="#translateAndScale "
145
+ double < strong > translateAndScale</ strong > (double val, double fromMin, double fromMax, double toMin, double toMax) < a class ="anchor-link " href ="#translateAndScale "
146
146
title ="Permalink to MathBox.translateAndScale "> #</ a > </ h4 >
147
147
< div class ="doc ">
148
148
< p > Given a value within the range specified by
@@ -155,36 +155,36 @@ <h3>Static Methods</h3>
155
155
< span class ="param "> val</ span > of 2 in the
156
156
"from range" of 0-4, and a "to range" of 10-20, would return 15.</ p >
157
157
< pre class ="source ">
158
- static num translateAndScale(num val, num fromMin, num fromMax, num toMin ,
159
- num toMax) {
160
- final num mult = (val - fromMin) / (fromMax - fromMin);
161
- final num res = toMin + mult * (toMax - toMin);
158
+ static double translateAndScale(double val, double fromMin, double fromMax,
159
+ double toMin, double toMax) {
160
+ final double mult = (val - fromMin) / (fromMax - fromMin);
161
+ final double res = toMin + mult * (toMax - toMin);
162
162
return res;
163
163
}
164
164
</ pre >
165
165
</ div >
166
166
</ div >
167
167
< div class ="method "> < h4 id ="degToRad ">
168
168
< button class ="show-code "> Code</ button >
169
- num < strong > degToRad</ strong > (num deg) < a class ="anchor-link " href ="#degToRad "
169
+ double < strong > degToRad</ strong > (double deg) < a class ="anchor-link " href ="#degToRad "
170
170
title ="Permalink to MathBox.degToRad "> #</ a > </ h4 >
171
171
< div class ="doc ">
172
172
< p > Convert from
173
173
< span class ="param "> deg</ span > degrees to radians. </ p >
174
174
< pre class ="source ">
175
- static num degToRad(num deg) => (Math.PI / 180.0) * deg;
175
+ static double degToRad(double deg) => (Math.PI / 180.0) * deg;
176
176
</ pre >
177
177
</ div >
178
178
</ div >
179
179
< div class ="method "> < h4 id ="radToDeg ">
180
180
< button class ="show-code "> Code</ button >
181
- num < strong > radToDeg</ strong > (num rad) < a class ="anchor-link " href ="#radToDeg "
181
+ double < strong > radToDeg</ strong > (double rad) < a class ="anchor-link " href ="#radToDeg "
182
182
title ="Permalink to MathBox.radToDeg "> #</ a > </ h4 >
183
183
< div class ="doc ">
184
184
< p > Convert from
185
185
< span class ="param "> rad</ span > radians to degrees. </ p >
186
186
< pre class ="source ">
187
- static num radToDeg(num rad) => (180.0 / Math.PI) * rad;
187
+ static double radToDeg(double rad) => (180.0 / Math.PI) * rad;
188
188
</ pre >
189
189
</ div >
190
190
</ div >
0 commit comments