Skip to content

Commit 5ba30da

Browse files
committed
Math library uses only double.
1 parent ed590d0 commit 5ba30da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+618
-623
lines changed

docs/0/box2d.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/0/box2d_browser.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/box2d/Body.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ <h2><strong>Body</strong>
899899
xf1.rotation.setAngle(sweep.angleZero);
900900
Matrix22.mulMatrixAndVectorToOut(xf1.rotation, sweep.localCenter,
901901
xf1.position);
902-
xf1.position.mulLocal(-1);
902+
xf1.position.mulLocal(-1.0);
903903
xf1.position.addLocal(sweep.centerZero);
904904

905905
BroadPhase broadPhase = world._contactManager.broadPhase;
@@ -2381,7 +2381,7 @@ <h3>Methods</h3>
23812381
xf1.rotation.setAngle(sweep.angleZero);
23822382
Matrix22.mulMatrixAndVectorToOut(xf1.rotation, sweep.localCenter,
23832383
xf1.position);
2384-
xf1.position.mulLocal(-1);
2384+
xf1.position.mulLocal(-1.0);
23852385
xf1.position.addLocal(sweep.centerZero);
23862386

23872387
BroadPhase broadPhase = world._contactManager.broadPhase;

docs/box2d/Collision.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ <h2><strong>Collision</strong>
585585
localTangent.normalize();
586586

587587
// Vector localNormal = Cross(dv, 1.0);
588-
Vector.crossVectorAndNumToOut(localTangent, 1, localNormal);
588+
Vector.crossVectorAndNumToOut(localTangent, 1.0, localNormal);
589589

590590
// Vector planePoint = 0.5 * (v11 + v12)
591591
planePoint.setFrom(v11).addLocal(v12).mulLocal(.5);
@@ -594,7 +594,7 @@ <h2><strong>Collision</strong>
594594
Matrix22.mulMatrixAndVectorToOut(xf1.rotation, localTangent, tangent);
595595

596596
// Vector frontNormal = Cross(sideNormal, 1.0);
597-
Vector.crossVectorAndNumToOut(tangent, 1, normal);
597+
Vector.crossVectorAndNumToOut(tangent, 1.0, normal);
598598

599599
// v11 = Mul(xf1, v11);
600600
// v12 = Mul(xf1, v12);
@@ -1154,7 +1154,7 @@ <h3>Methods</h3>
11541154
localTangent.normalize();
11551155

11561156
// Vector localNormal = Cross(dv, 1.0);
1157-
Vector.crossVectorAndNumToOut(localTangent, 1, localNormal);
1157+
Vector.crossVectorAndNumToOut(localTangent, 1.0, localNormal);
11581158

11591159
// Vector planePoint = 0.5 * (v11 + v12)
11601160
planePoint.setFrom(v11).addLocal(v12).mulLocal(.5);
@@ -1163,7 +1163,7 @@ <h3>Methods</h3>
11631163
Matrix22.mulMatrixAndVectorToOut(xf1.rotation, localTangent, tangent);
11641164

11651165
// Vector frontNormal = Cross(sideNormal, 1.0);
1166-
Vector.crossVectorAndNumToOut(tangent, 1, normal);
1166+
Vector.crossVectorAndNumToOut(tangent, 1.0, normal);
11671167

11681168
// v11 = Mul(xf1, v11);
11691169
// v12 = Mul(xf1, v12);

docs/box2d/ContactSolver.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ <h2><strong>ContactSolver</strong>
256256
final num invMassB = bodyB.invMass;
257257
final num invIB = bodyB.invInertia;
258258
final Vector normal = c.normal;
259-
Vector.crossVectorAndNumToOut(normal, 1, tangent);
259+
Vector.crossVectorAndNumToOut(normal, 1.0, tangent);
260260

261261
for (int j = 0; j &lt; c.pointCount; ++j){
262262
ContactConstraintPoint ccp = c.points[j];
@@ -391,7 +391,7 @@ <h2><strong>ContactSolver</strong>
391391

392392
while (true) {
393393
Matrix22.mulMatrixAndVectorToOut(c.normalMass, b, x);
394-
x.mulLocal(-1);
394+
x.mulLocal(-1.0);
395395

396396
if (x.x &gt;= 0.0 &amp;&amp; x.y &gt;= 0.0){
397397
// Resubstitute for the incremental impulse
@@ -1231,7 +1231,7 @@ <h3>Methods</h3>
12311231

12321232
while (true) {
12331233
Matrix22.mulMatrixAndVectorToOut(c.normalMass, b, x);
1234-
x.mulLocal(-1);
1234+
x.mulLocal(-1.0);
12351235

12361236
if (x.x &gt;= 0.0 &amp;&amp; x.y &gt;= 0.0){
12371237
// Resubstitute for the incremental impulse
@@ -1408,7 +1408,7 @@ <h3>Methods</h3>
14081408
final num invMassB = bodyB.invMass;
14091409
final num invIB = bodyB.invInertia;
14101410
final Vector normal = c.normal;
1411-
Vector.crossVectorAndNumToOut(normal, 1, tangent);
1411+
Vector.crossVectorAndNumToOut(normal, 1.0, tangent);
14121412

14131413
for (int j = 0; j &lt; c.pointCount; ++j){
14141414
ContactConstraintPoint ccp = c.points[j];

docs/box2d/MathBox.html

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ <h2><strong>MathBox</strong>
4141
/**
4242
* Return the distance between the two given vectors, but squared.
4343
*/
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);
4747
return dx * dx + dy * dy;
4848
}
4949

5050
/**
5151
* Return the distance between the two given vectors.
5252
*/
53-
static num distance(Vector v1, Vector v2) {
53+
static double distance(Vector v1, Vector v2) {
5454
return Math.sqrt(distanceSquared(v1, v2));
5555
}
5656

5757
/** 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) {
5959
return Math.max(low, Math.min(a, high));
6060
}
6161

@@ -65,17 +65,17 @@ <h2><strong>MathBox</strong>
6565
* from [toMin] and [toMax]. For example, given a [val] of 2 in the
6666
* "from range" of 0-4, and a "to range" of 10-20, would return 15.
6767
*/
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);
7272
return res;
7373
}
7474

7575
/** Convert from [deg] degrees to radians. */
76-
static num degToRad(num deg) =&gt; (Math.PI / 180.0) * deg;
76+
static double degToRad(double deg) =&gt; (Math.PI / 180.0) * deg;
7777
/** Convert from [rad] radians to degrees. */
78-
static num radToDeg(num rad) =&gt; (180.0 / Math.PI) * rad;
78+
static double radToDeg(double rad) =&gt; (180.0 / Math.PI) * rad;
7979
}
8080
</pre>
8181
</div>
@@ -98,51 +98,51 @@ <h3>Static Properties</h3>
9898
<h3>Static Methods</h3>
9999
<div class="method"><h4 id="distanceSquared">
100100
<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"
102102
title="Permalink to MathBox.distanceSquared">#</a></h4>
103103
<div class="doc">
104104
<p>Return the distance between the two given vectors, but squared.</p>
105105
<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);
109109
return dx * dx + dy * dy;
110110
}
111111
</pre>
112112
</div>
113113
</div>
114114
<div class="method"><h4 id="distance">
115115
<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"
117117
title="Permalink to MathBox.distance">#</a></h4>
118118
<div class="doc">
119119
<p>Return the distance between the two given vectors.</p>
120120
<pre class="source">
121-
static num distance(Vector v1, Vector v2) {
121+
static double distance(Vector v1, Vector v2) {
122122
return Math.sqrt(distanceSquared(v1, v2));
123123
}
124124
</pre>
125125
</div>
126126
</div>
127127
<div class="method"><h4 id="clamp">
128128
<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"
130130
title="Permalink to MathBox.clamp">#</a></h4>
131131
<div class="doc">
132132
<p>Returns the closest value to
133133
<span class="param">a</span> that is in between
134134
<span class="param">low</span> and
135135
<span class="param">high</span> </p>
136136
<pre class="source">
137-
static num clamp(num a, num low, num high) {
137+
static double clamp(double a, double low, double high) {
138138
return Math.max(low, Math.min(a, high));
139139
}
140140
</pre>
141141
</div>
142142
</div>
143143
<div class="method"><h4 id="translateAndScale">
144144
<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"
146146
title="Permalink to MathBox.translateAndScale">#</a></h4>
147147
<div class="doc">
148148
<p>Given a value within the range specified by
@@ -155,36 +155,36 @@ <h3>Static Methods</h3>
155155
<span class="param">val</span> of 2 in the
156156
"from range" of 0-4, and a "to range" of 10-20, would return 15.</p>
157157
<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);
162162
return res;
163163
}
164164
</pre>
165165
</div>
166166
</div>
167167
<div class="method"><h4 id="degToRad">
168168
<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"
170170
title="Permalink to MathBox.degToRad">#</a></h4>
171171
<div class="doc">
172172
<p>Convert from
173173
<span class="param">deg</span> degrees to radians. </p>
174174
<pre class="source">
175-
static num degToRad(num deg) =&gt; (Math.PI / 180.0) * deg;
175+
static double degToRad(double deg) =&gt; (Math.PI / 180.0) * deg;
176176
</pre>
177177
</div>
178178
</div>
179179
<div class="method"><h4 id="radToDeg">
180180
<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"
182182
title="Permalink to MathBox.radToDeg">#</a></h4>
183183
<div class="doc">
184184
<p>Convert from
185185
<span class="param">rad</span> radians to degrees. </p>
186186
<pre class="source">
187-
static num radToDeg(num rad) =&gt; (180.0 / Math.PI) * rad;
187+
static double radToDeg(double rad) =&gt; (180.0 / Math.PI) * rad;
188188
</pre>
189189
</div>
190190
</div>

0 commit comments

Comments
 (0)