-
Notifications
You must be signed in to change notification settings - Fork 1
/
Box2d.min.js
514 lines (514 loc) · 255 KB
/
Box2d.min.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
var a2j={};
(function(L,I){if(I.flash)if(I.flash.utils){if(!I.flash.utils.Dictionary)I.flash.utils.Dictionary=Object}else I.flash.utils={Dictionary:Object};else I.flash={utils:{Dictionary:Object}};I.Vector=I.Array;Function.prototype.inherit=function(H){var F=Function.prototype.inherit.empty;F.prototype=H.prototype;this.prototype=new F;this.prototype.constructor=this};Function.prototype.inherit.empty=function(){};I.trace=function(){I.console&&I.console.log instanceof Function&&I.console.log.apply(I.console,arguments)};
I.assert=function(){I.console&&I.console.assert instanceof Function&&I.console.assert.apply(I.console,arguments)};L.warn=function(){I.console&&console.warn.apply(console,arguments)};L.generateCallback=function(H,F){return function(){F.apply(H,arguments)}};L.NVector=function(H){if(H===undefined)H=0;for(var F=Array(H||0),G=0;G<H;++G)F[G]=0;return F};L.is=function(H,F){if(H===null)return false;if(F instanceof Function&&H instanceof F)return true;if(H.constructor.__implements!=undefined&&H.constructor.__implements[F])return true;
return false};L.parseUInt=function(H){return Math.abs(parseInt(H))}})(a2j,window,undefined);var Vector_a2j_Number=a2j.NVector;window.Box2D||(Box2D={});if(!window.Box2D.Collision)Box2D.Collision={};if(!window.Box2D.Collision.Shapes)Box2D.Collision.Shapes={};if(!window.Box2D.Common)Box2D.Common={};if(!window.Box2D.Common.Math)Box2D.Common.Math={};if(!window.Box2D.Dynamics)Box2D.Dynamics={};if(!window.Box2D.Dynamics.Contacts)Box2D.Dynamics.Contacts={};
if(!window.Box2D.Dynamics.Controllers)Box2D.Dynamics.Controllers={};if(!window.Box2D.Dynamics.Joints)Box2D.Dynamics.Joints={};
(function(){function L(){L.b2AABB.apply(this,arguments)}function I(){I.b2Bound.apply(this,arguments)}function H(){H.b2BoundValues.apply(this,arguments);this.constructor===H&&this.b2BoundValues.apply(this,arguments)}function F(){F.b2BroadPhase.apply(this,arguments);this.constructor===F&&this.b2BroadPhase.apply(this,arguments)}function G(){G.b2Collision.apply(this,arguments)}function A(){A.b2ContactID.apply(this,arguments);this.constructor===A&&this.b2ContactID.apply(this,arguments)}function N(){N.b2ContactPoint.apply(this,
arguments)}function s(){s.b2Distance.apply(this,arguments)}function C(){C.b2DistanceInput.apply(this,arguments)}function R(){R.b2DistanceOutput.apply(this,arguments)}function aa(){aa.b2DistanceProxy.apply(this,arguments)}function $(){$.b2DynamicTree.apply(this,arguments);this.constructor===$&&this.b2DynamicTree.apply(this,arguments)}function T(){T.b2DynamicTreeBroadPhase.apply(this,arguments)}function Q(){Q.b2DynamicTreeNode.apply(this,arguments)}function X(){X.b2DynamicTreePair.apply(this,arguments)}
function da(){da.b2Manifold.apply(this,arguments);this.constructor===da&&this.b2Manifold.apply(this,arguments)}function j(){j.b2ManifoldPoint.apply(this,arguments);this.constructor===j&&this.b2ManifoldPoint.apply(this,arguments)}function y(){y.b2OBB.apply(this,arguments)}function x(){x.b2Pair.apply(this,arguments)}function J(){J.b2PairManager.apply(this,arguments);this.constructor===J&&this.b2PairManager.apply(this,arguments)}function M(){M.b2Point.apply(this,arguments)}function U(){U.b2Proxy.apply(this,
arguments)}function K(){K.b2RayCastInput.apply(this,arguments);this.constructor===K&&this.b2RayCastInput.apply(this,arguments)}function ba(){ba.b2RayCastOutput.apply(this,arguments)}function V(){V.b2Segment.apply(this,arguments)}function Z(){Z.b2SeparationFunction.apply(this,arguments)}function ga(){ga.b2Simplex.apply(this,arguments);this.constructor===ga&&this.b2Simplex.apply(this,arguments)}function fa(){fa.b2SimplexCache.apply(this,arguments)}function c(){c.b2SimplexVertex.apply(this,arguments)}
function g(){g.b2TimeOfImpact.apply(this,arguments)}function k(){k.b2TOIInput.apply(this,arguments)}function h(){h.b2WorldManifold.apply(this,arguments);this.constructor===h&&this.b2WorldManifold.apply(this,arguments)}function o(){o.ClipVertex.apply(this,arguments)}function q(){q.Features.apply(this,arguments)}function l(){l.b2CircleShape.apply(this,arguments);this.constructor===l&&this.b2CircleShape.apply(this,arguments)}function a(){a.b2EdgeChainDef.apply(this,arguments);this.constructor===a&&this.b2EdgeChainDef.apply(this,
arguments)}function b(){b.b2EdgeShape.apply(this,arguments);this.constructor===b&&this.b2EdgeShape.apply(this,arguments)}function f(){f.b2MassData.apply(this,arguments)}function m(){m.b2PolygonShape.apply(this,arguments);this.constructor===m&&this.b2PolygonShape.apply(this,arguments)}function p(){p.b2Shape.apply(this,arguments);this.constructor===p&&this.b2Shape.apply(this,arguments)}function D(){D.b2Color.apply(this,arguments);this.constructor===D&&this.b2Color.apply(this,arguments)}function B(){B.b2Settings.apply(this,
arguments)}function O(){O.b2Mat22.apply(this,arguments);this.constructor===O&&this.b2Mat22.apply(this,arguments)}function W(){W.b2Mat33.apply(this,arguments);this.constructor===W&&this.b2Mat33.apply(this,arguments)}function ca(){ca.b2Math.apply(this,arguments)}function d(){d.b2Sweep.apply(this,arguments)}function n(){n.b2Transform.apply(this,arguments);this.constructor===n&&this.b2Transform.apply(this,arguments)}function e(){e.b2Vec2.apply(this,arguments);this.constructor===e&&this.b2Vec2.apply(this,
arguments)}function r(){r.b2Vec3.apply(this,arguments);this.constructor===r&&this.b2Vec3.apply(this,arguments)}function t(){t.b2Body.apply(this,arguments);this.constructor===t&&this.b2Body.apply(this,arguments)}function v(){v.b2BodyDef.apply(this,arguments);this.constructor===v&&this.b2BodyDef.apply(this,arguments)}function z(){z.b2ContactFilter.apply(this,arguments)}function u(){u.b2ContactImpulse.apply(this,arguments)}function w(){w.b2ContactListener.apply(this,arguments)}function E(){E.b2ContactManager.apply(this,
arguments);this.constructor===E&&this.b2ContactManager.apply(this,arguments)}function P(){P.b2DebugDraw.apply(this,arguments);this.constructor===P&&this.b2DebugDraw.apply(this,arguments)}function Y(){Y.b2DestructionListener.apply(this,arguments)}function S(){S.b2FilterData.apply(this,arguments)}function ea(){ea.b2Fixture.apply(this,arguments);this.constructor===ea&&this.b2Fixture.apply(this,arguments)}function ha(){ha.b2FixtureDef.apply(this,arguments);this.constructor===ha&&this.b2FixtureDef.apply(this,
arguments)}function ia(){ia.b2Island.apply(this,arguments);this.constructor===ia&&this.b2Island.apply(this,arguments)}function ja(){ja.b2TimeStep.apply(this,arguments)}function ka(){ka.b2World.apply(this,arguments);this.constructor===ka&&this.b2World.apply(this,arguments)}function la(){la.b2CircleContact.apply(this,arguments)}function ma(){ma.b2Contact.apply(this,arguments);this.constructor===ma&&this.b2Contact.apply(this,arguments)}function na(){na.b2ContactConstraint.apply(this,arguments);this.constructor===
na&&this.b2ContactConstraint.apply(this,arguments)}function Ma(){Ma.b2ContactConstraintPoint.apply(this,arguments)}function Na(){Na.b2ContactEdge.apply(this,arguments)}function oa(){oa.b2ContactFactory.apply(this,arguments);this.constructor===oa&&this.b2ContactFactory.apply(this,arguments)}function Oa(){Oa.b2ContactRegister.apply(this,arguments)}function Pa(){Pa.b2ContactResult.apply(this,arguments)}function pa(){pa.b2ContactSolver.apply(this,arguments);this.constructor===pa&&this.b2ContactSolver.apply(this,
arguments)}function Qa(){Qa.b2EdgeAndCircleContact.apply(this,arguments)}function qa(){qa.b2NullContact.apply(this,arguments);this.constructor===qa&&this.b2NullContact.apply(this,arguments)}function Ra(){Ra.b2PolyAndCircleContact.apply(this,arguments)}function Sa(){Sa.b2PolyAndEdgeContact.apply(this,arguments)}function Ta(){Ta.b2PolygonContact.apply(this,arguments)}function ra(){ra.b2PositionSolverManifold.apply(this,arguments);this.constructor===ra&&this.b2PositionSolverManifold.apply(this,arguments)}
function Ua(){Ua.b2BuoyancyController.apply(this,arguments)}function Va(){Va.b2ConstantAccelController.apply(this,arguments)}function Wa(){Wa.b2ConstantForceController.apply(this,arguments)}function Xa(){Xa.b2Controller.apply(this,arguments)}function Ya(){Ya.b2ControllerEdge.apply(this,arguments)}function Za(){Za.b2GravityController.apply(this,arguments)}function $a(){$a.b2TensorDampingController.apply(this,arguments)}function sa(){sa.b2DistanceJoint.apply(this,arguments);this.constructor===sa&&this.b2DistanceJoint.apply(this,
arguments)}function ta(){ta.b2DistanceJointDef.apply(this,arguments);this.constructor===ta&&this.b2DistanceJointDef.apply(this,arguments)}function ua(){ua.b2FrictionJoint.apply(this,arguments);this.constructor===ua&&this.b2FrictionJoint.apply(this,arguments)}function va(){va.b2FrictionJointDef.apply(this,arguments);this.constructor===va&&this.b2FrictionJointDef.apply(this,arguments)}function wa(){wa.b2GearJoint.apply(this,arguments);this.constructor===wa&&this.b2GearJoint.apply(this,arguments)}function xa(){xa.b2GearJointDef.apply(this,
arguments);this.constructor===xa&&this.b2GearJointDef.apply(this,arguments)}function ab(){ab.b2Jacobian.apply(this,arguments)}function ya(){ya.b2Joint.apply(this,arguments);this.constructor===ya&&this.b2Joint.apply(this,arguments)}function za(){za.b2JointDef.apply(this,arguments);this.constructor===za&&this.b2JointDef.apply(this,arguments)}function bb(){bb.b2JointEdge.apply(this,arguments)}function Aa(){Aa.b2LineJoint.apply(this,arguments);this.constructor===Aa&&this.b2LineJoint.apply(this,arguments)}
function Ba(){Ba.b2LineJointDef.apply(this,arguments);this.constructor===Ba&&this.b2LineJointDef.apply(this,arguments)}function Ca(){Ca.b2MouseJoint.apply(this,arguments);this.constructor===Ca&&this.b2MouseJoint.apply(this,arguments)}function Da(){Da.b2MouseJointDef.apply(this,arguments);this.constructor===Da&&this.b2MouseJointDef.apply(this,arguments)}function Ea(){Ea.b2PrismaticJoint.apply(this,arguments);this.constructor===Ea&&this.b2PrismaticJoint.apply(this,arguments)}function Fa(){Fa.b2PrismaticJointDef.apply(this,
arguments);this.constructor===Fa&&this.b2PrismaticJointDef.apply(this,arguments)}function Ga(){Ga.b2PulleyJoint.apply(this,arguments);this.constructor===Ga&&this.b2PulleyJoint.apply(this,arguments)}function Ha(){Ha.b2PulleyJointDef.apply(this,arguments);this.constructor===Ha&&this.b2PulleyJointDef.apply(this,arguments)}function Ia(){Ia.b2RevoluteJoint.apply(this,arguments);this.constructor===Ia&&this.b2RevoluteJoint.apply(this,arguments)}function Ja(){Ja.b2RevoluteJointDef.apply(this,arguments);this.constructor===
Ja&&this.b2RevoluteJointDef.apply(this,arguments)}function Ka(){Ka.b2WeldJoint.apply(this,arguments);this.constructor===Ka&&this.b2WeldJoint.apply(this,arguments)}function La(){La.b2WeldJointDef.apply(this,arguments);this.constructor===La&&this.b2WeldJointDef.apply(this,arguments)}Box2D.Collision.IBroadPhase="Box2D.Collision.IBroadPhase";Box2D.Collision.b2AABB=L;Box2D.Collision.b2Bound=I;Box2D.Collision.b2BoundValues=H;Box2D.Collision.b2BroadPhase=F;Box2D.Collision.b2Collision=G;Box2D.Collision.b2ContactID=
A;Box2D.Collision.b2ContactPoint=N;Box2D.Collision.b2Distance=s;Box2D.Collision.b2DistanceInput=C;Box2D.Collision.b2DistanceOutput=R;Box2D.Collision.b2DistanceProxy=aa;Box2D.Collision.b2DynamicTree=$;Box2D.Collision.b2DynamicTreeBroadPhase=T;Box2D.Collision.b2DynamicTreeNode=Q;Box2D.Collision.b2DynamicTreePair=X;Box2D.Collision.b2Manifold=da;Box2D.Collision.b2ManifoldPoint=j;Box2D.Collision.b2OBB=y;Box2D.Collision.b2Pair=x;Box2D.Collision.b2PairManager=J;Box2D.Collision.b2Point=M;Box2D.Collision.b2Proxy=
U;Box2D.Collision.b2RayCastInput=K;Box2D.Collision.b2RayCastOutput=ba;Box2D.Collision.b2Segment=V;Box2D.Collision.b2SeparationFunction=Z;Box2D.Collision.b2Simplex=ga;Box2D.Collision.b2SimplexCache=fa;Box2D.Collision.b2SimplexVertex=c;Box2D.Collision.b2TimeOfImpact=g;Box2D.Collision.b2TOIInput=k;Box2D.Collision.b2WorldManifold=h;Box2D.Collision.ClipVertex=o;Box2D.Collision.Features=q;Box2D.Collision.Shapes.b2CircleShape=l;Box2D.Collision.Shapes.b2EdgeChainDef=a;Box2D.Collision.Shapes.b2EdgeShape=b;
Box2D.Collision.Shapes.b2MassData=f;Box2D.Collision.Shapes.b2PolygonShape=m;Box2D.Collision.Shapes.b2Shape=p;Box2D.Common.b2internal="Box2D.Common.b2internal";Box2D.Common.b2Color=D;Box2D.Common.b2Settings=B;Box2D.Common.Math.b2Mat22=O;Box2D.Common.Math.b2Mat33=W;Box2D.Common.Math.b2Math=ca;Box2D.Common.Math.b2Sweep=d;Box2D.Common.Math.b2Transform=n;Box2D.Common.Math.b2Vec2=e;Box2D.Common.Math.b2Vec3=r;Box2D.Dynamics.b2Body=t;Box2D.Dynamics.b2BodyDef=v;Box2D.Dynamics.b2ContactFilter=z;Box2D.Dynamics.b2ContactImpulse=
u;Box2D.Dynamics.b2ContactListener=w;Box2D.Dynamics.b2ContactManager=E;Box2D.Dynamics.b2DebugDraw=P;Box2D.Dynamics.b2DestructionListener=Y;Box2D.Dynamics.b2FilterData=S;Box2D.Dynamics.b2Fixture=ea;Box2D.Dynamics.b2FixtureDef=ha;Box2D.Dynamics.b2Island=ia;Box2D.Dynamics.b2TimeStep=ja;Box2D.Dynamics.b2World=ka;Box2D.Dynamics.Contacts.b2CircleContact=la;Box2D.Dynamics.Contacts.b2Contact=ma;Box2D.Dynamics.Contacts.b2ContactConstraint=na;Box2D.Dynamics.Contacts.b2ContactConstraintPoint=Ma;Box2D.Dynamics.Contacts.b2ContactEdge=
Na;Box2D.Dynamics.Contacts.b2ContactFactory=oa;Box2D.Dynamics.Contacts.b2ContactRegister=Oa;Box2D.Dynamics.Contacts.b2ContactResult=Pa;Box2D.Dynamics.Contacts.b2ContactSolver=pa;Box2D.Dynamics.Contacts.b2EdgeAndCircleContact=Qa;Box2D.Dynamics.Contacts.b2NullContact=qa;Box2D.Dynamics.Contacts.b2PolyAndCircleContact=Ra;Box2D.Dynamics.Contacts.b2PolyAndEdgeContact=Sa;Box2D.Dynamics.Contacts.b2PolygonContact=Ta;Box2D.Dynamics.Contacts.b2PositionSolverManifold=ra;Box2D.Dynamics.Controllers.b2BuoyancyController=
Ua;Box2D.Dynamics.Controllers.b2ConstantAccelController=Va;Box2D.Dynamics.Controllers.b2ConstantForceController=Wa;Box2D.Dynamics.Controllers.b2Controller=Xa;Box2D.Dynamics.Controllers.b2ControllerEdge=Ya;Box2D.Dynamics.Controllers.b2GravityController=Za;Box2D.Dynamics.Controllers.b2TensorDampingController=$a;Box2D.Dynamics.Joints.b2DistanceJoint=sa;Box2D.Dynamics.Joints.b2DistanceJointDef=ta;Box2D.Dynamics.Joints.b2FrictionJoint=ua;Box2D.Dynamics.Joints.b2FrictionJointDef=va;Box2D.Dynamics.Joints.b2GearJoint=
wa;Box2D.Dynamics.Joints.b2GearJointDef=xa;Box2D.Dynamics.Joints.b2Jacobian=ab;Box2D.Dynamics.Joints.b2Joint=ya;Box2D.Dynamics.Joints.b2JointDef=za;Box2D.Dynamics.Joints.b2JointEdge=bb;Box2D.Dynamics.Joints.b2LineJoint=Aa;Box2D.Dynamics.Joints.b2LineJointDef=Ba;Box2D.Dynamics.Joints.b2MouseJoint=Ca;Box2D.Dynamics.Joints.b2MouseJointDef=Da;Box2D.Dynamics.Joints.b2PrismaticJoint=Ea;Box2D.Dynamics.Joints.b2PrismaticJointDef=Fa;Box2D.Dynamics.Joints.b2PulleyJoint=Ga;Box2D.Dynamics.Joints.b2PulleyJointDef=
Ha;Box2D.Dynamics.Joints.b2RevoluteJoint=Ia;Box2D.Dynamics.Joints.b2RevoluteJointDef=Ja;Box2D.Dynamics.Joints.b2WeldJoint=Ka;Box2D.Dynamics.Joints.b2WeldJointDef=La})();_A2J_postDefs=[];
(function(){var L=flash.utils.Dictionary,I=Box2D.Collision.Shapes.b2CircleShape,H=Box2D.Collision.Shapes.b2PolygonShape,F=Box2D.Collision.Shapes.b2Shape,G=Box2D.Common.b2Settings,A=Box2D.Common.Math.b2Mat22,N=Box2D.Common.Math.b2Math,s=Box2D.Common.Math.b2Sweep,C=Box2D.Common.Math.b2Transform,R=Box2D.Common.Math.b2Vec2,aa=Box2D.Collision.b2AABB,$=Box2D.Collision.b2Bound,T=Box2D.Collision.b2BoundValues,Q=Box2D.Collision.b2BroadPhase,X=Box2D.Collision.b2Collision,da=Box2D.Collision.b2ContactID,j=Box2D.Collision.b2ContactPoint,
y=Box2D.Collision.b2Distance,x=Box2D.Collision.b2DistanceInput,J=Box2D.Collision.b2DistanceOutput,M=Box2D.Collision.b2DistanceProxy,U=Box2D.Collision.b2DynamicTree,K=Box2D.Collision.b2DynamicTreeBroadPhase,ba=Box2D.Collision.b2DynamicTreeNode,V=Box2D.Collision.b2DynamicTreePair,Z=Box2D.Collision.b2Manifold,ga=Box2D.Collision.b2ManifoldPoint,fa=Box2D.Collision.b2OBB,c=Box2D.Collision.b2Pair,g=Box2D.Collision.b2PairManager,k=Box2D.Collision.b2Point,h=Box2D.Collision.b2Proxy,o=Box2D.Collision.b2RayCastInput,
q=Box2D.Collision.b2RayCastOutput,l=Box2D.Collision.b2Segment,a=Box2D.Collision.b2SeparationFunction,b=Box2D.Collision.b2Simplex,f=Box2D.Collision.b2SimplexCache,m=Box2D.Collision.b2SimplexVertex,p=Box2D.Collision.b2TimeOfImpact,D=Box2D.Collision.b2TOIInput,B=Box2D.Collision.b2WorldManifold,O=Box2D.Collision.ClipVertex,W=Box2D.Collision.Features,ca=Box2D.Collision.IBroadPhase;R=Box2D.Common.Math.b2Vec2;aa=Box2D.Collision.b2AABB;$=Box2D.Collision.b2Bound;T=Box2D.Collision.b2BoundValues;Q=Box2D.Collision.b2BroadPhase;
X=Box2D.Collision.b2Collision;da=Box2D.Collision.b2ContactID;j=Box2D.Collision.b2ContactPoint;y=Box2D.Collision.b2Distance;x=Box2D.Collision.b2DistanceInput;J=Box2D.Collision.b2DistanceOutput;M=Box2D.Collision.b2DistanceProxy;U=Box2D.Collision.b2DynamicTree;K=Box2D.Collision.b2DynamicTreeBroadPhase;ba=Box2D.Collision.b2DynamicTreeNode;V=Box2D.Collision.b2DynamicTreePair;Z=Box2D.Collision.b2Manifold;ga=Box2D.Collision.b2ManifoldPoint;fa=Box2D.Collision.b2OBB;c=Box2D.Collision.b2Pair;g=Box2D.Collision.b2PairManager;
k=Box2D.Collision.b2Point;h=Box2D.Collision.b2Proxy;o=Box2D.Collision.b2RayCastInput;q=Box2D.Collision.b2RayCastOutput;l=Box2D.Collision.b2Segment;a=Box2D.Collision.b2SeparationFunction;b=Box2D.Collision.b2Simplex;f=Box2D.Collision.b2SimplexCache;m=Box2D.Collision.b2SimplexVertex;p=Box2D.Collision.b2TimeOfImpact;D=Box2D.Collision.b2TOIInput;B=Box2D.Collision.b2WorldManifold;O=Box2D.Collision.ClipVertex;W=Box2D.Collision.Features;ca=ca=Box2D.Collision.IBroadPhase;aa.b2AABB=function(){this.lowerBound=
new R;this.upperBound=new R};aa.prototype.IsValid=function(){var d=this.upperBound.y-this.lowerBound.y;return d=(d=this.upperBound.x-this.lowerBound.x>=0&&d>=0)&&this.lowerBound.IsValid()&&this.upperBound.IsValid()};aa.prototype.GetCenter=function(){return new R((this.lowerBound.x+this.upperBound.x)/2,(this.lowerBound.y+this.upperBound.y)/2)};aa.prototype.GetExtents=function(){return new R((this.upperBound.x-this.lowerBound.x)/2,(this.upperBound.y-this.lowerBound.y)/2)};aa.prototype.Contains=function(d){var n=
true;return n=(n=(n=(n=n&&this.lowerBound.x<=d.lowerBound.x)&&this.lowerBound.y<=d.lowerBound.y)&&d.upperBound.x<=this.upperBound.x)&&d.upperBound.y<=this.upperBound.y};aa.prototype.RayCast=function(d,n){var e=-Number.MAX_VALUE,r=Number.MAX_VALUE,t=n.p1.x,v=n.p1.y,z=n.p2.x-n.p1.x,u=n.p2.y-n.p1.y,w=Math.abs(u),E=d.normal,P=0,Y=0,S=P=0;S=0;if(Math.abs(z)<Number.MIN_VALUE){if(t<this.lowerBound.x||this.upperBound.x<t)return false}else{P=1/z;Y=(this.lowerBound.x-t)*P;P=(this.upperBound.x-t)*P;S=-1;if(Y>
P){S=Y;Y=P;P=S;S=1}if(Y>e){E.x=S;E.y=0;e=Y}r=Math.min(r,P);if(e>r)return false}if(w<Number.MIN_VALUE){if(v<this.lowerBound.y||this.upperBound.y<v)return false}else{P=1/u;Y=(this.lowerBound.y-v)*P;P=(this.upperBound.y-v)*P;S=-1;if(Y>P){S=Y;Y=P;P=S;S=1}if(Y>e){E.y=S;E.x=0;e=Y}r=Math.min(r,P);if(e>r)return false}d.fraction=e;return true};aa.prototype.TestOverlap=function(d){var n=d.lowerBound.y-this.upperBound.y,e=this.lowerBound.y-d.upperBound.y;if(d.lowerBound.x-this.upperBound.x>0||n>0)return false;
if(this.lowerBound.x-d.upperBound.x>0||e>0)return false;return true};aa.prototype.Combine=function(d,n){var e=new aa;this.constructor===Box2D.Collision.b2AABB?this._a2j__Combine(d,n):e._a2j__Combine(d,n);return e};aa.Combine=aa.prototype.Combine;aa.prototype._a2j__Combine=function(d,n){this.lowerBound.x=Math.min(d.lowerBound.x,n.lowerBound.x);this.lowerBound.y=Math.min(d.lowerBound.y,n.lowerBound.y);this.upperBound.x=Math.max(d.upperBound.x,n.upperBound.x);this.upperBound.y=Math.max(d.upperBound.y,
n.upperBound.y)};$.b2Bound=function(){};$.prototype.IsLower=function(){return(this.value&1)==0};$.prototype.IsUpper=function(){return(this.value&1)==1};$.prototype.Swap=function(d){var n=this.value,e=this.proxy,r=this.stabbingCount;this.value=d.value;this.proxy=d.proxy;this.stabbingCount=d.stabbingCount;d.value=n;d.proxy=e;d.stabbingCount=r};T.b2BoundValues=function(){};T.prototype.b2BoundValues=function(){this.lowerValues=new Vector_a2j_Number;this.lowerValues[0]=0;this.lowerValues[1]=0;this.upperValues=
new Vector_a2j_Number;this.upperValues[0]=0;this.upperValues[1]=0};Q.b2BroadPhase=function(){this.m_pairManager=new g;this.m_proxyPool=[];this.m_querySortKeys=[];this.m_queryResults=[];this.m_quantizationFactor=new R};Q.prototype.b2BroadPhase=function(d){var n=0;this.m_pairManager.Initialize(this);this.m_worldAABB=d;this.m_proxyCount=0;this.m_bounds=new Vector;for(n=0;n<2;n++)this.m_bounds[n]=new Vector;n=d.upperBound.y-d.lowerBound.y;this.m_quantizationFactor.x=G.USHRT_MAX/(d.upperBound.x-d.lowerBound.x);
this.m_quantizationFactor.y=G.USHRT_MAX/n;this.m_timeStamp=1;this.m_queryResultCount=0};Q.prototype.InRange=function(d){var n=0,e=0,r=0,t=0;n=d.lowerBound.x;e=d.lowerBound.y;n-=this.m_worldAABB.upperBound.x;e-=this.m_worldAABB.upperBound.y;r=this.m_worldAABB.lowerBound.x;t=this.m_worldAABB.lowerBound.y;r-=d.upperBound.x;t-=d.upperBound.y;n=N.Max(n,r);e=N.Max(e,t);return N.Max(n,e)<0};Q.prototype.CreateProxy=function(d,n){var e=0,r,t=0;r=0;if(!this.m_freeProxy){this.m_freeProxy=this.m_proxyPool[this.m_proxyCount]=
new h;this.m_freeProxy.next=null;this.m_freeProxy.timeStamp=0;this.m_freeProxy.overlapCount=Q.b2_invalid;this.m_freeProxy.userData=null;for(t=0;t<2;t++){r=this.m_proxyCount*2;this.m_bounds[t][r++]=new $;this.m_bounds[t][r]=new $}}r=this.m_freeProxy;this.m_freeProxy=r.next;r.overlapCount=0;r.userData=n;t=2*this.m_proxyCount;var v=new Vector_a2j_Number,z=new Vector_a2j_Number;this.ComputeBounds(v,z,d);for(var u=0;u<2;++u){var w=this.m_bounds[u],E=0,P=0,Y=new Vector_a2j_Number;Y.push(E);e=new Vector_a2j_Number;
e.push(P);this.QueryAxis(Y,e,v[u],z[u],w,t,u);E=Y[0];P=e[0];w.splice(P,0,w[w.length-1]);w.length--;w.splice(E,0,w[w.length-1]);w.length--;++P;Y=w[E];e=w[P];Y.value=v[u];Y.proxy=r;e.value=z[u];e.proxy=r;var S=w[parseInt(E-1)];Y.stabbingCount=E==0?0:S.stabbingCount;S=w[parseInt(P-1)];e.stabbingCount=S.stabbingCount;for(e=E;e<P;++e){S=w[e];S.stabbingCount++}for(e=E;e<t+2;++e){Y=w[e];E=Y.proxy;if(Y.IsLower())E.lowerBounds[u]=e;else E.upperBounds[u]=e}}++this.m_proxyCount;for(t=0;t<this.m_queryResultCount;++t)this.m_pairManager.AddBufferedPair(r,
this.m_queryResults[t]);this.m_queryResultCount=0;this.IncrementTimeStamp();return r};Q.prototype.DestroyProxy=function(d){d=d instanceof h?d:null;for(var n,e,r=parseInt(2*this.m_proxyCount),t=0;t<2;++t){var v=this.m_bounds[t],z=d.lowerBounds[t],u=d.upperBounds[t];n=v[z];var w=n.value;e=v[u];var E=e.value;v.splice(u,1);v.splice(z,1);v.push(n);v.push(e);e=parseInt(r-2);for(var P=z;P<e;++P){n=v[P];var Y=n.proxy;if(n.IsLower())Y.lowerBounds[t]=P;else Y.upperBounds[t]=P}e=u-1;for(z=parseInt(z);z<e;++z){n=
v[z];n.stabbingCount--}n=new Vector_a2j_Number;this.QueryAxis(n,n,w,E,v,r-2,t)}for(r=0;r<this.m_queryResultCount;++r)this.m_pairManager.RemoveBufferedPair(d,this.m_queryResults[r]);this.m_queryResultCount=0;this.IncrementTimeStamp();d.userData=null;d.overlapCount=Q.b2_invalid;d.lowerBounds[0]=Q.b2_invalid;d.lowerBounds[1]=Q.b2_invalid;d.upperBounds[0]=Q.b2_invalid;d.upperBounds[1]=Q.b2_invalid;d.next=this.m_freeProxy;this.m_freeProxy=d;--this.m_proxyCount};Q.prototype.MoveProxy=function(d,n){var e=
d instanceof h?d:null,r,t=0,v=0,z=0,u,w;if(e!=null)if(n.IsValid()!=false){var E=2*this.m_proxyCount,P=new T;this.ComputeBounds(P.lowerValues,P.upperValues,n);var Y=new T;for(v=0;v<2;++v){u=this.m_bounds[v][e.lowerBounds[v]];Y.lowerValues[v]=u.value;u=this.m_bounds[v][e.upperBounds[v]];Y.upperValues[v]=u.value}for(v=0;v<2;++v){var S=this.m_bounds[v],ea=e.lowerBounds[v],ha=e.upperBounds[v],ia=P.lowerValues[v],ja=P.upperValues[v];u=S[ea];var ka=parseInt(ia-u.value);u.value=ia;u=S[ha];var la=parseInt(ja-
u.value);u.value=ja;if(ka<0)for(z=ea;z>0&&ia<(S[parseInt(z-1)]instanceof $?S[parseInt(z-1)]:null).value;){u=S[z];w=S[parseInt(z-1)];r=w.proxy;w.stabbingCount++;if(w.IsUpper()==true){this.TestOverlapBound(P,r)&&this.m_pairManager.AddBufferedPair(e,r);r=r.upperBounds;t=r[v];t++;r[v]=t;u.stabbingCount++}else{r=r.lowerBounds;t=r[v];t++;r[v]=t;u.stabbingCount--}r=e.lowerBounds;t=r[v];t--;r[v]=t;u.Swap(w);--z}if(la>0)for(z=ha;z<E-1&&(S[parseInt(z+1)]instanceof $?S[parseInt(z+1)]:null).value<=ja;){u=S[z];
w=S[parseInt(z+1)];r=w.proxy;w.stabbingCount++;if(w.IsLower()==true){this.TestOverlapBound(P,r)&&this.m_pairManager.AddBufferedPair(e,r);r=r.lowerBounds;t=r[v];t--;r[v]=t;u.stabbingCount++}else{r=r.upperBounds;t=r[v];t--;r[v]=t;u.stabbingCount--}r=e.upperBounds;t=r[v];t++;r[v]=t;u.Swap(w);z++}if(ka>0)for(z=ea;z<E-1&&(S[parseInt(z+1)]instanceof $?S[parseInt(z+1)]:null).value<=ia;){u=S[z];w=S[parseInt(z+1)];r=w.proxy;w.stabbingCount--;if(w.IsUpper()){this.TestOverlapBound(Y,r)&&this.m_pairManager.RemoveBufferedPair(e,
r);r=r.upperBounds;t=r[v];t--;r[v]=t;u.stabbingCount--}else{r=r.lowerBounds;t=r[v];t--;r[v]=t;u.stabbingCount++}r=e.lowerBounds;t=r[v];t++;r[v]=t;u.Swap(w);z++}if(la<0)for(z=ha;z>0&&ja<(S[parseInt(z-1)]instanceof $?S[parseInt(z-1)]:null).value;){u=S[z];w=S[parseInt(z-1)];r=w.proxy;w.stabbingCount--;if(w.IsLower()==true){this.TestOverlapBound(Y,r)&&this.m_pairManager.RemoveBufferedPair(e,r);r=r.lowerBounds;t=r[v];t++;r[v]=t;u.stabbingCount--}else{r=r.upperBounds;t=r[v];t++;r[v]=t;u.stabbingCount++}r=
e.upperBounds;t=r[v];t--;r[v]=t;u.Swap(w);z--}}}};Q.prototype.UpdatePairs=function(d){this.m_pairManager.Commit(d)};Q.prototype.TestOverlap=function(d,n){var e=d instanceof h?d:null,r=n instanceof h?n:null;if(e.lowerBounds[0]>r.upperBounds[0])return false;if(r.lowerBounds[0]>e.upperBounds[0])return false;if(e.lowerBounds[1]>r.upperBounds[1])return false;if(r.lowerBounds[1]>e.upperBounds[1])return false;return true};Q.prototype.GetUserData=function(d){return(d instanceof h?d:null).userData};Q.prototype.GetFatAABB=
function(d){var n=new aa;d=d instanceof h?d:null;n.lowerBound.x=this.m_worldAABB.lowerBound.x+this.m_bounds[0][d.lowerBounds[0]].value/this.m_quantizationFactor.x;n.lowerBound.y=this.m_worldAABB.lowerBound.y+this.m_bounds[1][d.lowerBounds[1]].value/this.m_quantizationFactor.y;n.upperBound.x=this.m_worldAABB.lowerBound.x+this.m_bounds[0][d.upperBounds[0]].value/this.m_quantizationFactor.x;n.upperBound.y=this.m_worldAABB.lowerBound.y+this.m_bounds[1][d.upperBounds[1]].value/this.m_quantizationFactor.y;
return n};Q.prototype.GetProxyCount=function(){return this.m_proxyCount};Q.prototype.Query=function(d,n){var e=new Vector_a2j_Number,r=new Vector_a2j_Number;this.ComputeBounds(e,r,n);var t=new Vector_a2j_Number;t.push(0);var v=new Vector_a2j_Number;v.push(0);this.QueryAxis(t,v,e[0],r[0],this.m_bounds[0],2*this.m_proxyCount,0);this.QueryAxis(t,v,e[1],r[1],this.m_bounds[1],2*this.m_proxyCount,1);for(e=0;e<this.m_queryResultCount;++e)if(!d(this.m_queryResults[e]))break;this.m_queryResultCount=0;this.IncrementTimeStamp()};
Q.prototype.Validate=function(){for(var d=0;d<2;++d)for(var n=this.m_bounds[d],e=2*this.m_proxyCount,r=0,t=0;t<e;++t)if(n[t].IsLower()==true)r++;else r--};Q.prototype.Rebalance=function(){};Q.prototype.RayCast=function(d,n){var e=new o;e.p1.SetV(n.p1);e.p2.SetV(n.p2);e.maxFraction=n.maxFraction;var r=(n.p2.x-n.p1.x)*this.m_quantizationFactor.x,t=(n.p2.y-n.p1.y)*this.m_quantizationFactor.y,v=parseInt(r<(-Number.MIN_VALUE?-1:r>Number.MIN_VALUE?1:0)),z=parseInt(t<(-Number.MIN_VALUE?-1:t>Number.MIN_VALUE?
1:0)),u=this.m_quantizationFactor.x*(n.p1.x-this.m_worldAABB.lowerBound.x),w=this.m_quantizationFactor.y*(n.p1.y-this.m_worldAABB.lowerBound.y),E=[],P=[];E[0]=a2j.parseUInt(u)&G.USHRT_MAX-1;E[1]=a2j.parseUInt(w)&G.USHRT_MAX-1;P[0]=E[0]+1;P[1]=E[1]+1;var Y=0,S=0;S=new Vector_a2j_Number;S.push(0);var ea=new Vector_a2j_Number;ea.push(0);this.QueryAxis(S,ea,E[0],P[0],this.m_bounds[0],2*this.m_proxyCount,0);Y=v>=0?ea[0]-1:S[0];this.QueryAxis(S,ea,E[1],P[1],this.m_bounds[1],2*this.m_proxyCount,1);S=z>=
0?ea[0]-1:S[0];for(E=0;E<this.m_queryResultCount;E++)e.maxFraction=d(e,this.m_queryResults[E]);for(;;){ea=P=0;Y+=v>=0?1:-1;if(Y<0||Y>=this.m_proxyCount*2)break;if(v!=0)P=(this.m_bounds[0][Y].value-u)/r;S+=z>=0?1:-1;if(S<0||S>=this.m_proxyCount*2)break;if(z!=0)ea=(this.m_bounds[1][S].value-w)/t;for(;;)if(z==0||v!=0&&P<ea){if(P>e.maxFraction)break;if(v>0?this.m_bounds[0][Y].IsLower():this.m_bounds[0][Y].IsUpper()){E=this.m_bounds[0][Y].proxy;if(z>=0){if(E.lowerBounds[1]<=S-1&&E.upperBounds[1]>=S)e.maxFraction=
d(e,E)}else if(E.lowerBounds[1]<=S&&E.upperBounds[1]>=S+1)e.maxFraction=d(e,E)}if(e.maxFraction==0)break;if(v>0){Y++;if(Y==this.m_proxyCount*2)break}else{Y--;if(Y<0)break}P=(this.m_bounds[0][Y].value-u)/r}else{if(ea>e.maxFraction)break;if(z>0?this.m_bounds[1][S].IsLower():this.m_bounds[1][S].IsUpper()){E=this.m_bounds[1][S].proxy;if(v>=0){if(E.lowerBounds[0]<=Y-1&&E.upperBounds[0]>=Y)e.maxFraction=d(e,E)}else if(E.lowerBounds[0]<=Y&&E.upperBounds[0]>=Y+1)e.maxFraction=d(e,E)}if(e.maxFraction==0)break;
if(z>0){S++;if(S==this.m_proxyCount*2)break}else{S--;if(S<0)break}ea=(this.m_bounds[1][S].value-w)/t}break}this.m_queryResultCount=0;this.IncrementTimeStamp()};Q.prototype.ComputeBounds=function(d,n,e){var r=e.lowerBound.x,t=e.lowerBound.y;r=N.Min(r,this.m_worldAABB.upperBound.x);t=N.Min(t,this.m_worldAABB.upperBound.y);r=N.Max(r,this.m_worldAABB.lowerBound.x);t=N.Max(t,this.m_worldAABB.lowerBound.y);var v=e.upperBound.x;e=e.upperBound.y;v=N.Min(v,this.m_worldAABB.upperBound.x);e=N.Min(e,this.m_worldAABB.upperBound.y);
v=N.Max(v,this.m_worldAABB.lowerBound.x);e=N.Max(e,this.m_worldAABB.lowerBound.y);d[0]=a2j.parseUInt(this.m_quantizationFactor.x*(r-this.m_worldAABB.lowerBound.x))&G.USHRT_MAX-1;n[0]=a2j.parseUInt(this.m_quantizationFactor.x*(v-this.m_worldAABB.lowerBound.x))&65535|1;d[1]=a2j.parseUInt(this.m_quantizationFactor.y*(t-this.m_worldAABB.lowerBound.y))&G.USHRT_MAX-1;n[1]=a2j.parseUInt(this.m_quantizationFactor.y*(e-this.m_worldAABB.lowerBound.y))&65535|1};Q.prototype.TestOverlapValidate=function(d,n){for(var e=
0;e<2;++e){var r=this.m_bounds[e],t=r[d.lowerBounds[e]],v=r[n.upperBounds[e]];if(t.value>v.value)return false;t=r[d.upperBounds[e]];v=r[n.lowerBounds[e]];if(t.value<v.value)return false}return true};Q.prototype.TestOverlapBound=function(d,n){for(var e=0;e<2;++e){var r=this.m_bounds[e],t=r[n.upperBounds[e]];if(d.lowerValues[e]>t.value)return false;t=r[n.lowerBounds[e]];if(d.upperValues[e]<t.value)return false}return true};Q.prototype.QueryAxis=function(d,n,e,r,t,v,z){if(e===undefined)e=0;if(r===undefined)r=
0;if(v===undefined)v=0;if(z===undefined)z=0;e=this.BinarySearch(t,v,e);r=this.BinarySearch(t,v,r);for(var u=e;u<r;++u){v=t[u];v.IsLower()&&this.IncrementOverlapCount(v.proxy)}if(e>0){u=parseInt(e-1);v=t[u];for(var w=parseInt(v.stabbingCount);w;){v=t[u];if(v.IsLower())if(e<=v.proxy.upperBounds[z]){this.IncrementOverlapCount(v.proxy);--w}--u}}d[0]=e;n[0]=r};Q.prototype.IncrementOverlapCount=function(d){if(d.timeStamp<this.m_timeStamp){d.timeStamp=this.m_timeStamp;d.overlapCount=1}else{d.overlapCount=
2;this.m_queryResults[this.m_queryResultCount]=d;++this.m_queryResultCount}};Q.prototype.IncrementTimeStamp=function(){if(this.m_timeStamp==G.USHRT_MAX){for(var d=0;d<this.m_proxyPool.length;++d)(this.m_proxyPool[d]instanceof h?this.m_proxyPool[d]:null).timeStamp=0;this.m_timeStamp=1}else++this.m_timeStamp};Q.prototype.BinarySearch=function(d,n,e){if(n===undefined)n=0;if(e===undefined)e=0;var r=0;for(n=parseInt(n-1);r<=n;){var t=parseInt((r+n)/2),v=d[t];if(v.value>e)n=t-1;else if(v.value<e)r=t+1;
else return a2j.parseUInt(t)}return a2j.parseUInt(r)};Q.BinarySearch=Q.prototype.BinarySearch;_A2J_postDefs.push(function(){Box2D.Collision.b2BroadPhase.s_validate=false;Box2D.Collision.b2BroadPhase.prototype.s_validate=Box2D.Collision.b2BroadPhase.s_validate;Box2D.Collision.b2BroadPhase.b2_invalid=parseInt(G.USHRT_MAX);Box2D.Collision.b2BroadPhase.prototype.b2_invalid=Box2D.Collision.b2BroadPhase.b2_invalid;Box2D.Collision.b2BroadPhase.b2_nullEdge=parseInt(G.USHRT_MAX);Box2D.Collision.b2BroadPhase.prototype.b2_nullEdge=
Box2D.Collision.b2BroadPhase.b2_nullEdge});Q.__implements={};Q.__implements[ca]=true;X.b2Collision=function(){};X.prototype.ClipSegmentToLine=function(d,n,e,r){if(r===undefined)r=0;var t,v=0;t=n[0];var z=t.v;t=n[1];var u=t.v,w=e.x*z.x+e.y*z.y-r;t=e.x*u.x+e.y*u.y-r;w<=0&&d[v++].Set(n[0]);t<=0&&d[v++].Set(n[1]);if(w*t<0){e=w/(w-t);t=d[v];t=t.v;t.x=z.x+e*(u.x-z.x);t.y=z.y+e*(u.y-z.y);t=d[v];t.id=(w>0?n[0]:n[1]).id;++v}return v};X.ClipSegmentToLine=X.prototype.ClipSegmentToLine;X.prototype.EdgeSeparation=
function(d,n,e,r,t){if(e===undefined)e=0;parseInt(d.m_vertexCount);var v=d.m_vertices;d=d.m_normals;var z=parseInt(r.m_vertexCount),u=r.m_vertices,w,E;w=n.R;E=d[e];d=w.col1.x*E.x+w.col2.x*E.y;r=w.col1.y*E.x+w.col2.y*E.y;w=t.R;var P=w.col1.x*d+w.col1.y*r;w=w.col2.x*d+w.col2.y*r;for(var Y=0,S=Number.MAX_VALUE,ea=0;ea<z;++ea){E=u[ea];E=E.x*P+E.y*w;if(E<S){S=E;Y=ea}}E=v[e];w=n.R;e=n.position.x+(w.col1.x*E.x+w.col2.x*E.y);n=n.position.y+(w.col1.y*E.x+w.col2.y*E.y);E=u[Y];w=t.R;v=t.position.x+(w.col1.x*
E.x+w.col2.x*E.y);t=t.position.y+(w.col1.y*E.x+w.col2.y*E.y);v-=e;t-=n;return v*d+t*r};X.EdgeSeparation=X.prototype.EdgeSeparation;X.prototype.FindMaxSeparation=function(d,n,e,r,t){var v=parseInt(n.m_vertexCount),z=n.m_normals,u,w;w=t.R;u=r.m_centroid;var E=t.position.x+(w.col1.x*u.x+w.col2.x*u.y),P=t.position.y+(w.col1.y*u.x+w.col2.y*u.y);w=e.R;u=n.m_centroid;E-=e.position.x+(w.col1.x*u.x+w.col2.x*u.y);P-=e.position.y+(w.col1.y*u.x+w.col2.y*u.y);w=E*e.R.col1.x+P*e.R.col1.y;P=E*e.R.col2.x+P*e.R.col2.y;
E=0;for(var Y=-Number.MAX_VALUE,S=0;S<v;++S){u=z[S];u=u.x*w+u.y*P;if(u>Y){Y=u;E=S}}z=this.EdgeSeparation(n,e,E,r,t);u=parseInt(E-1>=0?E-1:v-1);w=this.EdgeSeparation(n,e,u,r,t);P=parseInt(E+1<v?E+1:0);Y=this.EdgeSeparation(n,e,P,r,t);var ea=S=0,ha=0;if(w>z&&w>Y){ha=-1;S=u;ea=w}else if(Y>z){ha=1;S=P;ea=Y}else{d[0]=E;return z}for(;;){E=ha==-1?S-1>=0?S-1:v-1:S+1<v?S+1:0;z=this.EdgeSeparation(n,e,E,r,t);if(z>ea){S=E;ea=z}else break}d[0]=S;return ea};X.FindMaxSeparation=X.prototype.FindMaxSeparation;X.prototype.FindIncidentEdge=
function(d,n,e,r,t,v){if(r===undefined)r=0;parseInt(n.m_vertexCount);var z=n.m_normals,u=parseInt(t.m_vertexCount);n=t.m_vertices;t=t.m_normals;var w;w=e.R;e=z[r];z=w.col1.x*e.x+w.col2.x*e.y;var E=w.col1.y*e.x+w.col2.y*e.y;w=v.R;e=w.col1.x*z+w.col1.y*E;E=w.col2.x*z+w.col2.y*E;z=e;w=0;for(var P=Number.MAX_VALUE,Y=0;Y<u;++Y){e=t[Y];e=z*e.x+E*e.y;if(e<P){P=e;w=Y}}t=parseInt(w);z=parseInt(t+1<u?t+1:0);u=d[0];e=n[t];w=v.R;u.v.x=v.position.x+(w.col1.x*e.x+w.col2.x*e.y);u.v.y=v.position.y+(w.col1.y*e.x+
w.col2.y*e.y);u.id.features.referenceEdge=r;u.id.features.incidentEdge=t;u.id.features.incidentVertex=0;u=d[1];e=n[z];w=v.R;u.v.x=v.position.x+(w.col1.x*e.x+w.col2.x*e.y);u.v.y=v.position.y+(w.col1.y*e.x+w.col2.y*e.y);u.id.features.referenceEdge=r;u.id.features.incidentEdge=z;u.id.features.incidentVertex=1};X.FindIncidentEdge=X.prototype.FindIncidentEdge;X.prototype.MakeClipPointVector=function(){var d=new Vector(2);d[0]=new O;d[1]=new O;return d};X.MakeClipPointVector=X.prototype.MakeClipPointVector;
X.prototype.CollidePolygons=function(d,n,e,r,t){var v;d.m_pointCount=0;var z=n.m_radius+r.m_radius;v=0;X.s_edgeAO[0]=v;var u=this.FindMaxSeparation(X.s_edgeAO,n,e,r,t);v=X.s_edgeAO[0];if(!(u>z)){var w=0;X.s_edgeBO[0]=w;var E=this.FindMaxSeparation(X.s_edgeBO,r,t,n,e);w=X.s_edgeBO[0];if(!(E>z)){var P=0,Y=0;if(E>0.98*u+0.0010){u=r;r=n;n=t;e=e;P=w;d.m_type=Z.e_faceB;Y=1}else{u=n;r=r;n=e;e=t;P=v;d.m_type=Z.e_faceA;Y=0}v=X.s_incidentEdge;this.FindIncidentEdge(v,u,n,P,r,e);w=parseInt(u.m_vertexCount);t=
u.m_vertices;u=t[P];var S;S=P+1<w?t[parseInt(P+1)]:t[0];P=X.s_localTangent;P.Set(S.x-u.x,S.y-u.y);P.Normalize();t=X.s_localNormal;t.x=P.y;t.y=-P.x;r=X.s_planePoint;r.Set(0.5*(u.x+S.x),0.5*(u.y+S.y));E=X.s_tangent;w=n.R;E.x=w.col1.x*P.x+w.col2.x*P.y;E.y=w.col1.y*P.x+w.col2.y*P.y;var ea=X.s_tangent2;ea.x=-E.x;ea.y=-E.y;P=X.s_normal;P.x=E.y;P.y=-E.x;var ha=X.s_v11,ia=X.s_v12;ha.x=n.position.x+(w.col1.x*u.x+w.col2.x*u.y);ha.y=n.position.y+(w.col1.y*u.x+w.col2.y*u.y);ia.x=n.position.x+(w.col1.x*S.x+w.col2.x*
S.y);ia.y=n.position.y+(w.col1.y*S.x+w.col2.y*S.y);n=P.x*ha.x+P.y*ha.y;w=E.x*ia.x+E.y*ia.y+z;S=X.s_clipPoints1;u=X.s_clipPoints2;ia=0;ia=this.ClipSegmentToLine(S,v,ea,-E.x*ha.x-E.y*ha.y+z);if(!(ia<2)){ia=this.ClipSegmentToLine(u,S,E,w);if(!(ia<2)){d.m_localPlaneNormal.SetV(t);d.m_localPoint.SetV(r);for(r=t=0;r<G.b2_maxManifoldPoints;++r){v=u[r];if(P.x*v.v.x+P.y*v.v.y-n<=z){E=d.m_points[t];w=e.R;ea=v.v.x-e.position.x;ha=v.v.y-e.position.y;E.m_localPoint.x=ea*w.col1.x+ha*w.col1.y;E.m_localPoint.y=ea*
w.col2.x+ha*w.col2.y;E.m_id.Set(v.id);E.m_id.features.flip=Y;++t}}d.m_pointCount=t}}}}};X.CollidePolygons=X.prototype.CollidePolygons;X.prototype.CollideCircles=function(d,n,e,r,t){d.m_pointCount=0;var v,z;v=e.R;z=n.m_p;var u=e.position.x+(v.col1.x*z.x+v.col2.x*z.y);e=e.position.y+(v.col1.y*z.x+v.col2.y*z.y);v=t.R;z=r.m_p;u=t.position.x+(v.col1.x*z.x+v.col2.x*z.y)-u;t=t.position.y+(v.col1.y*z.x+v.col2.y*z.y)-e;v=n.m_radius+r.m_radius;if(!(u*u+t*t>v*v)){d.m_type=Z.e_circles;d.m_localPoint.SetV(n.m_p);
d.m_localPlaneNormal.SetZero();d.m_pointCount=1;d.m_points[0].m_localPoint.SetV(r.m_p);d.m_points[0].m_id.key=0}};X.CollideCircles=X.prototype.CollideCircles;X.prototype.CollidePolygonAndCircle=function(d,n,e,r,t){var v=d.m_pointCount=0,z=0,u,w;w=t.R;u=r.m_p;var E=t.position.y+(w.col1.y*u.x+w.col2.y*u.y);v=t.position.x+(w.col1.x*u.x+w.col2.x*u.y)-e.position.x;z=E-e.position.y;w=e.R;e=v*w.col1.x+z*w.col1.y;w=v*w.col2.x+z*w.col2.y;var P=0;E=-Number.MAX_VALUE;t=n.m_radius+r.m_radius;var Y=parseInt(n.m_vertexCount),
S=n.m_vertices;n=n.m_normals;for(var ea=0;ea<Y;++ea){u=S[ea];v=e-u.x;z=w-u.y;u=n[ea];v=u.x*v+u.y*z;if(v>t)return;if(v>E){E=v;P=ea}}v=parseInt(P);z=parseInt(v+1<Y?v+1:0);u=S[v];S=S[z];if(E<Number.MIN_VALUE){d.m_pointCount=1;d.m_type=Z.e_faceA;d.m_localPlaneNormal.SetV(n[P]);d.m_localPoint.x=0.5*(u.x+S.x);d.m_localPoint.y=0.5*(u.y+S.y)}else{E=(e-S.x)*(u.x-S.x)+(w-S.y)*(u.y-S.y);if((e-u.x)*(S.x-u.x)+(w-u.y)*(S.y-u.y)<=0){if((e-u.x)*(e-u.x)+(w-u.y)*(w-u.y)>t*t)return;d.m_pointCount=1;d.m_type=Z.e_faceA;
d.m_localPlaneNormal.x=e-u.x;d.m_localPlaneNormal.y=w-u.y;d.m_localPlaneNormal.Normalize();d.m_localPoint.SetV(u)}else if(E<=0){if((e-S.x)*(e-S.x)+(w-S.y)*(w-S.y)>t*t)return;d.m_pointCount=1;d.m_type=Z.e_faceA;d.m_localPlaneNormal.x=e-S.x;d.m_localPlaneNormal.y=w-S.y;d.m_localPlaneNormal.Normalize();d.m_localPoint.SetV(S)}else{P=0.5*(u.x+S.x);u=0.5*(u.y+S.y);E=(e-P)*n[v].x+(w-u)*n[v].y;if(E>t)return;d.m_pointCount=1;d.m_type=Z.e_faceA;d.m_localPlaneNormal.x=n[v].x;d.m_localPlaneNormal.y=n[v].y;d.m_localPlaneNormal.Normalize();
d.m_localPoint.Set(P,u)}}d.m_points[0].m_localPoint.SetV(r.m_p);d.m_points[0].m_id.key=0};X.CollidePolygonAndCircle=X.prototype.CollidePolygonAndCircle;X.prototype.TestOverlap=function(d,n){var e=n.lowerBound,r=d.upperBound,t=e.x-r.x,v=e.y-r.y;e=d.lowerBound;r=n.upperBound;var z=e.y-r.y;if(t>0||v>0)return false;if(e.x-r.x>0||z>0)return false;return true};X.TestOverlap=X.prototype.TestOverlap;_A2J_postDefs.push(function(){Box2D.Collision.b2Collision.s_incidentEdge=X.MakeClipPointVector();Box2D.Collision.b2Collision.prototype.s_incidentEdge=
Box2D.Collision.b2Collision.s_incidentEdge;Box2D.Collision.b2Collision.s_clipPoints1=X.MakeClipPointVector();Box2D.Collision.b2Collision.prototype.s_clipPoints1=Box2D.Collision.b2Collision.s_clipPoints1;Box2D.Collision.b2Collision.s_clipPoints2=X.MakeClipPointVector();Box2D.Collision.b2Collision.prototype.s_clipPoints2=Box2D.Collision.b2Collision.s_clipPoints2;Box2D.Collision.b2Collision.s_edgeAO=new Vector_a2j_Number(1);Box2D.Collision.b2Collision.prototype.s_edgeAO=Box2D.Collision.b2Collision.s_edgeAO;
Box2D.Collision.b2Collision.s_edgeBO=new Vector_a2j_Number(1);Box2D.Collision.b2Collision.prototype.s_edgeBO=Box2D.Collision.b2Collision.s_edgeBO;Box2D.Collision.b2Collision.s_localTangent=new R;Box2D.Collision.b2Collision.prototype.s_localTangent=Box2D.Collision.b2Collision.s_localTangent;Box2D.Collision.b2Collision.s_localNormal=new R;Box2D.Collision.b2Collision.prototype.s_localNormal=Box2D.Collision.b2Collision.s_localNormal;Box2D.Collision.b2Collision.s_planePoint=new R;Box2D.Collision.b2Collision.prototype.s_planePoint=
Box2D.Collision.b2Collision.s_planePoint;Box2D.Collision.b2Collision.s_normal=new R;Box2D.Collision.b2Collision.prototype.s_normal=Box2D.Collision.b2Collision.s_normal;Box2D.Collision.b2Collision.s_tangent=new R;Box2D.Collision.b2Collision.prototype.s_tangent=Box2D.Collision.b2Collision.s_tangent;Box2D.Collision.b2Collision.s_tangent2=new R;Box2D.Collision.b2Collision.prototype.s_tangent2=Box2D.Collision.b2Collision.s_tangent2;Box2D.Collision.b2Collision.s_v11=new R;Box2D.Collision.b2Collision.prototype.s_v11=
Box2D.Collision.b2Collision.s_v11;Box2D.Collision.b2Collision.s_v12=new R;Box2D.Collision.b2Collision.prototype.s_v12=Box2D.Collision.b2Collision.s_v12;Box2D.Collision.b2Collision.b2CollidePolyTempVec=new R;Box2D.Collision.b2Collision.prototype.b2CollidePolyTempVec=Box2D.Collision.b2Collision.b2CollidePolyTempVec;Box2D.Collision.b2Collision.b2_nullFeature=255;Box2D.Collision.b2Collision.prototype.b2_nullFeature=Box2D.Collision.b2Collision.b2_nullFeature});da.b2ContactID=function(){this.features=new W};
da.prototype.b2ContactID=function(){this.features._m_id=this};da.prototype.Set=function(d){this.key=d._key};da.prototype.Copy=function(){var d=new da;d.key=this.key;return d};Object.defineProperty(da.prototype,"key",{enumerable:false,configurable:true,get:function(){return this._key}});Object.defineProperty(da.prototype,"key",{enumerable:false,configurable:true,set:function(d){if(d===undefined)d=0;this._key=d;this.features._referenceEdge=this._key&255;this.features._incidentEdge=(this._key&65280)>>
8&255;this.features._incidentVertex=(this._key&16711680)>>16&255;this.features._flip=(this._key&4278190080)>>24&255}});j.b2ContactPoint=function(){this.position=new R;this.velocity=new R;this.normal=new R;this.id=new da};y.b2Distance=function(){};y.prototype.Distance=function(d,n,e){++y.b2_gjkCalls;var r=e.proxyA,t=e.proxyB,v=e.transformA,z=e.transformB,u=y.s_simplex;u.ReadCache(n,r,v,t,z);var w=u.m_vertices,E=y.s_saveA,P=y.s_saveB,Y=0;u.GetClosestPoint().LengthSquared();for(var S=0,ea,ha=0;ha<20;){Y=
u.m_count;for(S=0;S<Y;S++){E[S]=w[S].indexA;P[S]=w[S].indexB}switch(u.m_count){case 1:break;case 2:u.Solve2();break;case 3:u.Solve3();break;default:G.b2Assert(false)}if(u.m_count==3)break;ea=u.GetClosestPoint();ea.LengthSquared();S=u.GetSearchDirection();if(S.LengthSquared()<Number.MIN_VALUE*Number.MIN_VALUE)break;ea=w[u.m_count];ea.indexA=r.GetSupport(N.MulTMV(v.R,S.GetNegative()));ea.wA=N.MulX(v,r.GetVertex(ea.indexA));ea.indexB=t.GetSupport(N.MulTMV(z.R,S));ea.wB=N.MulX(z,t.GetVertex(ea.indexB));
ea.w=N.SubtractVV(ea.wB,ea.wA);++ha;++y.b2_gjkIters;var ia=false;for(S=0;S<Y;S++)if(ea.indexA==E[S]&&ea.indexB==P[S]){ia=true;break}if(ia)break;++u.m_count}y.b2_gjkMaxIters=N.Max(y.b2_gjkMaxIters,ha);u.GetWitnessPoints(d.pointA,d.pointB);d.distance=N.SubtractVV(d.pointA,d.pointB).Length();d.iterations=ha;u.WriteCache(n);if(e.useRadii){n=r.m_radius;t=t.m_radius;if(d.distance>n+t&&d.distance>Number.MIN_VALUE){d.distance-=n+t;e=N.SubtractVV(d.pointB,d.pointA);e.Normalize();d.pointA.x+=n*e.x;d.pointA.y+=
n*e.y;d.pointB.x-=t*e.x;d.pointB.y-=t*e.y}else{ea=new R;ea.x=0.5*(d.pointA.x+d.pointB.x);ea.y=0.5*(d.pointA.y+d.pointB.y);d.pointA.x=d.pointB.x=ea.x;d.pointA.y=d.pointB.y=ea.y;d.distance=0}}};y.Distance=y.prototype.Distance;_A2J_postDefs.push(function(){Box2D.Collision.b2Distance.s_simplex=new b;Box2D.Collision.b2Distance.prototype.s_simplex=Box2D.Collision.b2Distance.s_simplex;Box2D.Collision.b2Distance.s_saveA=new Vector_a2j_Number(3);Box2D.Collision.b2Distance.prototype.s_saveA=Box2D.Collision.b2Distance.s_saveA;
Box2D.Collision.b2Distance.s_saveB=new Vector_a2j_Number(3);Box2D.Collision.b2Distance.prototype.s_saveB=Box2D.Collision.b2Distance.s_saveB});x.b2DistanceInput=function(){};J.b2DistanceOutput=function(){this.pointA=new R;this.pointB=new R};M.b2DistanceProxy=function(){};M.prototype.Set=function(d){switch(d.GetType()){case F.e_circleShape:d=d instanceof I?d:null;this.m_vertices=new Vector(1,true);this.m_vertices[0]=d.m_p;this.m_count=1;this.m_radius=d.m_radius;break;case F.e_polygonShape:d=d instanceof
H?d:null;this.m_vertices=d.m_vertices;this.m_count=d.m_vertexCount;this.m_radius=d.m_radius;break;default:G.b2Assert(false)}};M.prototype.GetSupport=function(d){for(var n=0,e=this.m_vertices[0].x*d.x+this.m_vertices[0].y*d.y,r=1;r<this.m_count;++r){var t=this.m_vertices[r].x*d.x+this.m_vertices[r].y*d.y;if(t>e){n=r;e=t}}return n};M.prototype.GetSupportVertex=function(d){for(var n=0,e=this.m_vertices[0].x*d.x+this.m_vertices[0].y*d.y,r=1;r<this.m_count;++r){var t=this.m_vertices[r].x*d.x+this.m_vertices[r].y*
d.y;if(t>e){n=r;e=t}}return this.m_vertices[n]};M.prototype.GetVertexCount=function(){return this.m_count};M.prototype.GetVertex=function(d){if(d===undefined)d=0;G.b2Assert(0<=d&&d<this.m_count);return this.m_vertices[d]};U.b2DynamicTree=function(){};U.prototype.b2DynamicTree=function(){this.m_freeList=this.m_root=null;this.m_insertionCount=this.m_path=0};U.prototype.CreateProxy=function(d,n){var e=this.AllocateNode(),r=G.b2_aabbExtension,t=G.b2_aabbExtension;e.aabb.lowerBound.x=d.lowerBound.x-r;
e.aabb.lowerBound.y=d.lowerBound.y-t;e.aabb.upperBound.x=d.upperBound.x+r;e.aabb.upperBound.y=d.upperBound.y+t;e.userData=n;this.InsertLeaf(e);return e};U.prototype.DestroyProxy=function(d){this.RemoveLeaf(d);this.FreeNode(d)};U.prototype.MoveProxy=function(d,n,e){G.b2Assert(d.IsLeaf());if(d.aabb.Contains(n))return false;this.RemoveLeaf(d);var r=G.b2_aabbExtension+G.b2_aabbMultiplier*(e.x>0?e.x:-e.x);e=G.b2_aabbExtension+G.b2_aabbMultiplier*(e.y>0?e.y:-e.y);d.aabb.lowerBound.x=n.lowerBound.x-r;d.aabb.lowerBound.y=
n.lowerBound.y-e;d.aabb.upperBound.x=n.upperBound.x+r;d.aabb.upperBound.y=n.upperBound.y+e;this.InsertLeaf(d);return true};U.prototype.Rebalance=function(d){if(d===undefined)d=0;if(this.m_root!=null)for(var n=0;n<d;n++){for(var e=this.m_root,r=0;e.IsLeaf()==false;){e=this.m_path>>r&1?e.child2:e.child1;r=r+1&31}++this.m_path;this.RemoveLeaf(e);this.InsertLeaf(e)}};U.prototype.GetFatAABB=function(d){return d.aabb};U.prototype.GetUserData=function(d){return d.userData};U.prototype.Query=function(d,n){if(this.m_root!=
null){var e=new Vector,r=0;for(e[r++]=this.m_root;r>0;){var t=e[--r];if(t.aabb.TestOverlap(n))if(t.IsLeaf()){if(!d(t))break}else{e[r++]=t.child1;e[r++]=t.child2}}}};U.prototype.RayCast=function(d,n){if(this.m_root!=null){var e=n.p1,r=n.p2,t=N.SubtractVV(e,r);t.Normalize();t=N.CrossFV(1,t);var v=N.AbsV(t),z=n.maxFraction,u=new aa,w=0,E=0;w=e.x+z*(r.x-e.x);E=e.y+z*(r.y-e.y);u.lowerBound.x=Math.min(e.x,w);u.lowerBound.y=Math.min(e.y,E);u.upperBound.x=Math.max(e.x,w);u.upperBound.y=Math.max(e.y,E);var P=
new Vector,Y=0;for(P[Y++]=this.m_root;Y>0;){z=P[--Y];if(z.aabb.TestOverlap(u)!=false){w=z.aabb.GetCenter();E=z.aabb.GetExtents();if(!(Math.abs(t.x*(e.x-w.x)+t.y*(e.y-w.y))-v.x*E.x-v.y*E.y>0))if(z.IsLeaf()){w=new o;w.p1=n.p1;w.p2=n.p2;w.maxFraction=n.maxFraction;z=d(w,z);if(z==0)break;if(z>0){w=e.x+z*(r.x-e.x);E=e.y+z*(r.y-e.y);u.lowerBound.x=Math.min(e.x,w);u.lowerBound.y=Math.min(e.y,E);u.upperBound.x=Math.max(e.x,w);u.upperBound.y=Math.max(e.y,E)}}else{P[Y++]=z.child1;P[Y++]=z.child2}}}}};U.prototype.AllocateNode=
function(){if(this.m_freeList){var d=this.m_freeList;this.m_freeList=d.parent;d.parent=null;d.child1=null;d.child2=null;return d}return new ba};U.prototype.FreeNode=function(d){d.parent=this.m_freeList;this.m_freeList=d};U.prototype.InsertLeaf=function(d){++this.m_insertionCount;if(this.m_root==null){this.m_root=d;this.m_root.parent=null}else{var n=d.aabb.GetCenter(),e=this.m_root;if(e.IsLeaf()==false){do{var r=e.child1;e=e.child2;e=Math.abs((r.aabb.lowerBound.x+r.aabb.upperBound.x)/2-n.x)+Math.abs((r.aabb.lowerBound.y+
r.aabb.upperBound.y)/2-n.y)<Math.abs((e.aabb.lowerBound.x+e.aabb.upperBound.x)/2-n.x)+Math.abs((e.aabb.lowerBound.y+e.aabb.upperBound.y)/2-n.y)?r:e}while(e.IsLeaf()==false)}n=e.parent;r=this.AllocateNode();r.parent=n;r.userData=null;r.aabb.Combine(d.aabb,e.aabb);if(n){if(e.parent.child1==e)n.child1=r;else n.child2=r;r.child1=e;r.child2=d;e.parent=r;d.parent=r;do{if(n.aabb.Contains(r.aabb))break;n.aabb.Combine(n.child1.aabb,n.child2.aabb);r=n;n=n.parent}while(n)}else{r.child1=e;r.child2=d;e.parent=
r;this.m_root=d.parent=r}}};U.prototype.RemoveLeaf=function(d){if(d==this.m_root)this.m_root=null;else{var n=d.parent,e=n.parent;d=n.child1==d?n.child2:n.child1;if(e){if(e.child1==n)e.child1=d;else e.child2=d;d.parent=e;for(this.FreeNode(n);e;){n=e.aabb;e.aabb=aa.Combine(e.child1.aabb,e.child2.aabb);if(n.Contains(e.aabb))break;e=e.parent}}else{this.m_root=d;d.parent=null;this.FreeNode(n)}}};K.b2DynamicTreeBroadPhase=function(){this.m_tree=new U;this.m_moveBuffer=new Vector;this.m_pairBuffer=new Vector;
this.m_pairCount=0};K.prototype.CreateProxy=function(d,n){var e=this.m_tree.CreateProxy(d,n);++this.m_proxyCount;this.BufferMove(e);return e};K.prototype.DestroyProxy=function(d){this.UnBufferMove(d);--this.m_proxyCount;this.m_tree.DestroyProxy(d)};K.prototype.MoveProxy=function(d,n,e){this.m_tree.MoveProxy(d,n,e)&&this.BufferMove(d)};K.prototype.TestOverlap=function(d,n){var e=this.m_tree.GetFatAABB(d),r=this.m_tree.GetFatAABB(n);return e.TestOverlap(r)};K.prototype.GetUserData=function(d){return this.m_tree.GetUserData(d)};
K.prototype.GetFatAABB=function(d){return this.m_tree.GetFatAABB(d)};K.prototype.GetProxyCount=function(){return this.m_proxyCount};K.prototype.UpdatePairs=function(d){var n=this;var e=n.m_pairCount=0,r;for(e=0;e<n.m_moveBuffer.length;++e){r=n.m_moveBuffer[e];var t=n.m_tree.GetFatAABB(r);n.m_tree.Query(function(u){if(u==r)return true;if(n.m_pairCount==n.m_pairBuffer.length)n.m_pairBuffer[n.m_pairCount]=new V;var w=n.m_pairBuffer[n.m_pairCount];w.proxyA=u<r?u:r;w.proxyB=u>=r?u:r;++n.m_pairCount;return true},
t)}for(e=n.m_moveBuffer.length=0;e<n.m_pairCount;){t=n.m_pairBuffer[e];var v=n.m_tree.GetUserData(t.proxyA),z=n.m_tree.GetUserData(t.proxyB);d(v,z);for(++e;e<n.m_pairCount;){v=n.m_pairBuffer[e];if(v.proxyA!=t.proxyA||v.proxyB!=t.proxyB)break;++e}}};K.prototype.Query=function(d,n){this.m_tree.Query(d,n)};K.prototype.RayCast=function(d,n){this.m_tree.RayCast(d,n)};K.prototype.Validate=function(){};K.prototype.Rebalance=function(d){if(d===undefined)d=0;this.m_tree.Rebalance(d)};K.prototype.BufferMove=
function(d){this.m_moveBuffer[this.m_moveBuffer.length]=d};K.prototype.UnBufferMove=function(d){this.m_moveBuffer.splice(parseInt(this.m_moveBuffer.indexOf(d)),1)};K.prototype.ComparePairs=function(){return 0};K.__implements={};K.__implements[ca]=true;ba.b2DynamicTreeNode=function(){this.aabb=new aa};ba.prototype.IsLeaf=function(){return this.child1==null};V.b2DynamicTreePair=function(){};Z.b2Manifold=function(){this.m_pointCount=0};Z.prototype.b2Manifold=function(){this.m_points=new Vector(G.b2_maxManifoldPoints);
for(var d=0;d<G.b2_maxManifoldPoints;d++)this.m_points[d]=new ga;this.m_localPlaneNormal=new R;this.m_localPoint=new R};Z.prototype.Reset=function(){for(var d=0;d<G.b2_maxManifoldPoints;d++)(this.m_points[d]instanceof ga?this.m_points[d]:null).Reset();this.m_localPlaneNormal.SetZero();this.m_localPoint.SetZero();this.m_pointCount=this.m_type=0};Z.prototype.Set=function(d){this.m_pointCount=d.m_pointCount;for(var n=0;n<G.b2_maxManifoldPoints;n++)(this.m_points[n]instanceof ga?this.m_points[n]:null).Set(d.m_points[n]);
this.m_localPlaneNormal.SetV(d.m_localPlaneNormal);this.m_localPoint.SetV(d.m_localPoint);this.m_type=d.m_type};Z.prototype.Copy=function(){var d=new Z;d.Set(this);return d};_A2J_postDefs.push(function(){Box2D.Collision.b2Manifold.e_circles=1;Box2D.Collision.b2Manifold.prototype.e_circles=Box2D.Collision.b2Manifold.e_circles;Box2D.Collision.b2Manifold.e_faceA=2;Box2D.Collision.b2Manifold.prototype.e_faceA=Box2D.Collision.b2Manifold.e_faceA;Box2D.Collision.b2Manifold.e_faceB=4;Box2D.Collision.b2Manifold.prototype.e_faceB=
Box2D.Collision.b2Manifold.e_faceB});ga.b2ManifoldPoint=function(){this.m_localPoint=new R;this.m_id=new da};ga.prototype.b2ManifoldPoint=function(){this.Reset()};ga.prototype.Reset=function(){this.m_localPoint.SetZero();this.m_tangentImpulse=this.m_normalImpulse=0;this.m_id.key=0};ga.prototype.Set=function(d){this.m_localPoint.SetV(d.m_localPoint);this.m_normalImpulse=d.m_normalImpulse;this.m_tangentImpulse=d.m_tangentImpulse;this.m_id.Set(d.m_id)};fa.b2OBB=function(){this.R=new A;this.center=new R;
this.extents=new R};c.b2Pair=function(){this.userData=null};c.prototype.SetBuffered=function(){this.status|=c.e_pairBuffered};c.prototype.ClearBuffered=function(){this.status&=~c.e_pairBuffered};c.prototype.IsBuffered=function(){return(this.status&c.e_pairBuffered)==c.e_pairBuffered};c.prototype.SetRemoved=function(){this.status|=c.e_pairRemoved};c.prototype.ClearRemoved=function(){this.status&=~c.e_pairRemoved};c.prototype.IsRemoved=function(){return(this.status&c.e_pairRemoved)==c.e_pairRemoved};
c.prototype.SetFinal=function(){this.status|=c.e_pairFinal};c.prototype.IsFinal=function(){return(this.status&c.e_pairFinal)==c.e_pairFinal};_A2J_postDefs.push(function(){Box2D.Collision.b2Pair.b2_nullProxy=parseInt(G.USHRT_MAX);Box2D.Collision.b2Pair.prototype.b2_nullProxy=Box2D.Collision.b2Pair.b2_nullProxy;Box2D.Collision.b2Pair.e_pairBuffered=1;Box2D.Collision.b2Pair.prototype.e_pairBuffered=Box2D.Collision.b2Pair.e_pairBuffered;Box2D.Collision.b2Pair.e_pairRemoved=2;Box2D.Collision.b2Pair.prototype.e_pairRemoved=
Box2D.Collision.b2Pair.e_pairRemoved;Box2D.Collision.b2Pair.e_pairFinal=4;Box2D.Collision.b2Pair.prototype.e_pairFinal=Box2D.Collision.b2Pair.e_pairFinal});g.b2PairManager=function(){};g.prototype.b2PairManager=function(){this.m_pairs=[];this.m_pairBuffer=[];this.m_pairBufferCount=this.m_pairCount=0;this.m_freePair=null};g.prototype.Initialize=function(d){this.m_broadPhase=d};g.prototype.AddBufferedPair=function(d,n){var e=this.AddPair(d,n);if(e.IsBuffered()==false){e.SetBuffered();this.m_pairBuffer[this.m_pairBufferCount]=
e;++this.m_pairBufferCount}e.ClearRemoved();Q.s_validate&&this.ValidateBuffer()};g.prototype.RemoveBufferedPair=function(d,n){var e=this.Find(d,n);if(e!=null){if(e.IsBuffered()==false){e.SetBuffered();this.m_pairBuffer[this.m_pairBufferCount]=e;++this.m_pairBufferCount}e.SetRemoved();Q.s_validate&&this.ValidateBuffer()}};g.prototype.Commit=function(d){var n=0;for(n=0;n<this.m_pairBufferCount;++n){var e=this.m_pairBuffer[n];e.ClearBuffered();var r=e.proxy1,t=e.proxy2;e.IsRemoved()||e.IsFinal()==false&&
d(r.userData,t.userData)}this.m_pairBufferCount=0;Q.s_validate&&this.ValidateTable()};g.prototype.AddPair=function(d,n){var e=d.pairs[n];if(e!=null)return e;if(this.m_freePair==null){this.m_freePair=new c;this.m_pairs.push(this.m_freePair)}e=this.m_freePair;this.m_freePair=e.next;e.proxy1=d;e.proxy2=n;e.status=0;e.userData=null;e.next=null;d.pairs[n]=e;n.pairs[d]=e;++this.m_pairCount;return e};g.prototype.RemovePair=function(d,n){var e=d.pairs[n];if(e==null)return null;var r=e.userData;delete d.pairs[n];
delete n.pairs[d];e.next=this.m_freePair;e.proxy1=null;e.proxy2=null;e.userData=null;e.status=0;this.m_freePair=e;--this.m_pairCount;return r};g.prototype.Find=function(d,n){return d.pairs[n]};g.prototype.ValidateBuffer=function(){};g.prototype.ValidateTable=function(){};k.b2Point=function(){this.p=new R};k.prototype.Support=function(){return this.p};k.prototype.GetFirstVertex=function(){return this.p};h.b2Proxy=function(){this.lowerBounds=new Vector_a2j_Number(2);this.upperBounds=new Vector_a2j_Number(2);
this.pairs=new L;this.userData=null};h.prototype.IsValid=function(){return this.overlapCount!=Q.b2_invalid};o.b2RayCastInput=function(){this.p1=new R;this.p2=new R};o.prototype.b2RayCastInput=function(d,n,e){if(d===undefined)d=null;if(n===undefined)n=null;if(e===undefined)e=1;d&&this.p1.SetV(d);n&&this.p2.SetV(n);this.maxFraction=e};q.b2RayCastOutput=function(){this.normal=new R};l.b2Segment=function(){this.p1=new R;this.p2=new R};l.prototype.TestSegment=function(d,n,e,r){if(r===undefined)r=0;var t=
e.p1,v=e.p2.x-t.x,z=e.p2.y-t.y;e=this.p2.y-this.p1.y;var u=-(this.p2.x-this.p1.x),w=100*Number.MIN_VALUE,E=-(v*e+z*u);if(E>w){var P=t.x-this.p1.x,Y=t.y-this.p1.y;t=P*e+Y*u;if(0<=t&&t<=r*E){r=-v*Y+z*P;if(-w*E<=r&&r<=E*(1+w)){t/=E;r=Math.sqrt(e*e+u*u);e/=r;u/=r;d[0]=t;n.Set(e,u);return true}}}return false};l.prototype.Extend=function(d){this.ExtendForward(d);this.ExtendBackward(d)};l.prototype.ExtendForward=function(d){var n=this.p2.x-this.p1.x,e=this.p2.y-this.p1.y;d=Math.min(n>0?(d.upperBound.x-this.p1.x)/
n:n<0?(d.lowerBound.x-this.p1.x)/n:Number.POSITIVE_INFINITY,e>0?(d.upperBound.y-this.p1.y)/e:e<0?(d.lowerBound.y-this.p1.y)/e:Number.POSITIVE_INFINITY);this.p2.x=this.p1.x+n*d;this.p2.y=this.p1.y+e*d};l.prototype.ExtendBackward=function(d){var n=-this.p2.x+this.p1.x,e=-this.p2.y+this.p1.y;d=Math.min(n>0?(d.upperBound.x-this.p2.x)/n:n<0?(d.lowerBound.x-this.p2.x)/n:Number.POSITIVE_INFINITY,e>0?(d.upperBound.y-this.p2.y)/e:e<0?(d.lowerBound.y-this.p2.y)/e:Number.POSITIVE_INFINITY);this.p1.x=this.p2.x+
n*d;this.p1.y=this.p2.y+e*d};a.b2SeparationFunction=function(){this.m_localPoint=new R;this.m_axis=new R};a.prototype.Initialize=function(d,n,e,r,t){this.m_proxyA=n;this.m_proxyB=r;var v=parseInt(d.count);G.b2Assert(0<v&&v<3);var z,u,w,E,P=E=w=r=n=0,Y=0;P=0;if(v==1){this.m_type=a.e_points;z=this.m_proxyA.GetVertex(d.indexA[0]);u=this.m_proxyB.GetVertex(d.indexB[0]);v=z;d=e.R;n=e.position.x+(d.col1.x*v.x+d.col2.x*v.y);r=e.position.y+(d.col1.y*v.x+d.col2.y*v.y);v=u;d=t.R;w=t.position.x+(d.col1.x*v.x+
d.col2.x*v.y);E=t.position.y+(d.col1.y*v.x+d.col2.y*v.y);this.m_axis.x=w-n;this.m_axis.y=E-r;this.m_axis.Normalize()}else{if(d.indexB[0]==d.indexB[1]){this.m_type=a.e_faceA;n=this.m_proxyA.GetVertex(d.indexA[0]);r=this.m_proxyA.GetVertex(d.indexA[1]);u=this.m_proxyB.GetVertex(d.indexB[0]);this.m_localPoint.x=0.5*(n.x+r.x);this.m_localPoint.y=0.5*(n.y+r.y);this.m_axis=N.CrossVF(N.SubtractVV(r,n),1);this.m_axis.Normalize();v=this.m_axis;d=e.R;P=d.col1.x*v.x+d.col2.x*v.y;Y=d.col1.y*v.x+d.col2.y*v.y;
v=this.m_localPoint;d=e.R;n=e.position.x+(d.col1.x*v.x+d.col2.x*v.y);r=e.position.y+(d.col1.y*v.x+d.col2.y*v.y);v=u;d=t.R;w=t.position.x+(d.col1.x*v.x+d.col2.x*v.y);E=t.position.y+(d.col1.y*v.x+d.col2.y*v.y);P=(w-n)*P+(E-r)*Y}else if(d.indexA[0]==d.indexA[0]){this.m_type=a.e_faceB;w=this.m_proxyB.GetVertex(d.indexB[0]);E=this.m_proxyB.GetVertex(d.indexB[1]);z=this.m_proxyA.GetVertex(d.indexA[0]);this.m_localPoint.x=0.5*(w.x+E.x);this.m_localPoint.y=0.5*(w.y+E.y);this.m_axis=N.CrossVF(N.SubtractVV(E,
w),1);this.m_axis.Normalize();v=this.m_axis;d=t.R;P=d.col1.x*v.x+d.col2.x*v.y;Y=d.col1.y*v.x+d.col2.y*v.y;v=this.m_localPoint;d=t.R;w=t.position.x+(d.col1.x*v.x+d.col2.x*v.y);E=t.position.y+(d.col1.y*v.x+d.col2.y*v.y);v=z;d=e.R;n=e.position.x+(d.col1.x*v.x+d.col2.x*v.y);r=e.position.y+(d.col1.y*v.x+d.col2.y*v.y);P=(n-w)*P+(r-E)*Y}else{n=this.m_proxyA.GetVertex(d.indexA[0]);r=this.m_proxyA.GetVertex(d.indexA[1]);w=this.m_proxyB.GetVertex(d.indexB[0]);E=this.m_proxyB.GetVertex(d.indexB[1]);N.MulX(e,
z);z=N.MulMV(e.R,N.SubtractVV(r,n));N.MulX(t,u);P=N.MulMV(t.R,N.SubtractVV(E,w));t=z.x*z.x+z.y*z.y;u=P.x*P.x+P.y*P.y;d=N.SubtractVV(P,z);e=z.x*d.x+z.y*d.y;d=P.x*d.x+P.y*d.y;z=z.x*P.x+z.y*P.y;Y=t*u-z*z;P=0;if(Y!=0)P=N.Clamp((z*d-e*u)/Y,0,1);if((z*P+d)/u<0)P=N.Clamp((z-e)/t,0,1);z=new R;z.x=n.x+P*(r.x-n.x);z.y=n.y+P*(r.y-n.y);u=new R;u.x=w.x+P*(E.x-w.x);u.y=w.y+P*(E.y-w.y);if(P==0||P==1){this.m_type=a.e_faceB;this.m_axis=N.CrossVF(N.SubtractVV(E,w),1);this.m_axis.Normalize();this.m_localPoint=u}else{this.m_type=
a.e_faceA;this.m_axis=N.CrossVF(N.SubtractVV(r,n),1);this.m_localPoint=z}}P<0&&this.m_axis.NegativeSelf()}};a.prototype.Evaluate=function(d,n){var e,r,t=0;switch(this.m_type){case a.e_points:e=N.MulTMV(d.R,this.m_axis);r=N.MulTMV(n.R,this.m_axis.GetNegative());e=this.m_proxyA.GetSupportVertex(e);r=this.m_proxyB.GetSupportVertex(r);e=N.MulX(d,e);r=N.MulX(n,r);return t=(r.x-e.x)*this.m_axis.x+(r.y-e.y)*this.m_axis.y;case a.e_faceA:t=N.MulMV(d.R,this.m_axis);e=N.MulX(d,this.m_localPoint);r=N.MulTMV(n.R,
t.GetNegative());r=this.m_proxyB.GetSupportVertex(r);r=N.MulX(n,r);return t=(r.x-e.x)*t.x+(r.y-e.y)*t.y;case a.e_faceB:t=N.MulMV(n.R,this.m_axis);r=N.MulX(n,this.m_localPoint);e=N.MulTMV(d.R,t.GetNegative());e=this.m_proxyA.GetSupportVertex(e);e=N.MulX(d,e);return t=(e.x-r.x)*t.x+(e.y-r.y)*t.y;default:G.b2Assert(false);return 0}};_A2J_postDefs.push(function(){Box2D.Collision.b2SeparationFunction.e_points=1;Box2D.Collision.b2SeparationFunction.prototype.e_points=Box2D.Collision.b2SeparationFunction.e_points;
Box2D.Collision.b2SeparationFunction.e_faceA=2;Box2D.Collision.b2SeparationFunction.prototype.e_faceA=Box2D.Collision.b2SeparationFunction.e_faceA;Box2D.Collision.b2SeparationFunction.e_faceB=4;Box2D.Collision.b2SeparationFunction.prototype.e_faceB=Box2D.Collision.b2SeparationFunction.e_faceB});b.b2Simplex=function(){this.m_v1=new m;this.m_v2=new m;this.m_v3=new m;this.m_vertices=new Vector(3)};b.prototype.b2Simplex=function(){this.m_vertices[0]=this.m_v1;this.m_vertices[1]=this.m_v2;this.m_vertices[2]=
this.m_v3};b.prototype.ReadCache=function(d,n,e,r,t){G.b2Assert(0<=d.count&&d.count<=3);var v,z;this.m_count=d.count;for(var u=this.m_vertices,w=0;w<this.m_count;w++){var E=u[w];E.indexA=d.indexA[w];E.indexB=d.indexB[w];v=n.GetVertex(E.indexA);z=r.GetVertex(E.indexB);E.wA=N.MulX(e,v);E.wB=N.MulX(t,z);E.w=N.SubtractVV(E.wB,E.wA);E.a=0}if(this.m_count>1){d=d.metric;v=this.GetMetric();if(v<0.5*d||2*d<v||v<Number.MIN_VALUE)this.m_count=0}if(this.m_count==0){E=u[0];E.indexA=0;E.indexB=0;v=n.GetVertex(0);
z=r.GetVertex(0);E.wA=N.MulX(e,v);E.wB=N.MulX(t,z);E.w=N.SubtractVV(E.wB,E.wA);this.m_count=1}};b.prototype.WriteCache=function(d){d.metric=this.GetMetric();d.count=a2j.parseUInt(this.m_count);for(var n=this.m_vertices,e=0;e<this.m_count;e++){d.indexA[e]=a2j.parseUInt(n[e].indexA);d.indexB[e]=a2j.parseUInt(n[e].indexB)}};b.prototype.GetSearchDirection=function(){switch(this.m_count){case 1:return this.m_v1.w.GetNegative();case 2:var d=N.SubtractVV(this.m_v2.w,this.m_v1.w);return N.CrossVV(d,this.m_v1.w.GetNegative())>
0?N.CrossFV(1,d):N.CrossVF(d,1);default:G.b2Assert(false);return new R}};b.prototype.GetClosestPoint=function(){switch(this.m_count){case 0:G.b2Assert(false);return new R;case 1:return this.m_v1.w;case 2:return new R(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);default:G.b2Assert(false);return new R}};b.prototype.GetWitnessPoints=function(d,n){switch(this.m_count){case 0:G.b2Assert(false);break;case 1:d.SetV(this.m_v1.wA);n.SetV(this.m_v1.wB);
break;case 2:d.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x;d.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y;n.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x;n.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:n.x=d.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x;n.y=d.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y;break;default:G.b2Assert(false)}};b.prototype.GetMetric=function(){switch(this.m_count){case 0:G.b2Assert(false);
return 0;case 1:return 0;case 2:return N.SubtractVV(this.m_v1.w,this.m_v2.w).Length();case 3:return N.CrossVV(N.SubtractVV(this.m_v2.w,this.m_v1.w),N.SubtractVV(this.m_v3.w,this.m_v1.w));default:G.b2Assert(false);return 0}};b.prototype.Solve2=function(){var d=this.m_v1.w,n=this.m_v2.w,e=N.SubtractVV(n,d);d=-(d.x*e.x+d.y*e.y);if(d<=0)this.m_count=this.m_v1.a=1;else{n=n.x*e.x+n.y*e.y;if(n<=0){this.m_count=this.m_v2.a=1;this.m_v1.Set(this.m_v2)}else{e=1/(n+d);this.m_v1.a=n*e;this.m_v2.a=d*e;this.m_count=
2}}};b.prototype.Solve3=function(){var d=this.m_v1.w,n=this.m_v2.w,e=this.m_v3.w,r=N.SubtractVV(n,d),t=N.Dot(d,r),v=N.Dot(n,r);t=-t;var z=N.SubtractVV(e,d),u=N.Dot(d,z),w=N.Dot(e,z);u=-u;var E=N.SubtractVV(e,n),P=N.Dot(n,E);E=N.Dot(e,E);P=-P;z=N.CrossVV(r,z);r=z*N.CrossVV(n,e);e=z*N.CrossVV(e,d);d=z*N.CrossVV(d,n);if(t<=0&&u<=0)this.m_count=this.m_v1.a=1;else if(v>0&&t>0&&d<=0){w=1/(v+t);this.m_v1.a=v*w;this.m_v2.a=t*w;this.m_count=2}else if(w>0&&u>0&&e<=0){v=1/(w+u);this.m_v1.a=w*v;this.m_v3.a=u*
v;this.m_count=2;this.m_v2.Set(this.m_v3)}else if(v<=0&&P<=0){this.m_count=this.m_v2.a=1;this.m_v1.Set(this.m_v2)}else if(w<=0&&E<=0){this.m_count=this.m_v3.a=1;this.m_v1.Set(this.m_v3)}else if(E>0&&P>0&&r<=0){v=1/(E+P);this.m_v2.a=E*v;this.m_v3.a=P*v;this.m_count=2;this.m_v1.Set(this.m_v3)}else{v=1/(r+e+d);this.m_v1.a=r*v;this.m_v2.a=e*v;this.m_v3.a=d*v;this.m_count=3}};f.b2SimplexCache=function(){this.indexA=new Vector_a2j_Number(3);this.indexB=new Vector_a2j_Number(3)};m.b2SimplexVertex=function(){};
m.prototype.Set=function(d){this.wA.SetV(d.wA);this.wB.SetV(d.wB);this.w.SetV(d.w);this.a=d.a;this.indexA=d.indexA;this.indexB=d.indexB};p.b2TimeOfImpact=function(){};p.prototype.TimeOfImpact=function(d){++p.b2_toiCalls;var n=d.proxyA,e=d.proxyB,r=d.sweepA,t=d.sweepB;G.b2Assert(r.t0==t.t0);G.b2Assert(1-r.t0>Number.MIN_VALUE);var v=n.m_radius+e.m_radius;d=d.tolerance;var z=0,u=0,w=0;p.s_cache.count=0;for(p.s_distanceInput.useRadii=false;;){r.GetTransform(p.s_xfA,z);t.GetTransform(p.s_xfB,z);p.s_distanceInput.proxyA=
n;p.s_distanceInput.proxyB=e;p.s_distanceInput.transformA=p.s_xfA;p.s_distanceInput.transformB=p.s_xfB;y.Distance(p.s_distanceOutput,p.s_cache,p.s_distanceInput);if(p.s_distanceOutput.distance<=0){z=1;break}p.s_fcn.Initialize(p.s_cache,n,p.s_xfA,e,p.s_xfB);var E=p.s_fcn.Evaluate(p.s_xfA,p.s_xfB);if(E<=0){z=1;break}if(u==0)w=E>v?N.Max(v-d,0.75*v):N.Max(E-d,0.02*v);if(E-w<0.5*d){if(u==0){z=1;break}break}var P=z,Y=z,S=1;E=E;r.GetTransform(p.s_xfA,S);t.GetTransform(p.s_xfB,S);var ea=p.s_fcn.Evaluate(p.s_xfA,
p.s_xfB);if(ea>=w){z=1;break}for(var ha=0;;){var ia=0;ia=ha&1?Y+(w-E)*(S-Y)/(ea-E):0.5*(Y+S);r.GetTransform(p.s_xfA,ia);t.GetTransform(p.s_xfB,ia);var ja=p.s_fcn.Evaluate(p.s_xfA,p.s_xfB);if(N.Abs(ja-w)<0.025*d){P=ia;break}if(ja>w){Y=ia;E=ja}else{S=ia;ea=ja}++ha;++p.b2_toiRootIters;if(ha==50)break}p.b2_toiMaxRootIters=N.Max(p.b2_toiMaxRootIters,ha);if(P<(1+100*Number.MIN_VALUE)*z)break;z=P;u++;++p.b2_toiIters;if(u==1E3)break}p.b2_toiMaxIters=N.Max(p.b2_toiMaxIters,u);return z};p.TimeOfImpact=p.prototype.TimeOfImpact;
_A2J_postDefs.push(function(){Box2D.Collision.b2TimeOfImpact.b2_toiCalls=0;Box2D.Collision.b2TimeOfImpact.prototype.b2_toiCalls=Box2D.Collision.b2TimeOfImpact.b2_toiCalls;Box2D.Collision.b2TimeOfImpact.b2_toiIters=0;Box2D.Collision.b2TimeOfImpact.prototype.b2_toiIters=Box2D.Collision.b2TimeOfImpact.b2_toiIters;Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters=0;Box2D.Collision.b2TimeOfImpact.prototype.b2_toiMaxIters=Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters;Box2D.Collision.b2TimeOfImpact.b2_toiRootIters=
0;Box2D.Collision.b2TimeOfImpact.prototype.b2_toiRootIters=Box2D.Collision.b2TimeOfImpact.b2_toiRootIters;Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters=0;Box2D.Collision.b2TimeOfImpact.prototype.b2_toiMaxRootIters=Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters;Box2D.Collision.b2TimeOfImpact.s_cache=new f;Box2D.Collision.b2TimeOfImpact.prototype.s_cache=Box2D.Collision.b2TimeOfImpact.s_cache;Box2D.Collision.b2TimeOfImpact.s_distanceInput=new x;Box2D.Collision.b2TimeOfImpact.prototype.s_distanceInput=
Box2D.Collision.b2TimeOfImpact.s_distanceInput;Box2D.Collision.b2TimeOfImpact.s_xfA=new C;Box2D.Collision.b2TimeOfImpact.prototype.s_xfA=Box2D.Collision.b2TimeOfImpact.s_xfA;Box2D.Collision.b2TimeOfImpact.s_xfB=new C;Box2D.Collision.b2TimeOfImpact.prototype.s_xfB=Box2D.Collision.b2TimeOfImpact.s_xfB;Box2D.Collision.b2TimeOfImpact.s_fcn=new a;Box2D.Collision.b2TimeOfImpact.prototype.s_fcn=Box2D.Collision.b2TimeOfImpact.s_fcn;Box2D.Collision.b2TimeOfImpact.s_distanceOutput=new J;Box2D.Collision.b2TimeOfImpact.prototype.s_distanceOutput=
Box2D.Collision.b2TimeOfImpact.s_distanceOutput});D.b2TOIInput=function(){this.proxyA=new M;this.proxyB=new M;this.sweepA=new s;this.sweepB=new s};B.b2WorldManifold=function(){this.m_normal=new R};B.prototype.b2WorldManifold=function(){this.m_points=new Vector(G.b2_maxManifoldPoints);for(var d=0;d<G.b2_maxManifoldPoints;d++)this.m_points[d]=new R};B.prototype.Initialize=function(d,n,e,r,t){if(e===undefined)e=0;if(t===undefined)t=0;if(d.m_pointCount!=0){var v=0,z,u,w=0,E=0,P=0,Y=0,S=0;z=0;switch(d.m_type){case Z.e_circles:u=
n.R;z=d.m_localPoint;v=n.position.x+u.col1.x*z.x+u.col2.x*z.y;n=n.position.y+u.col1.y*z.x+u.col2.y*z.y;u=r.R;z=d.m_points[0].m_localPoint;d=r.position.x+u.col1.x*z.x+u.col2.x*z.y;r=r.position.y+u.col1.y*z.x+u.col2.y*z.y;z=d-v;u=r-n;w=z*z+u*u;if(w>Number.MIN_VALUE*Number.MIN_VALUE){w=Math.sqrt(w);this.m_normal.x=z/w;this.m_normal.y=u/w}else{this.m_normal.x=1;this.m_normal.y=0}z=n+e*this.m_normal.y;r=r-t*this.m_normal.y;this.m_points[0].x=0.5*(v+e*this.m_normal.x+(d-t*this.m_normal.x));this.m_points[0].y=
0.5*(z+r);break;case Z.e_faceA:u=n.R;z=d.m_localPlaneNormal;w=u.col1.x*z.x+u.col2.x*z.y;E=u.col1.y*z.x+u.col2.y*z.y;u=n.R;z=d.m_localPoint;P=n.position.x+u.col1.x*z.x+u.col2.x*z.y;Y=n.position.y+u.col1.y*z.x+u.col2.y*z.y;this.m_normal.x=w;this.m_normal.y=E;for(v=0;v<d.m_pointCount;v++){u=r.R;z=d.m_points[v].m_localPoint;S=r.position.x+u.col1.x*z.x+u.col2.x*z.y;z=r.position.y+u.col1.y*z.x+u.col2.y*z.y;this.m_points[v].x=S+0.5*(e-(S-P)*w-(z-Y)*E-t)*w;this.m_points[v].y=z+0.5*(e-(S-P)*w-(z-Y)*E-t)*E}break;
case Z.e_faceB:u=r.R;z=d.m_localPlaneNormal;w=u.col1.x*z.x+u.col2.x*z.y;E=u.col1.y*z.x+u.col2.y*z.y;u=r.R;z=d.m_localPoint;P=r.position.x+u.col1.x*z.x+u.col2.x*z.y;Y=r.position.y+u.col1.y*z.x+u.col2.y*z.y;this.m_normal.x=-w;this.m_normal.y=-E;for(v=0;v<d.m_pointCount;v++){u=n.R;z=d.m_points[v].m_localPoint;S=n.position.x+u.col1.x*z.x+u.col2.x*z.y;z=n.position.y+u.col1.y*z.x+u.col2.y*z.y;this.m_points[v].x=S+0.5*(t-(S-P)*w-(z-Y)*E-e)*w;this.m_points[v].y=z+0.5*(t-(S-P)*w-(z-Y)*E-e)*E}}}};O.ClipVertex=
function(){this.v=new R;this.id=new da};O.prototype.Set=function(d){this.v.SetV(d.v);this.id.Set(d.id)};W.Features=function(){};Object.defineProperty(W.prototype,"referenceEdge",{enumerable:false,configurable:true,get:function(){return this._referenceEdge}});Object.defineProperty(W.prototype,"referenceEdge",{enumerable:false,configurable:true,set:function(d){if(d===undefined)d=0;this._referenceEdge=d;this._m_id._key=this._m_id._key&4294967040|this._referenceEdge&255}});Object.defineProperty(W.prototype,
"incidentEdge",{enumerable:false,configurable:true,get:function(){return this._incidentEdge}});Object.defineProperty(W.prototype,"incidentEdge",{enumerable:false,configurable:true,set:function(d){if(d===undefined)d=0;this._incidentEdge=d;this._m_id._key=this._m_id._key&4294902015|this._incidentEdge<<8&65280}});Object.defineProperty(W.prototype,"incidentVertex",{enumerable:false,configurable:true,get:function(){return this._incidentVertex}});Object.defineProperty(W.prototype,"incidentVertex",{enumerable:false,
configurable:true,set:function(d){if(d===undefined)d=0;this._incidentVertex=d;this._m_id._key=this._m_id._key&4278255615|this._incidentVertex<<16&16711680}});Object.defineProperty(W.prototype,"flip",{enumerable:false,configurable:true,get:function(){return this._flip}});Object.defineProperty(W.prototype,"flip",{enumerable:false,configurable:true,set:function(d){if(d===undefined)d=0;this._flip=d;this._m_id._key=this._m_id._key&16777215|this._flip<<24&4278190080}})})();
(function(){var L=Box2D.Common.b2Settings,I=Box2D.Collision.Shapes.b2CircleShape,H=Box2D.Collision.Shapes.b2EdgeChainDef,F=Box2D.Collision.Shapes.b2EdgeShape,G=Box2D.Collision.Shapes.b2MassData,A=Box2D.Collision.Shapes.b2PolygonShape,N=Box2D.Collision.Shapes.b2Shape,s=Box2D.Common.Math.b2Mat22,C=Box2D.Common.Math.b2Math,R=Box2D.Common.Math.b2Transform,aa=Box2D.Common.Math.b2Vec2;L=Box2D.Common.b2Settings;var $=Box2D.Collision.b2Distance,T=Box2D.Collision.b2DistanceInput,Q=Box2D.Collision.b2DistanceOutput,
X=Box2D.Collision.b2DistanceProxy,da=Box2D.Collision.b2SimplexCache;I=Box2D.Collision.Shapes.b2CircleShape;H=Box2D.Collision.Shapes.b2EdgeChainDef;F=Box2D.Collision.Shapes.b2EdgeShape;G=Box2D.Collision.Shapes.b2MassData;A=Box2D.Collision.Shapes.b2PolygonShape;N=Box2D.Collision.Shapes.b2Shape;I.inherit(Box2D.Collision.Shapes.b2Shape);I.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;I.b2CircleShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments);this.m_p=new aa};
I.prototype.Copy=function(){var j=new I;j.Set(this);return j};I.prototype.Set=function(j){this.__super.Set.call(this,j);if(a2j.is(j,I))this.m_p.SetV((j instanceof I?j:null).m_p)};I.prototype.TestPoint=function(j,y){var x=j.R,J=j.position.x+(x.col1.x*this.m_p.x+x.col2.x*this.m_p.y);x=j.position.y+(x.col1.y*this.m_p.x+x.col2.y*this.m_p.y);J=y.x-J;x=y.y-x;return J*J+x*x<=this.m_radius*this.m_radius};I.prototype.RayCast=function(j,y,x){var J=x.R,M=y.p1.x-(x.position.x+(J.col1.x*this.m_p.x+J.col2.x*this.m_p.y));
x=y.p1.y-(x.position.y+(J.col1.y*this.m_p.x+J.col2.y*this.m_p.y));J=y.p2.x-y.p1.x;var U=y.p2.y-y.p1.y,K=M*J+x*U,ba=J*J+U*U,V=K*K-ba*(M*M+x*x-this.m_radius*this.m_radius);if(V<0||ba<Number.MIN_VALUE)return false;K=-(K+Math.sqrt(V));if(0<=K&&K<=y.maxFraction*ba){K/=ba;j.fraction=K;j.normal.x=M+K*J;j.normal.y=x+K*U;j.normal.Normalize();return true}return false};I.prototype.ComputeAABB=function(j,y){var x=y.R,J=y.position.x+(x.col1.x*this.m_p.x+x.col2.x*this.m_p.y);x=y.position.y+(x.col1.y*this.m_p.x+
x.col2.y*this.m_p.y);j.lowerBound.Set(J-this.m_radius,x-this.m_radius);j.upperBound.Set(J+this.m_radius,x+this.m_radius)};I.prototype.ComputeMass=function(j,y){if(y===undefined)y=0;j.mass=y*L.b2_pi*this.m_radius*this.m_radius;j.center.SetV(this.m_p);j.I=j.mass*(0.5*this.m_radius*this.m_radius+(this.m_p.x*this.m_p.x+this.m_p.y*this.m_p.y))};I.prototype.ComputeSubmergedArea=function(j,y,x,J){if(y===undefined)y=0;x=C.MulX(x,this.m_p);var M=-(C.Dot(j,x)-y);if(M<-this.m_radius+Number.MIN_VALUE)return 0;
if(M>this.m_radius){J.SetV(x);return Math.PI*this.m_radius*this.m_radius}y=this.m_radius*this.m_radius;var U=M*M;M=y*(Math.asin(M/this.m_radius)+Math.PI/2)+M*Math.sqrt(y-U);y=-2/3*Math.pow(y-U,1.5)/M;J.x=x.x+j.x*y;J.y=x.y+j.y*y;return M};I.prototype.GetLocalPosition=function(){return this.m_p};I.prototype.SetLocalPosition=function(j){this.m_p.SetV(j)};I.prototype.GetRadius=function(){return this.m_radius};I.prototype.SetRadius=function(j){if(j===undefined)j=0;this.m_radius=j};I.prototype.b2CircleShape=
function(j){if(j===undefined)j=0;this.__super.b2Shape.call(this);this.m_type=this.e_circleShape;this.m_radius=j};H.b2EdgeChainDef=function(){};H.prototype.b2EdgeChainDef=function(){this.vertexCount=0;this.isALoop=true;this.vertices=[]};F.inherit(Box2D.Collision.Shapes.b2Shape);F.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;F.b2EdgeShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments);this.s_supportVec=new aa;this.m_v1=new aa;this.m_v2=new aa;this.m_coreV1=new aa;
this.m_coreV2=new aa;this.m_normal=new aa;this.m_direction=new aa;this.m_cornerDir1=new aa;this.m_cornerDir2=new aa};F.prototype.TestPoint=function(){return false};F.prototype.RayCast=function(j,y,x){var J,M=y.p2.x-y.p1.x,U=y.p2.y-y.p1.y;J=x.R;var K=x.position.x+(J.col1.x*this.m_v1.x+J.col2.x*this.m_v1.y),ba=x.position.y+(J.col1.y*this.m_v1.x+J.col2.y*this.m_v1.y),V=x.position.y+(J.col1.y*this.m_v2.x+J.col2.y*this.m_v2.y)-ba;x=-(x.position.x+(J.col1.x*this.m_v2.x+J.col2.x*this.m_v2.y)-K);J=100*Number.MIN_VALUE;
var Z=-(M*V+U*x);if(Z>J){K=y.p1.x-K;var ga=y.p1.y-ba;ba=K*V+ga*x;if(0<=ba&&ba<=y.maxFraction*Z){y=-M*ga+U*K;if(-J*Z<=y&&y<=Z*(1+J)){ba/=Z;j.fraction=ba;y=Math.sqrt(V*V+x*x);j.normal.x=V/y;j.normal.y=x/y;return true}}}return false};F.prototype.ComputeAABB=function(j,y){var x=y.R,J=y.position.x+(x.col1.x*this.m_v1.x+x.col2.x*this.m_v1.y),M=y.position.y+(x.col1.y*this.m_v1.x+x.col2.y*this.m_v1.y),U=y.position.x+(x.col1.x*this.m_v2.x+x.col2.x*this.m_v2.y);x=y.position.y+(x.col1.y*this.m_v2.x+x.col2.y*
this.m_v2.y);if(J<U){j.lowerBound.x=J;j.upperBound.x=U}else{j.lowerBound.x=U;j.upperBound.x=J}if(M<x){j.lowerBound.y=M;j.upperBound.y=x}else{j.lowerBound.y=x;j.upperBound.y=M}};F.prototype.ComputeMass=function(j){j.mass=0;j.center.SetV(this.m_v1);j.I=0};F.prototype.ComputeSubmergedArea=function(j,y,x,J){if(y===undefined)y=0;var M=new aa(j.x*y,j.y*y),U=C.MulX(x,this.m_v1);x=C.MulX(x,this.m_v2);var K=C.Dot(j,U)-y;j=C.Dot(j,x)-y;if(K>0)if(j>0)return 0;else{U.x=-j/(K-j)*U.x+K/(K-j)*x.x;U.y=-j/(K-j)*U.y+
K/(K-j)*x.y}else if(j>0){x.x=-j/(K-j)*U.x+K/(K-j)*x.x;x.y=-j/(K-j)*U.y+K/(K-j)*x.y}J.x=(M.x+U.x+x.x)/3;J.y=(M.y+U.y+x.y)/3;return 0.5*((U.x-M.x)*(x.y-M.y)-(U.y-M.y)*(x.x-M.x))};F.prototype.GetLength=function(){return this.m_length};F.prototype.GetVertex1=function(){return this.m_v1};F.prototype.GetVertex2=function(){return this.m_v2};F.prototype.GetCoreVertex1=function(){return this.m_coreV1};F.prototype.GetCoreVertex2=function(){return this.m_coreV2};F.prototype.GetNormalVector=function(){return this.m_normal};
F.prototype.GetDirectionVector=function(){return this.m_direction};F.prototype.GetCorner1Vector=function(){return this.m_cornerDir1};F.prototype.GetCorner2Vector=function(){return this.m_cornerDir2};F.prototype.Corner1IsConvex=function(){return this.m_cornerConvex1};F.prototype.Corner2IsConvex=function(){return this.m_cornerConvex2};F.prototype.GetFirstVertex=function(j){var y=j.R;return new aa(j.position.x+(y.col1.x*this.m_coreV1.x+y.col2.x*this.m_coreV1.y),j.position.y+(y.col1.y*this.m_coreV1.x+
y.col2.y*this.m_coreV1.y))};F.prototype.GetNextEdge=function(){return this.m_nextEdge};F.prototype.GetPrevEdge=function(){return this.m_prevEdge};F.prototype.Support=function(j,y,x){if(y===undefined)y=0;if(x===undefined)x=0;var J=j.R,M=j.position.x+(J.col1.x*this.m_coreV1.x+J.col2.x*this.m_coreV1.y),U=j.position.y+(J.col1.y*this.m_coreV1.x+J.col2.y*this.m_coreV1.y),K=j.position.x+(J.col1.x*this.m_coreV2.x+J.col2.x*this.m_coreV2.y);j=j.position.y+(J.col1.y*this.m_coreV2.x+J.col2.y*this.m_coreV2.y);
if(M*y+U*x>K*y+j*x){this.s_supportVec.x=M;this.s_supportVec.y=U}else{this.s_supportVec.x=K;this.s_supportVec.y=j}return this.s_supportVec};F.prototype.b2EdgeShape=function(j,y){this.__super.b2Shape.call(this);this.m_type=this.e_edgeShape;this.m_nextEdge=this.m_prevEdge=null;this.m_v1=j;this.m_v2=y;this.m_direction.Set(this.m_v2.x-this.m_v1.x,this.m_v2.y-this.m_v1.y);this.m_length=this.m_direction.Normalize();this.m_normal.Set(this.m_direction.y,-this.m_direction.x);this.m_coreV1.Set(-L.b2_toiSlop*
(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-L.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y);this.m_coreV2.Set(-L.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+this.m_v2.x,-L.b2_toiSlop*(this.m_normal.y+this.m_direction.y)+this.m_v2.y);this.m_cornerDir1=this.m_normal;this.m_cornerDir2.Set(-this.m_normal.x,-this.m_normal.y)};F.prototype.SetPrevEdge=function(j,y,x,J){this.m_prevEdge=j;this.m_coreV1=y;this.m_cornerDir1=x;this.m_cornerConvex1=J};F.prototype.SetNextEdge=function(j,
y,x,J){this.m_nextEdge=j;this.m_coreV2=y;this.m_cornerDir2=x;this.m_cornerConvex2=J};G.b2MassData=function(){this.mass=0;this.center=new aa(0,0);this.I=0};A.inherit(Box2D.Collision.Shapes.b2Shape);A.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;A.b2PolygonShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments)};A.prototype.Copy=function(){var j=new A;j.Set(this);return j};A.prototype.Set=function(j){this.__super.Set.call(this,j);if(a2j.is(j,A)){j=j instanceof A?
j:null;this.m_centroid.SetV(j.m_centroid);this.m_vertexCount=j.m_vertexCount;this.Reserve(this.m_vertexCount);for(var y=0;y<this.m_vertexCount;y++){this.m_vertices[y].SetV(j.m_vertices[y]);this.m_normals[y].SetV(j.m_normals[y])}}};A.prototype.SetAsArray=function(j,y){if(y===undefined)y=0;var x=new Vector,J=0,M;for(J=0;J<j.length;++J){M=j[J];x.push(M)}this.SetAsVector(x,y)};A.prototype.AsArray=function(j,y){if(y===undefined)y=0;var x=new A;x.SetAsArray(j,y);return x};A.AsArray=A.prototype.AsArray;
A.prototype.SetAsVector=function(j,y){if(y===undefined)y=0;if(y==0)y=j.length;L.b2Assert(2<=y);this.m_vertexCount=y;this.Reserve(y);var x=0;for(x=0;x<this.m_vertexCount;x++)this.m_vertices[x].SetV(j[x]);for(x=0;x<this.m_vertexCount;++x){var J=parseInt(x),M=parseInt(x+1<this.m_vertexCount?x+1:0);J=C.SubtractVV(this.m_vertices[M],this.m_vertices[J]);L.b2Assert(J.LengthSquared()>Number.MIN_VALUE);this.m_normals[x].SetV(C.CrossVF(J,1));this.m_normals[x].Normalize()}this.m_centroid=this.ComputeCentroid(this.m_vertices,
this.m_vertexCount)};A.prototype.AsVector=function(j,y){if(y===undefined)y=0;var x=new A;x.SetAsVector(j,y);return x};A.AsVector=A.prototype.AsVector;A.prototype.SetAsBox=function(j,y){if(j===undefined)j=0;if(y===undefined)y=0;this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-j,-y);this.m_vertices[1].Set(j,-y);this.m_vertices[2].Set(j,y);this.m_vertices[3].Set(-j,y);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1,0);this.m_centroid.SetZero()};
A.prototype.AsBox=function(j,y){if(j===undefined)j=0;if(y===undefined)y=0;var x=new A;x.SetAsBox(j,y);return x};A.AsBox=A.prototype.AsBox;A.prototype.SetAsOrientedBox=function(j,y,x,J){if(j===undefined)j=0;if(y===undefined)y=0;if(x===undefined)x=null;if(J===undefined)J=0;this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-j,-y);this.m_vertices[1].Set(j,-y);this.m_vertices[2].Set(j,y);this.m_vertices[3].Set(-j,y);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,
1);this.m_normals[3].Set(-1,0);this.m_centroid=x;j=new R;j.position=x;j.R.Set(J);for(x=0;x<this.m_vertexCount;++x){this.m_vertices[x]=C.MulX(j,this.m_vertices[x]);this.m_normals[x]=C.MulMV(j.R,this.m_normals[x])}};A.prototype.AsOrientedBox=function(j,y,x,J){if(j===undefined)j=0;if(y===undefined)y=0;if(x===undefined)x=null;if(J===undefined)J=0;var M=new A;M.SetAsOrientedBox(j,y,x,J);return M};A.AsOrientedBox=A.prototype.AsOrientedBox;A.prototype.SetAsEdge=function(j,y){this.m_vertexCount=2;this.Reserve(2);
this.m_vertices[0].SetV(j);this.m_vertices[1].SetV(y);this.m_centroid.x=0.5*(j.x+y.x);this.m_centroid.y=0.5*(j.y+y.y);this.m_normals[0]=C.CrossVF(C.SubtractVV(y,j),1);this.m_normals[0].Normalize();this.m_normals[1].x=-this.m_normals[0].x;this.m_normals[1].y=-this.m_normals[0].y};A.prototype.AsEdge=function(j,y){var x=new A;x.SetAsEdge(j,y);return x};A.AsEdge=A.prototype.AsEdge;A.prototype.TestPoint=function(j,y){var x;x=j.R;for(var J=y.x-j.position.x,M=y.y-j.position.y,U=J*x.col1.x+M*x.col1.y,K=J*
x.col2.x+M*x.col2.y,ba=0;ba<this.m_vertexCount;++ba){x=this.m_vertices[ba];J=U-x.x;M=K-x.y;x=this.m_normals[ba];if(x.x*J+x.y*M>0)return false}return true};A.prototype.RayCast=function(j,y,x){var J=0,M=y.maxFraction,U=0,K=0,ba,V;U=y.p1.x-x.position.x;K=y.p1.y-x.position.y;ba=x.R;var Z=U*ba.col1.x+K*ba.col1.y,ga=U*ba.col2.x+K*ba.col2.y;U=y.p2.x-x.position.x;K=y.p2.y-x.position.y;ba=x.R;y=U*ba.col1.x+K*ba.col1.y-Z;ba=U*ba.col2.x+K*ba.col2.y-ga;for(var fa=parseInt(-1),c=0;c<this.m_vertexCount;++c){V=
this.m_vertices[c];U=V.x-Z;K=V.y-ga;V=this.m_normals[c];U=V.x*U+V.y*K;K=V.x*y+V.y*ba;if(K==0){if(U<0)return false}else if(K<0&&U<J*K){J=U/K;fa=c}else if(K>0&&U<M*K)M=U/K;if(M<J-Number.MIN_VALUE)return false}if(fa>=0){j.fraction=J;ba=x.R;V=this.m_normals[fa];j.normal.x=ba.col1.x*V.x+ba.col2.x*V.y;j.normal.y=ba.col1.y*V.x+ba.col2.y*V.y;return true}return false};A.prototype.ComputeAABB=function(j,y){for(var x=y.R,J=this.m_vertices[0],M=y.position.x+(x.col1.x*J.x+x.col2.x*J.y),U=y.position.y+(x.col1.y*
J.x+x.col2.y*J.y),K=M,ba=U,V=1;V<this.m_vertexCount;++V){J=this.m_vertices[V];var Z=y.position.x+(x.col1.x*J.x+x.col2.x*J.y);J=y.position.y+(x.col1.y*J.x+x.col2.y*J.y);M=M<Z?M:Z;U=U<J?U:J;K=K>Z?K:Z;ba=ba>J?ba:J}j.lowerBound.x=M-this.m_radius;j.lowerBound.y=U-this.m_radius;j.upperBound.x=K+this.m_radius;j.upperBound.y=ba+this.m_radius};A.prototype.ComputeMass=function(j,y){if(y===undefined)y=0;if(this.m_vertexCount==2){j.center.x=0.5*(this.m_vertices[0].x+this.m_vertices[1].x);j.center.y=0.5*(this.m_vertices[0].y+
this.m_vertices[1].y);j.mass=0;j.I=0}else{for(var x=0,J=0,M=0,U=0,K=1/3,ba=0;ba<this.m_vertexCount;++ba){var V=this.m_vertices[ba],Z=ba+1<this.m_vertexCount?this.m_vertices[parseInt(ba+1)]:this.m_vertices[0],ga=V.x-0,fa=V.y-0,c=Z.x-0,g=Z.y-0,k=ga*g-fa*c,h=0.5*k;M+=h;x+=h*K*(0+V.x+Z.x);J+=h*K*(0+V.y+Z.y);V=ga;fa=fa;c=c;g=g;U+=k*(K*(0.25*(V*V+c*V+c*c)+(0*V+0*c))+0+(K*(0.25*(fa*fa+g*fa+g*g)+(0*fa+0*g))+0))}j.mass=y*M;x*=1/M;J*=1/M;j.center.Set(x,J);j.I=y*U}};A.prototype.ComputeSubmergedArea=function(j,
y,x,J){if(y===undefined)y=0;var M=C.MulTMV(x.R,j),U=y-C.Dot(j,x.position),K=new Vector_a2j_Number,ba=0,V=parseInt(-1);y=parseInt(-1);var Z=false;for(j=j=0;j<this.m_vertexCount;++j){K[j]=C.Dot(M,this.m_vertices[j])-U;var ga=K[j]<-Number.MIN_VALUE;if(j>0)if(ga){if(!Z){V=j-1;ba++}}else if(Z){y=j-1;ba++}Z=ga}switch(ba){case 0:if(Z){j=new G;this.ComputeMass(j,1);J.SetV(C.MulX(x,j.center));return j.mass}else return 0;case 1:if(V==-1)V=this.m_vertexCount-1;else y=this.m_vertexCount-1}j=parseInt((V+1)%this.m_vertexCount);
M=parseInt((y+1)%this.m_vertexCount);U=(0-K[V])/(K[j]-K[V]);K=(0-K[y])/(K[M]-K[y]);V=new aa(this.m_vertices[V].x*(1-U)+this.m_vertices[j].x*U,this.m_vertices[V].y*(1-U)+this.m_vertices[j].y*U);y=new aa(this.m_vertices[y].x*(1-K)+this.m_vertices[M].x*K,this.m_vertices[y].y*(1-K)+this.m_vertices[M].y*K);K=0;U=new aa;ba=this.m_vertices[j];for(j=j;j!=M;){j=(j+1)%this.m_vertexCount;Z=j==M?y:this.m_vertices[j];ga=0.5*((ba.x-V.x)*(Z.y-V.y)-(ba.y-V.y)*(Z.x-V.x));K+=ga;U.x+=ga*(V.x+ba.x+Z.x)/3;U.y+=ga*(V.y+
ba.y+Z.y)/3;ba=Z}U.Multiply(1/K);J.SetV(C.MulX(x,U));return K};A.prototype.GetVertexCount=function(){return this.m_vertexCount};A.prototype.GetVertices=function(){return this.m_vertices};A.prototype.GetNormals=function(){return this.m_normals};A.prototype.GetSupport=function(j){for(var y=0,x=this.m_vertices[0].x*j.x+this.m_vertices[0].y*j.y,J=1;J<this.m_vertexCount;++J){var M=this.m_vertices[J].x*j.x+this.m_vertices[J].y*j.y;if(M>x){y=J;x=M}}return y};A.prototype.GetSupportVertex=function(j){for(var y=
0,x=this.m_vertices[0].x*j.x+this.m_vertices[0].y*j.y,J=1;J<this.m_vertexCount;++J){var M=this.m_vertices[J].x*j.x+this.m_vertices[J].y*j.y;if(M>x){y=J;x=M}}return this.m_vertices[y]};A.prototype.Validate=function(){return false};A.prototype.b2PolygonShape=function(){this.__super.b2Shape.call(this);this.m_type=this.e_polygonShape;this.m_centroid=new aa;this.m_vertices=new Vector;this.m_normals=new Vector};A.prototype.Reserve=function(j){if(j===undefined)j=0;for(var y=parseInt(this.m_vertices.length);y<
j;y++){this.m_vertices[y]=new aa;this.m_normals[y]=new aa}};A.prototype.ComputeCentroid=function(j,y){if(y===undefined)y=0;for(var x=new aa,J=0,M=1/3,U=0;U<y;++U){var K=j[U],ba=U+1<y?j[parseInt(U+1)]:j[0],V=0.5*((K.x-0)*(ba.y-0)-(K.y-0)*(ba.x-0));J+=V;x.x+=V*M*(0+K.x+ba.x);x.y+=V*M*(0+K.y+ba.y)}x.x*=1/J;x.y*=1/J;return x};A.ComputeCentroid=A.prototype.ComputeCentroid;A.prototype.ComputeOBB=function(j,y,x){if(x===undefined)x=0;var J=0,M=new Vector(x+1);for(J=0;J<x;++J)M[J]=y[J];M[x]=M[0];y=Number.MAX_VALUE;
for(J=1;J<=x;++J){var U=M[parseInt(J-1)],K=M[J].x-U.x,ba=M[J].y-U.y,V=Math.sqrt(K*K+ba*ba);K/=V;ba/=V;for(var Z=-ba,ga=K,fa=V=Number.MAX_VALUE,c=-Number.MAX_VALUE,g=-Number.MAX_VALUE,k=0;k<x;++k){var h=M[k].x-U.x,o=M[k].y-U.y,q=K*h+ba*o;h=Z*h+ga*o;if(q<V)V=q;if(h<fa)fa=h;if(q>c)c=q;if(h>g)g=h}k=(c-V)*(g-fa);if(k<0.95*y){y=k;j.R.col1.x=K;j.R.col1.y=ba;j.R.col2.x=Z;j.R.col2.y=ga;K=0.5*(V+c);ba=0.5*(fa+g);Z=j.R;j.center.x=U.x+(Z.col1.x*K+Z.col2.x*ba);j.center.y=U.y+(Z.col1.y*K+Z.col2.y*ba);j.extents.x=
0.5*(c-V);j.extents.y=0.5*(g-fa)}}};A.ComputeOBB=A.prototype.ComputeOBB;_A2J_postDefs.push(function(){Box2D.Collision.Shapes.b2PolygonShape.s_mat=new s;Box2D.Collision.Shapes.b2PolygonShape.prototype.s_mat=Box2D.Collision.Shapes.b2PolygonShape.s_mat});N.b2Shape=function(){};N.prototype.Copy=function(){return null};N.prototype.Set=function(j){this.m_radius=j.m_radius};N.prototype.GetType=function(){return this.m_type};N.prototype.TestPoint=function(){return false};N.prototype.RayCast=function(){return false};
N.prototype.ComputeAABB=function(){};N.prototype.ComputeMass=function(){};N.prototype.ComputeSubmergedArea=function(){return 0};N.prototype.TestOverlap=function(j,y,x,J){var M=new T;M.proxyA=new X;M.proxyA.Set(j);M.proxyB=new X;M.proxyB.Set(x);M.transformA=y;M.transformB=J;M.useRadii=true;j=new da;j.count=0;y=new Q;$.Distance(y,j,M);return y.distance<10*Number.MIN_VALUE};N.TestOverlap=N.prototype.TestOverlap;N.prototype.b2Shape=function(){this.m_type=N.e_unknownShape;this.m_radius=L.b2_linearSlop};
_A2J_postDefs.push(function(){Box2D.Collision.Shapes.b2Shape.e_unknownShape=parseInt(-1);Box2D.Collision.Shapes.b2Shape.prototype.e_unknownShape=Box2D.Collision.Shapes.b2Shape.e_unknownShape;Box2D.Collision.Shapes.b2Shape.e_circleShape=0;Box2D.Collision.Shapes.b2Shape.prototype.e_circleShape=Box2D.Collision.Shapes.b2Shape.e_circleShape;Box2D.Collision.Shapes.b2Shape.e_polygonShape=1;Box2D.Collision.Shapes.b2Shape.prototype.e_polygonShape=Box2D.Collision.Shapes.b2Shape.e_polygonShape;Box2D.Collision.Shapes.b2Shape.e_edgeShape=
2;Box2D.Collision.Shapes.b2Shape.prototype.e_edgeShape=Box2D.Collision.Shapes.b2Shape.e_edgeShape;Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount=3;Box2D.Collision.Shapes.b2Shape.prototype.e_shapeTypeCount=Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount;Box2D.Collision.Shapes.b2Shape.e_hitCollide=1;Box2D.Collision.Shapes.b2Shape.prototype.e_hitCollide=Box2D.Collision.Shapes.b2Shape.e_hitCollide;Box2D.Collision.Shapes.b2Shape.e_missCollide=0;Box2D.Collision.Shapes.b2Shape.prototype.e_missCollide=Box2D.Collision.Shapes.b2Shape.e_missCollide;
Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide=parseInt(-1);Box2D.Collision.Shapes.b2Shape.prototype.e_startsInsideCollide=Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide})})();
(function(){var L=Box2D.Common.b2Color,I=Box2D.Common.b2Settings,H=Box2D.Common.Math.b2Math;L=Box2D.Common.b2Color;I=Box2D.Common.b2Settings;L.b2Color=function(){this._b=this._g=this._r=0};L.prototype.b2Color=function(F,G,A){if(F===undefined)F=0;if(G===undefined)G=0;if(A===undefined)A=0;this._r=a2j.parseUInt(255*H.Clamp(F,0,1));this._g=a2j.parseUInt(255*H.Clamp(G,0,1));this._b=a2j.parseUInt(255*H.Clamp(A,0,1))};L.prototype.Set=function(F,G,A){if(F===undefined)F=0;if(G===undefined)G=0;if(A===undefined)A=
0;this._r=a2j.parseUInt(255*H.Clamp(F,0,1));this._g=a2j.parseUInt(255*H.Clamp(G,0,1));this._b=a2j.parseUInt(255*H.Clamp(A,0,1))};Object.defineProperty(L.prototype,"r",{enumerable:false,configurable:true,set:function(F){if(F===undefined)F=0;this._r=a2j.parseUInt(255*H.Clamp(F,0,1))}});Object.defineProperty(L.prototype,"g",{enumerable:false,configurable:true,set:function(F){if(F===undefined)F=0;this._g=a2j.parseUInt(255*H.Clamp(F,0,1))}});Object.defineProperty(L.prototype,"b",{enumerable:false,configurable:true,
set:function(F){if(F===undefined)F=0;this._b=a2j.parseUInt(255*H.Clamp(F,0,1))}});Object.defineProperty(L.prototype,"color",{enumerable:false,configurable:true,get:function(){return this._r<<16|this._g<<8|this._b}});I.b2Settings=function(){};I.prototype.b2MixFriction=function(F,G){if(F===undefined)F=0;if(G===undefined)G=0;return Math.sqrt(F*G)};I.b2MixFriction=I.prototype.b2MixFriction;I.prototype.b2MixRestitution=function(F,G){if(F===undefined)F=0;if(G===undefined)G=0;return F>G?F:G};I.b2MixRestitution=
I.prototype.b2MixRestitution;I.prototype.b2Assert=function(F){if(!F)throw"Assertion Failed";};I.b2Assert=I.prototype.b2Assert;_A2J_postDefs.push(function(){Box2D.Common.b2Settings.VERSION="2.1alpha";Box2D.Common.b2Settings.prototype.VERSION=Box2D.Common.b2Settings.VERSION;Box2D.Common.b2Settings.USHRT_MAX=65535;Box2D.Common.b2Settings.prototype.USHRT_MAX=Box2D.Common.b2Settings.USHRT_MAX;Box2D.Common.b2Settings.b2_pi=Math.PI;Box2D.Common.b2Settings.prototype.b2_pi=Box2D.Common.b2Settings.b2_pi;Box2D.Common.b2Settings.b2_maxManifoldPoints=
2;Box2D.Common.b2Settings.prototype.b2_maxManifoldPoints=Box2D.Common.b2Settings.b2_maxManifoldPoints;Box2D.Common.b2Settings.b2_aabbExtension=0.1;Box2D.Common.b2Settings.prototype.b2_aabbExtension=Box2D.Common.b2Settings.b2_aabbExtension;Box2D.Common.b2Settings.b2_aabbMultiplier=2;Box2D.Common.b2Settings.prototype.b2_aabbMultiplier=Box2D.Common.b2Settings.b2_aabbMultiplier;Box2D.Common.b2Settings.b2_polygonRadius=2*I.b2_linearSlop;Box2D.Common.b2Settings.prototype.b2_polygonRadius=Box2D.Common.b2Settings.b2_polygonRadius;
Box2D.Common.b2Settings.b2_linearSlop=0.0050;Box2D.Common.b2Settings.prototype.b2_linearSlop=Box2D.Common.b2Settings.b2_linearSlop;Box2D.Common.b2Settings.b2_angularSlop=2/180*I.b2_pi;Box2D.Common.b2Settings.prototype.b2_angularSlop=Box2D.Common.b2Settings.b2_angularSlop;Box2D.Common.b2Settings.b2_toiSlop=8*I.b2_linearSlop;Box2D.Common.b2Settings.prototype.b2_toiSlop=Box2D.Common.b2Settings.b2_toiSlop;Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland=32;Box2D.Common.b2Settings.prototype.b2_maxTOIContactsPerIsland=
Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland;Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland=32;Box2D.Common.b2Settings.prototype.b2_maxTOIJointsPerIsland=Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland;Box2D.Common.b2Settings.b2_velocityThreshold=1;Box2D.Common.b2Settings.prototype.b2_velocityThreshold=Box2D.Common.b2Settings.b2_velocityThreshold;Box2D.Common.b2Settings.b2_maxLinearCorrection=0.2;Box2D.Common.b2Settings.prototype.b2_maxLinearCorrection=Box2D.Common.b2Settings.b2_maxLinearCorrection;
Box2D.Common.b2Settings.b2_maxAngularCorrection=8/180*I.b2_pi;Box2D.Common.b2Settings.prototype.b2_maxAngularCorrection=Box2D.Common.b2Settings.b2_maxAngularCorrection;Box2D.Common.b2Settings.b2_maxTranslation=2;Box2D.Common.b2Settings.prototype.b2_maxTranslation=Box2D.Common.b2Settings.b2_maxTranslation;Box2D.Common.b2Settings.b2_maxTranslationSquared=I.b2_maxTranslation*I.b2_maxTranslation;Box2D.Common.b2Settings.prototype.b2_maxTranslationSquared=Box2D.Common.b2Settings.b2_maxTranslationSquared;
Box2D.Common.b2Settings.b2_maxRotation=0.5*I.b2_pi;Box2D.Common.b2Settings.prototype.b2_maxRotation=Box2D.Common.b2Settings.b2_maxRotation;Box2D.Common.b2Settings.b2_maxRotationSquared=I.b2_maxRotation*I.b2_maxRotation;Box2D.Common.b2Settings.prototype.b2_maxRotationSquared=Box2D.Common.b2Settings.b2_maxRotationSquared;Box2D.Common.b2Settings.b2_contactBaumgarte=0.2;Box2D.Common.b2Settings.prototype.b2_contactBaumgarte=Box2D.Common.b2Settings.b2_contactBaumgarte;Box2D.Common.b2Settings.b2_timeToSleep=
0.5;Box2D.Common.b2Settings.prototype.b2_timeToSleep=Box2D.Common.b2Settings.b2_timeToSleep;Box2D.Common.b2Settings.b2_linearSleepTolerance=0.01;Box2D.Common.b2Settings.prototype.b2_linearSleepTolerance=Box2D.Common.b2Settings.b2_linearSleepTolerance;Box2D.Common.b2Settings.b2_angularSleepTolerance=2/180*I.b2_pi;Box2D.Common.b2Settings.prototype.b2_angularSleepTolerance=Box2D.Common.b2Settings.b2_angularSleepTolerance})})();
(function(){var L=Box2D.Common.Math.b2Mat22,I=Box2D.Common.Math.b2Mat33,H=Box2D.Common.Math.b2Math,F=Box2D.Common.Math.b2Sweep,G=Box2D.Common.Math.b2Transform,A=Box2D.Common.Math.b2Vec2,N=Box2D.Common.Math.b2Vec3;L.b2Mat22=function(){this.col1=new A;this.col2=new A};L.prototype.b2Mat22=function(){this.SetIdentity()};L.prototype.FromAngle=function(s){if(s===undefined)s=0;var C=new L;C.Set(s);return C};L.FromAngle=L.prototype.FromAngle;L.prototype.FromVV=function(s,C){var R=new L;R.SetVV(s,C);return R};
L.FromVV=L.prototype.FromVV;L.prototype.Set=function(s){if(s===undefined)s=0;var C=Math.cos(s);s=Math.sin(s);this.col1.x=C;this.col2.x=-s;this.col1.y=s;this.col2.y=C};L.prototype.SetVV=function(s,C){this.col1.SetV(s);this.col2.SetV(C)};L.prototype.Copy=function(){var s=new L;s.SetM(this);return s};L.prototype.SetM=function(s){this.col1.SetV(s.col1);this.col2.SetV(s.col2)};L.prototype.AddM=function(s){this.col1.x+=s.col1.x;this.col1.y+=s.col1.y;this.col2.x+=s.col2.x;this.col2.y+=s.col2.y};L.prototype.SetIdentity=
function(){this.col1.x=1;this.col2.x=0;this.col1.y=0;this.col2.y=1};L.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col1.y=0;this.col2.y=0};L.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)};L.prototype.GetInverse=function(s){var C=this.col1.x,R=this.col2.x,aa=this.col1.y,$=this.col2.y,T=C*$-R*aa;if(T!=0)T=1/T;s.col1.x=T*$;s.col2.x=-T*R;s.col1.y=-T*aa;s.col2.y=T*C;return s};L.prototype.Solve=function(s,C,R){if(C===undefined)C=0;if(R===undefined)R=0;var aa=
this.col1.x,$=this.col2.x,T=this.col1.y,Q=this.col2.y,X=aa*Q-$*T;if(X!=0)X=1/X;s.x=X*(Q*C-$*R);s.y=X*(aa*R-T*C);return s};L.prototype.Abs=function(){this.col1.Abs();this.col2.Abs()};I.b2Mat33=function(){this.col1=new N;this.col2=new N;this.col3=new N};I.prototype.b2Mat33=function(s,C,R){if(s===undefined)s=null;if(C===undefined)C=null;if(R===undefined)R=null;if(!s&&!C&&!R){this.col1.SetZero();this.col2.SetZero();this.col3.SetZero()}else{this.col1.SetV(s);this.col2.SetV(C);this.col3.SetV(R)}};I.prototype.SetVVV=
function(s,C,R){this.col1.SetV(s);this.col2.SetV(C);this.col3.SetV(R)};I.prototype.Copy=function(){return new I(this.col1,this.col2,this.col3)};I.prototype.SetM=function(s){this.col1.SetV(s.col1);this.col2.SetV(s.col2);this.col3.SetV(s.col3)};I.prototype.AddM=function(s){this.col1.x+=s.col1.x;this.col1.y+=s.col1.y;this.col1.z+=s.col1.z;this.col2.x+=s.col2.x;this.col2.y+=s.col2.y;this.col2.z+=s.col2.z;this.col3.x+=s.col3.x;this.col3.y+=s.col3.y;this.col3.z+=s.col3.z};I.prototype.SetIdentity=function(){this.col1.x=
1;this.col2.x=0;this.col3.x=0;this.col1.y=0;this.col2.y=1;this.col3.y=0;this.col1.z=0;this.col2.z=0;this.col3.z=1};I.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col3.x=0;this.col1.y=0;this.col2.y=0;this.col3.y=0;this.col1.z=0;this.col2.z=0;this.col3.z=0};I.prototype.Solve22=function(s,C,R){if(C===undefined)C=0;if(R===undefined)R=0;var aa=this.col1.x,$=this.col2.x,T=this.col1.y,Q=this.col2.y,X=aa*Q-$*T;if(X!=0)X=1/X;s.x=X*(Q*C-$*R);s.y=X*(aa*R-T*C);return s};I.prototype.Solve33=function(s,
C,R,aa){if(C===undefined)C=0;if(R===undefined)R=0;if(aa===undefined)aa=0;var $=this.col1.x,T=this.col1.y,Q=this.col1.z,X=this.col2.x,da=this.col2.y,j=this.col2.z,y=this.col3.x,x=this.col3.y,J=this.col3.z,M=$*(da*J-j*x)+T*(j*y-X*J)+Q*(X*x-da*y);if(M!=0)M=1/M;s.x=M*(C*(da*J-j*x)+R*(j*y-X*J)+aa*(X*x-da*y));s.y=M*($*(R*J-aa*x)+T*(aa*y-C*J)+Q*(C*x-R*y));s.z=M*($*(da*aa-j*R)+T*(j*C-X*aa)+Q*(X*R-da*C));return s};H.b2Math=function(){};H.prototype.IsValid=function(s){if(s===undefined)s=0;return isFinite(s)};
H.IsValid=H.prototype.IsValid;H.prototype.Dot=function(s,C){return s.x*C.x+s.y*C.y};H.Dot=H.prototype.Dot;H.prototype.CrossVV=function(s,C){return s.x*C.y-s.y*C.x};H.CrossVV=H.prototype.CrossVV;H.prototype.CrossVF=function(s,C){if(C===undefined)C=0;return new A(C*s.y,-C*s.x)};H.CrossVF=H.prototype.CrossVF;H.prototype.CrossFV=function(s,C){if(s===undefined)s=0;return new A(-s*C.y,s*C.x)};H.CrossFV=H.prototype.CrossFV;H.prototype.MulMV=function(s,C){return new A(s.col1.x*C.x+s.col2.x*C.y,s.col1.y*C.x+
s.col2.y*C.y)};H.MulMV=H.prototype.MulMV;H.prototype.MulTMV=function(s,C){return new A(this.Dot(C,s.col1),this.Dot(C,s.col2))};H.MulTMV=H.prototype.MulTMV;H.prototype.MulX=function(s,C){var R=this.MulMV(s.R,C);R.x+=s.position.x;R.y+=s.position.y;return R};H.MulX=H.prototype.MulX;H.prototype.MulXT=function(s,C){var R=this.SubtractVV(C,s.position),aa=R.x*s.R.col1.x+R.y*s.R.col1.y;R.y=R.x*s.R.col2.x+R.y*s.R.col2.y;R.x=aa;return R};H.MulXT=H.prototype.MulXT;H.prototype.AddVV=function(s,C){return new A(s.x+
C.x,s.y+C.y)};H.AddVV=H.prototype.AddVV;H.prototype.SubtractVV=function(s,C){return new A(s.x-C.x,s.y-C.y)};H.SubtractVV=H.prototype.SubtractVV;H.prototype.Distance=function(s,C){var R=s.x-C.x,aa=s.y-C.y;return Math.sqrt(R*R+aa*aa)};H.Distance=H.prototype.Distance;H.prototype.DistanceSquared=function(s,C){var R=s.x-C.x,aa=s.y-C.y;return R*R+aa*aa};H.DistanceSquared=H.prototype.DistanceSquared;H.prototype.MulFV=function(s,C){if(s===undefined)s=0;return new A(s*C.x,s*C.y)};H.MulFV=H.prototype.MulFV;
H.prototype.AddMM=function(s,C){return L.FromVV(this.AddVV(s.col1,C.col1),this.AddVV(s.col2,C.col2))};H.AddMM=H.prototype.AddMM;H.prototype.MulMM=function(s,C){return L.FromVV(this.MulMV(s,C.col1),this.MulMV(s,C.col2))};H.MulMM=H.prototype.MulMM;H.prototype.MulTMM=function(s,C){var R=new A(this.Dot(s.col1,C.col1),this.Dot(s.col2,C.col1)),aa=new A(this.Dot(s.col1,C.col2),this.Dot(s.col2,C.col2));return L.FromVV(R,aa)};H.MulTMM=H.prototype.MulTMM;H.prototype.Abs=function(s){if(s===undefined)s=0;return s>
0?s:-s};H.Abs=H.prototype.Abs;H.prototype.AbsV=function(s){return new A(this.Abs(s.x),this.Abs(s.y))};H.AbsV=H.prototype.AbsV;H.prototype.AbsM=function(s){return L.FromVV(this.AbsV(s.col1),this.AbsV(s.col2))};H.AbsM=H.prototype.AbsM;H.prototype.Min=function(s,C){if(s===undefined)s=0;if(C===undefined)C=0;return s<C?s:C};H.Min=H.prototype.Min;H.prototype.MinV=function(s,C){return new A(this.Min(s.x,C.x),this.Min(s.y,C.y))};H.MinV=H.prototype.MinV;H.prototype.Max=function(s,C){if(s===undefined)s=0;if(C===
undefined)C=0;return s>C?s:C};H.Max=H.prototype.Max;H.prototype.MaxV=function(s,C){return new A(this.Max(s.x,C.x),this.Max(s.y,C.y))};H.MaxV=H.prototype.MaxV;H.prototype.Clamp=function(s,C,R){if(s===undefined)s=0;if(C===undefined)C=0;if(R===undefined)R=0;return s<C?C:s>R?R:s};H.Clamp=H.prototype.Clamp;H.prototype.ClampV=function(s,C,R){return this.MaxV(C,this.MinV(s,R))};H.ClampV=H.prototype.ClampV;H.prototype.Swap=function(s,C){var R=s[0];s[0]=C[0];C[0]=R};H.Swap=H.prototype.Swap;H.prototype.Random=
function(){return Math.random()*2-1};H.Random=H.prototype.Random;H.prototype.RandomRange=function(s,C){if(s===undefined)s=0;if(C===undefined)C=0;var R=Math.random();return R=(C-s)*R+s};H.RandomRange=H.prototype.RandomRange;H.prototype.NextPowerOfTwo=function(s){if(s===undefined)s=0;s|=s>>1&2147483647;s|=s>>2&1073741823;s|=s>>4&268435455;s|=s>>8&16777215;s|=s>>16&65535;return s+1};H.NextPowerOfTwo=H.prototype.NextPowerOfTwo;H.prototype.IsPowerOfTwo=function(s){if(s===undefined)s=0;return s>0&&(s&s-
1)==0};H.IsPowerOfTwo=H.prototype.IsPowerOfTwo;_A2J_postDefs.push(function(){Box2D.Common.Math.b2Math.b2Vec2_zero=new A(0,0);Box2D.Common.Math.b2Math.prototype.b2Vec2_zero=Box2D.Common.Math.b2Math.b2Vec2_zero;Box2D.Common.Math.b2Math.b2Mat22_identity=L.FromVV(new A(1,0),new A(0,1));Box2D.Common.Math.b2Math.prototype.b2Mat22_identity=Box2D.Common.Math.b2Math.b2Mat22_identity;Box2D.Common.Math.b2Math.b2Transform_identity=new G(H.b2Vec2_zero,H.b2Mat22_identity);Box2D.Common.Math.b2Math.prototype.b2Transform_identity=
Box2D.Common.Math.b2Math.b2Transform_identity});F.b2Sweep=function(){this.localCenter=new A;this.c0=new A;this.c=new A};F.prototype.Set=function(s){this.localCenter.SetV(s.localCenter);this.c0.SetV(s.c0);this.c.SetV(s.c);this.a0=s.a0;this.a=s.a;this.t0=s.t0};F.prototype.Copy=function(){var s=new F;s.localCenter.SetV(this.localCenter);s.c0.SetV(this.c0);s.c.SetV(this.c);s.a0=this.a0;s.a=this.a;s.t0=this.t0;return s};F.prototype.GetTransform=function(s,C){if(C===undefined)C=0;s.position.x=(1-C)*this.c0.x+
C*this.c.x;s.position.y=(1-C)*this.c0.y+C*this.c.y;s.R.Set((1-C)*this.a0+C*this.a);var R=s.R;s.position.x-=R.col1.x*this.localCenter.x+R.col2.x*this.localCenter.y;s.position.y-=R.col1.y*this.localCenter.x+R.col2.y*this.localCenter.y};F.prototype.Advance=function(s){if(s===undefined)s=0;if(this.t0<s&&1-this.t0>Number.MIN_VALUE){var C=(s-this.t0)/(1-this.t0);this.c0.x=(1-C)*this.c0.x+C*this.c.x;this.c0.y=(1-C)*this.c0.y+C*this.c.y;this.a0=(1-C)*this.a0+C*this.a;this.t0=s}};G.b2Transform=function(){this.position=
new A;this.R=new L};G.prototype.b2Transform=function(s,C){if(s===undefined)s=null;if(C===undefined)C=null;if(s){this.position.SetV(s);this.R.SetM(C)}};G.prototype.Initialize=function(s,C){this.position.SetV(s);this.R.SetM(C)};G.prototype.SetIdentity=function(){this.position.SetZero();this.R.SetIdentity()};G.prototype.Set=function(s){this.position.SetV(s.position);this.R.SetM(s.R)};G.prototype.GetAngle=function(){return Math.atan2(this.R.col1.y,this.R.col1.x)};A.b2Vec2=function(){};A.prototype.b2Vec2=
function(s,C){if(s===undefined)s=0;if(C===undefined)C=0;this.x=s;this.y=C};A.prototype.SetZero=function(){this.y=this.x=0};A.prototype.Set=function(s,C){if(s===undefined)s=0;if(C===undefined)C=0;this.x=s;this.y=C};A.prototype.SetV=function(s){this.x=s.x;this.y=s.y};A.prototype.GetNegative=function(){return new A(-this.x,-this.y)};A.prototype.NegativeSelf=function(){this.x=-this.x;this.y=-this.y};A.prototype.Make=function(s,C){if(s===undefined)s=0;if(C===undefined)C=0;return new A(s,C)};A.Make=A.prototype.Make;
A.prototype.Copy=function(){return new A(this.x,this.y)};A.prototype.Add=function(s){this.x+=s.x;this.y+=s.y};A.prototype.Subtract=function(s){this.x-=s.x;this.y-=s.y};A.prototype.Multiply=function(s){if(s===undefined)s=0;this.x*=s;this.y*=s};A.prototype.MulM=function(s){var C=this.x;this.x=s.col1.x*C+s.col2.x*this.y;this.y=s.col1.y*C+s.col2.y*this.y};A.prototype.MulTM=function(s){var C=H.Dot(this,s.col1);this.y=H.Dot(this,s.col2);this.x=C};A.prototype.CrossVF=function(s){if(s===undefined)s=0;var C=
this.x;this.x=s*this.y;this.y=-s*C};A.prototype.CrossFV=function(s){if(s===undefined)s=0;var C=this.x;this.x=-s*this.y;this.y=s*C};A.prototype.MinV=function(s){this.x=this.x<s.x?this.x:s.x;this.y=this.y<s.y?this.y:s.y};A.prototype.MaxV=function(s){this.x=this.x>s.x?this.x:s.x;this.y=this.y>s.y?this.y:s.y};A.prototype.Abs=function(){if(this.x<0)this.x=-this.x;if(this.y<0)this.y=-this.y};A.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};A.prototype.LengthSquared=function(){return this.x*
this.x+this.y*this.y};A.prototype.Normalize=function(){var s=Math.sqrt(this.x*this.x+this.y*this.y);if(s<Number.MIN_VALUE)return 0;var C=1/s;this.x*=C;this.y*=C;return s};A.prototype.IsValid=function(){return H.IsValid(this.x)&&H.IsValid(this.y)};N.b2Vec3=function(){};N.prototype.b2Vec3=function(s,C,R){if(s===undefined)s=0;if(C===undefined)C=0;if(R===undefined)R=0;this.x=s;this.y=C;this.z=R};N.prototype.SetZero=function(){this.x=this.y=this.z=0};N.prototype.Set=function(s,C,R){if(s===undefined)s=
0;if(C===undefined)C=0;if(R===undefined)R=0;this.x=s;this.y=C;this.z=R};N.prototype.SetV=function(s){this.x=s.x;this.y=s.y;this.z=s.z};N.prototype.GetNegative=function(){return new N(-this.x,-this.y,-this.z)};N.prototype.NegativeSelf=function(){this.x=-this.x;this.y=-this.y;this.z=-this.z};N.prototype.Copy=function(){return new N(this.x,this.y,this.z)};N.prototype.Add=function(s){this.x+=s.x;this.y+=s.y;this.z+=s.z};N.prototype.Subtract=function(s){this.x-=s.x;this.y-=s.y;this.z-=s.z};N.prototype.Multiply=
function(s){if(s===undefined)s=0;this.x*=s;this.y*=s;this.z*=s}})();
(function(){var L=Box2D.Common.Math.b2Math,I=Box2D.Common.Math.b2Sweep,H=Box2D.Common.Math.b2Transform,F=Box2D.Common.Math.b2Vec2,G=Box2D.Common.b2Color,A=Box2D.Common.b2Settings,N=Box2D.Collision.b2AABB,s=Box2D.Collision.b2ContactPoint,C=Box2D.Collision.b2DynamicTreeBroadPhase,R=Box2D.Collision.b2RayCastInput,aa=Box2D.Collision.b2RayCastOutput,$=Box2D.Collision.Shapes.b2CircleShape,T=Box2D.Collision.Shapes.b2EdgeShape,Q=Box2D.Collision.Shapes.b2MassData,X=Box2D.Collision.Shapes.b2PolygonShape,da=
Box2D.Collision.Shapes.b2Shape,j=Box2D.Dynamics.b2Body,y=Box2D.Dynamics.b2BodyDef,x=Box2D.Dynamics.b2ContactFilter,J=Box2D.Dynamics.b2ContactImpulse,M=Box2D.Dynamics.b2ContactListener,U=Box2D.Dynamics.b2ContactManager,K=Box2D.Dynamics.b2DebugDraw,ba=Box2D.Dynamics.b2DestructionListener,V=Box2D.Dynamics.b2FilterData,Z=Box2D.Dynamics.b2Fixture,ga=Box2D.Dynamics.b2FixtureDef,fa=Box2D.Dynamics.b2Island,c=Box2D.Dynamics.b2TimeStep,g=Box2D.Dynamics.b2World,k=Box2D.Dynamics.Contacts.b2Contact,h=Box2D.Dynamics.Contacts.b2ContactFactory,
o=Box2D.Dynamics.Contacts.b2ContactSolver,q=Box2D.Dynamics.Joints.b2Joint,l=Box2D.Dynamics.Joints.b2PulleyJoint;j=Box2D.Dynamics.b2Body;y=Box2D.Dynamics.b2BodyDef;x=Box2D.Dynamics.b2ContactFilter;J=Box2D.Dynamics.b2ContactImpulse;M=Box2D.Dynamics.b2ContactListener;U=Box2D.Dynamics.b2ContactManager;K=Box2D.Dynamics.b2DebugDraw;ba=Box2D.Dynamics.b2DestructionListener;V=Box2D.Dynamics.b2FilterData;Z=Box2D.Dynamics.b2Fixture;ga=Box2D.Dynamics.b2FixtureDef;fa=Box2D.Dynamics.b2Island;c=Box2D.Dynamics.b2TimeStep;
g=Box2D.Dynamics.b2World;j.b2Body=function(){this.m_xf=new H;this.m_sweep=new I;this.m_linearVelocity=new F;this.m_force=new F};j.prototype.connectEdges=function(a,b,f){if(f===undefined)f=0;var m=Math.atan2(b.GetDirectionVector().y,b.GetDirectionVector().x);f=L.MulFV(Math.tan((m-f)*0.5),b.GetDirectionVector());f=L.SubtractVV(f,b.GetNormalVector());f=L.MulFV(A.b2_toiSlop,f);f=L.AddVV(f,b.GetVertex1());var p=L.AddVV(a.GetDirectionVector(),b.GetDirectionVector());p.Normalize();var D=L.Dot(a.GetDirectionVector(),
b.GetNormalVector())>0;a.SetNextEdge(b,f,p,D);b.SetPrevEdge(a,f,p,D);return m};j.prototype.CreateFixture=function(a){if(this.m_world.IsLocked()==true)return null;var b=new Z;b.Create(this,this.m_xf,a);this.m_flags&j.e_activeFlag&&b.CreateProxy(this.m_world.m_contactManager.m_broadPhase,this.m_xf);b.m_next=this.m_fixtureList;this.m_fixtureList=b;++this.m_fixtureCount;b.m_body=this;b.m_density>0&&this.ResetMassData();this.m_world.m_flags|=g.e_newFixture;return b};j.prototype.CreateFixture2=function(a,
b){if(b===undefined)b=0;var f=new ga;f.shape=a;f.density=b;return this.CreateFixture(f)};j.prototype.DestroyFixture=function(a){if(this.m_world.IsLocked()!=true){for(var b=this.m_fixtureList,f=null;b!=null;){if(b==a){if(f)f.m_next=a.m_next;else this.m_fixtureList=a.m_next;break}f=b;b=b.m_next}for(b=this.m_contactList;b;){f=b.contact;b=b.next;var m=f.GetFixtureA(),p=f.GetFixtureB();if(a==m||a==p)this.m_world.m_contactManager.Destroy(f)}this.m_flags&j.e_activeFlag&&a.DestroyProxy(this.m_world.m_contactManager.m_broadPhase);
a.Destroy();a.m_body=null;a.m_next=null;--this.m_fixtureCount;this.ResetMassData()}};j.prototype.SetPositionAndAngle=function(a,b){if(b===undefined)b=0;var f;if(this.m_world.IsLocked()!=true){this.m_xf.R.Set(b);this.m_xf.position.SetV(a);f=this.m_xf.R;var m=this.m_sweep.localCenter;this.m_sweep.c.x=f.col1.x*m.x+f.col2.x*m.y;this.m_sweep.c.y=f.col1.y*m.x+f.col2.y*m.y;this.m_sweep.c.x+=this.m_xf.position.x;this.m_sweep.c.y+=this.m_xf.position.y;this.m_sweep.c0.SetV(this.m_sweep.c);this.m_sweep.a0=this.m_sweep.a=
b;m=this.m_world.m_contactManager.m_broadPhase;for(f=this.m_fixtureList;f;f=f.m_next)f.Synchronize(m,this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()}};j.prototype.SetTransform=function(a){this.SetPositionAndAngle(a.position,a.GetAngle())};j.prototype.GetTransform=function(){return this.m_xf};j.prototype.GetPosition=function(){return this.m_xf.position};j.prototype.SetPosition=function(a){this.SetPositionAndAngle(a,this.GetAngle())};j.prototype.GetAngle=function(){return this.m_sweep.a};
j.prototype.SetAngle=function(a){if(a===undefined)a=0;this.SetPositionAndAngle(this.GetPosition(),a)};j.prototype.GetWorldCenter=function(){return this.m_sweep.c};j.prototype.GetLocalCenter=function(){return this.m_sweep.localCenter};j.prototype.SetLinearVelocity=function(a){this.m_type!=j.b2_staticBody&&this.m_linearVelocity.SetV(a)};j.prototype.GetLinearVelocity=function(){return this.m_linearVelocity};j.prototype.SetAngularVelocity=function(a){if(a===undefined)a=0;if(this.m_type!=j.b2_staticBody)this.m_angularVelocity=
a};j.prototype.GetAngularVelocity=function(){return this.m_angularVelocity};j.prototype.GetDefinition=function(){var a=new y;a.type=this.GetType();a.allowSleep=(this.m_flags&j.e_allowSleepFlag)==j.e_allowSleepFlag;a.angle=this.GetAngle();a.angularDamping=this.m_angularDamping;a.angularVelocity=this.m_angularVelocity;a.fixedRotation=(this.m_flags&j.e_fixedRotationFlag)==j.e_fixedRotationFlag;a.bullet=(this.m_flags&j.e_bulletFlag)==j.e_bulletFlag;a.awake=(this.m_flags&j.e_awakeFlag)==j.e_awakeFlag;
a.linearDamping=this.m_linearDamping;a.linearVelocity.SetV(this.GetLinearVelocity());a.position=this.GetPosition();a.userData=this.GetUserData();return a};j.prototype.ApplyForce=function(a,b){if(this.m_type==j.b2_dynamicBody){this.IsAwake()==false&&this.SetAwake(true);this.m_force.x+=a.x;this.m_force.y+=a.y;this.m_torque+=(b.x-this.m_sweep.c.x)*a.y-(b.y-this.m_sweep.c.y)*a.x}};j.prototype.ApplyTorque=function(a){if(a===undefined)a=0;if(this.m_type==j.b2_dynamicBody){this.IsAwake()==false&&this.SetAwake(true);
this.m_torque+=a}};j.prototype.ApplyImpulse=function(a,b){if(this.m_type==j.b2_dynamicBody){this.IsAwake()==false&&this.SetAwake(true);this.m_linearVelocity.x+=this.m_invMass*a.x;this.m_linearVelocity.y+=this.m_invMass*a.y;this.m_angularVelocity+=this.m_invI*((b.x-this.m_sweep.c.x)*a.y-(b.y-this.m_sweep.c.y)*a.x)}};j.prototype.Split=function(a){for(var b=this.GetLinearVelocity().Copy(),f=this.GetAngularVelocity(),m=this.GetWorldCenter(),p=this.m_world.CreateBody(this.GetDefinition()),D,B=this.m_fixtureList;B;)if(a(B)){var O=
B.m_next;if(D)D.m_next=O;else this.m_fixtureList=O;this.m_fixtureCount--;B.m_next=p.m_fixtureList;p.m_fixtureList=B;p.m_fixtureCount++;B.m_body=p;B=O}else{D=B;B=B.m_next}this.ResetMassData();p.ResetMassData();D=this.GetWorldCenter();a=p.GetWorldCenter();D=L.AddVV(b,L.CrossFV(f,L.SubtractVV(D,m)));b=L.AddVV(b,L.CrossFV(f,L.SubtractVV(a,m)));this.SetLinearVelocity(D);p.SetLinearVelocity(b);this.SetAngularVelocity(f);p.SetAngularVelocity(f);this.SynchronizeFixtures();p.SynchronizeFixtures();return p};
j.prototype.Merge=function(a){var b;for(b=a.m_fixtureList;b;){var f=b.m_next;a.m_fixtureCount--;b.m_next=this.m_fixtureList;this.m_fixtureList=b;this.m_fixtureCount++;b.m_body=p;b=f}m.m_fixtureCount=0;var m=this,p=a;m.GetWorldCenter();p.GetWorldCenter();m.GetLinearVelocity().Copy();p.GetLinearVelocity().Copy();m.GetAngularVelocity();p.GetAngularVelocity();m.ResetMassData();this.SynchronizeFixtures()};j.prototype.GetMass=function(){return this.m_mass};j.prototype.GetInertia=function(){return this.m_I};
j.prototype.GetMassData=function(a){a.mass=this.m_mass;a.I=this.m_I;a.center.SetV(this.m_sweep.localCenter)};j.prototype.SetMassData=function(a){A.b2Assert(this.m_world.IsLocked()==false);if(this.m_world.IsLocked()!=true)if(this.m_type==j.b2_dynamicBody){this.m_invI=this.m_I=this.m_invMass=0;this.m_mass=a.mass;if(this.m_mass<=0)this.m_mass=1;this.m_invMass=1/this.m_mass;if(a.I>0&&(this.m_flags&j.e_fixedRotationFlag)==0){this.m_I=a.I-this.m_mass*(a.center.x*a.center.x+a.center.y*a.center.y);this.m_invI=
1/this.m_I}var b=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(a.center);this.m_sweep.c0.SetV(L.MulX(this.m_xf,this.m_sweep.localCenter));this.m_sweep.c.SetV(this.m_sweep.c0);this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-b.y);this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-b.x)}};j.prototype.ResetMassData=function(){this.m_invI=this.m_I=this.m_invMass=this.m_mass=0;this.m_sweep.localCenter.SetZero();if(!(this.m_type==j.b2_staticBody||this.m_type==j.b2_kinematicBody)){for(var a=
F.Make(0,0),b=this.m_fixtureList;b;b=b.m_next)if(b.m_density!=0){var f=b.GetMassData();this.m_mass+=f.mass;a.x+=f.center.x*f.mass;a.y+=f.center.y*f.mass;this.m_I+=f.I}if(this.m_mass>0){this.m_invMass=1/this.m_mass;a.x*=this.m_invMass;a.y*=this.m_invMass}else this.m_invMass=this.m_mass=1;if(this.m_I>0&&(this.m_flags&j.e_fixedRotationFlag)==0){this.m_I-=this.m_mass*(a.x*a.x+a.y*a.y);this.m_I*=this.m_inertiaScale;A.b2Assert(this.m_I>0);this.m_invI=1/this.m_I}else this.m_invI=this.m_I=0;b=this.m_sweep.c.Copy();
this.m_sweep.localCenter.SetV(a);this.m_sweep.c0.SetV(L.MulX(this.m_xf,this.m_sweep.localCenter));this.m_sweep.c.SetV(this.m_sweep.c0);this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-b.y);this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-b.x)}};j.prototype.GetWorldPoint=function(a){var b=this.m_xf.R;a=new F(b.col1.x*a.x+b.col2.x*a.y,b.col1.y*a.x+b.col2.y*a.y);a.x+=this.m_xf.position.x;a.y+=this.m_xf.position.y;return a};j.prototype.GetWorldVector=function(a){return L.MulMV(this.m_xf.R,
a)};j.prototype.GetLocalPoint=function(a){return L.MulXT(this.m_xf,a)};j.prototype.GetLocalVector=function(a){return L.MulTMV(this.m_xf.R,a)};j.prototype.GetLinearVelocityFromWorldPoint=function(a){return new F(this.m_linearVelocity.x-this.m_angularVelocity*(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x))};j.prototype.GetLinearVelocityFromLocalPoint=function(a){var b=this.m_xf.R;a=new F(b.col1.x*a.x+b.col2.x*a.y,b.col1.y*a.x+b.col2.y*a.y);a.x+=this.m_xf.position.x;
a.y+=this.m_xf.position.y;return new F(this.m_linearVelocity.x-this.m_angularVelocity*(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x))};j.prototype.GetLinearDamping=function(){return this.m_linearDamping};j.prototype.SetLinearDamping=function(a){if(a===undefined)a=0;this.m_linearDamping=a};j.prototype.GetAngularDamping=function(){return this.m_angularDamping};j.prototype.SetAngularDamping=function(a){if(a===undefined)a=0;this.m_angularDamping=a};j.prototype.SetType=
function(a){if(a===undefined)a=0;if(this.m_type!=a){this.m_type=a;this.ResetMassData();if(this.m_type==j.b2_staticBody){this.m_linearVelocity.SetZero();this.m_angularVelocity=0}this.SetAwake(true);this.m_force.SetZero();this.m_torque=0;for(a=this.m_contactList;a;a=a.next)a.contact.FlagForFiltering()}};j.prototype.GetType=function(){return this.m_type};j.prototype.SetBullet=function(a){if(a)this.m_flags|=j.e_bulletFlag;else this.m_flags&=~j.e_bulletFlag};j.prototype.IsBullet=function(){return(this.m_flags&
j.e_bulletFlag)==j.e_bulletFlag};j.prototype.SetSleepingAllowed=function(a){if(a)this.m_flags|=j.e_allowSleepFlag;else{this.m_flags&=~j.e_allowSleepFlag;this.SetAwake(true)}};j.prototype.SetAwake=function(a){if(a){this.m_flags|=j.e_awakeFlag;this.m_sleepTime=0}else{this.m_flags&=~j.e_awakeFlag;this.m_sleepTime=0;this.m_linearVelocity.SetZero();this.m_angularVelocity=0;this.m_force.SetZero();this.m_torque=0}};j.prototype.IsAwake=function(){return(this.m_flags&j.e_awakeFlag)==j.e_awakeFlag};j.prototype.SetFixedRotation=
function(a){if(a)this.m_flags|=j.e_fixedRotationFlag;else this.m_flags&=~j.e_fixedRotationFlag;this.ResetMassData()};j.prototype.IsFixedRotation=function(){return(this.m_flags&j.e_fixedRotationFlag)==j.e_fixedRotationFlag};j.prototype.SetActive=function(a){if(a!=this.IsActive()){var b;if(a){this.m_flags|=j.e_activeFlag;a=this.m_world.m_contactManager.m_broadPhase;for(b=this.m_fixtureList;b;b=b.m_next)b.CreateProxy(a,this.m_xf)}else{this.m_flags&=~j.e_activeFlag;a=this.m_world.m_contactManager.m_broadPhase;
for(b=this.m_fixtureList;b;b=b.m_next)b.DestroyProxy(a);for(a=this.m_contactList;a;){b=a;a=a.next;this.m_world.m_contactManager.Destroy(b.contact)}this.m_contactList=null}}};j.prototype.IsActive=function(){return(this.m_flags&j.e_activeFlag)==j.e_activeFlag};j.prototype.IsSleepingAllowed=function(){return(this.m_flags&j.e_allowSleepFlag)==j.e_allowSleepFlag};j.prototype.GetFixtureList=function(){return this.m_fixtureList};j.prototype.GetJointList=function(){return this.m_jointList};j.prototype.GetControllerList=
function(){return this.m_controllerList};j.prototype.GetContactList=function(){return this.m_contactList};j.prototype.GetNext=function(){return this.m_next};j.prototype.GetUserData=function(){return this.m_userData};j.prototype.SetUserData=function(a){this.m_userData=a};j.prototype.GetWorld=function(){return this.m_world};j.prototype.b2Body=function(a,b){this.m_flags=0;if(a.bullet)this.m_flags|=j.e_bulletFlag;if(a.fixedRotation)this.m_flags|=j.e_fixedRotationFlag;if(a.allowSleep)this.m_flags|=j.e_allowSleepFlag;
if(a.awake)this.m_flags|=j.e_awakeFlag;if(a.active)this.m_flags|=j.e_activeFlag;this.m_world=b;this.m_xf.position.SetV(a.position);this.m_xf.R.Set(a.angle);this.m_sweep.localCenter.SetZero();this.m_sweep.t0=1;this.m_sweep.a0=this.m_sweep.a=a.angle;var f=this.m_xf.R,m=this.m_sweep.localCenter;this.m_sweep.c.x=f.col1.x*m.x+f.col2.x*m.y;this.m_sweep.c.y=f.col1.y*m.x+f.col2.y*m.y;this.m_sweep.c.x+=this.m_xf.position.x;this.m_sweep.c.y+=this.m_xf.position.y;this.m_sweep.c0.SetV(this.m_sweep.c);this.m_contactList=
this.m_controllerList=this.m_jointList=null;this.m_controllerCount=0;this.m_next=this.m_prev=null;this.m_linearVelocity.SetV(a.linearVelocity);this.m_angularVelocity=a.angularVelocity;this.m_linearDamping=a.linearDamping;this.m_angularDamping=a.angularDamping;this.m_force.Set(0,0);this.m_sleepTime=this.m_torque=0;this.m_type=a.type;if(this.m_type==j.b2_dynamicBody)this.m_invMass=this.m_mass=1;else this.m_invMass=this.m_mass=0;this.m_invI=this.m_I=0;this.m_inertiaScale=a.inertiaScale;this.m_userData=
a.userData;this.m_fixtureList=null;this.m_fixtureCount=0};j.prototype.SynchronizeFixtures=function(){var a=j.s_xf1;a.R.Set(this.m_sweep.a0);var b=a.R,f=this.m_sweep.localCenter;a.position.x=this.m_sweep.c0.x-(b.col1.x*f.x+b.col2.x*f.y);a.position.y=this.m_sweep.c0.y-(b.col1.y*f.x+b.col2.y*f.y);f=this.m_world.m_contactManager.m_broadPhase;for(b=this.m_fixtureList;b;b=b.m_next)b.Synchronize(f,a,this.m_xf)};j.prototype.SynchronizeTransform=function(){this.m_xf.R.Set(this.m_sweep.a);var a=this.m_xf.R,
b=this.m_sweep.localCenter;this.m_xf.position.x=this.m_sweep.c.x-(a.col1.x*b.x+a.col2.x*b.y);this.m_xf.position.y=this.m_sweep.c.y-(a.col1.y*b.x+a.col2.y*b.y)};j.prototype.ShouldCollide=function(a){if(this.m_type!=j.b2_dynamicBody&&a.m_type!=j.b2_dynamicBody)return false;for(var b=this.m_jointList;b;b=b.next)if(b.other==a)if(b.joint.m_collideConnected==false)return false;return true};j.prototype.Advance=function(a){if(a===undefined)a=0;this.m_sweep.Advance(a);this.m_sweep.c.SetV(this.m_sweep.c0);
this.m_sweep.a=this.m_sweep.a0;this.SynchronizeTransform()};_A2J_postDefs.push(function(){Box2D.Dynamics.b2Body.s_xf1=new H;Box2D.Dynamics.b2Body.prototype.s_xf1=Box2D.Dynamics.b2Body.s_xf1;Box2D.Dynamics.b2Body.e_islandFlag=1;Box2D.Dynamics.b2Body.prototype.e_islandFlag=Box2D.Dynamics.b2Body.e_islandFlag;Box2D.Dynamics.b2Body.e_awakeFlag=2;Box2D.Dynamics.b2Body.prototype.e_awakeFlag=Box2D.Dynamics.b2Body.e_awakeFlag;Box2D.Dynamics.b2Body.e_allowSleepFlag=4;Box2D.Dynamics.b2Body.prototype.e_allowSleepFlag=
Box2D.Dynamics.b2Body.e_allowSleepFlag;Box2D.Dynamics.b2Body.e_bulletFlag=8;Box2D.Dynamics.b2Body.prototype.e_bulletFlag=Box2D.Dynamics.b2Body.e_bulletFlag;Box2D.Dynamics.b2Body.e_fixedRotationFlag=16;Box2D.Dynamics.b2Body.prototype.e_fixedRotationFlag=Box2D.Dynamics.b2Body.e_fixedRotationFlag;Box2D.Dynamics.b2Body.e_activeFlag=32;Box2D.Dynamics.b2Body.prototype.e_activeFlag=Box2D.Dynamics.b2Body.e_activeFlag;Box2D.Dynamics.b2Body.b2_staticBody=0;Box2D.Dynamics.b2Body.prototype.b2_staticBody=Box2D.Dynamics.b2Body.b2_staticBody;
Box2D.Dynamics.b2Body.b2_kinematicBody=1;Box2D.Dynamics.b2Body.prototype.b2_kinematicBody=Box2D.Dynamics.b2Body.b2_kinematicBody;Box2D.Dynamics.b2Body.b2_dynamicBody=2;Box2D.Dynamics.b2Body.prototype.b2_dynamicBody=Box2D.Dynamics.b2Body.b2_dynamicBody});y.b2BodyDef=function(){this.position=new F;this.linearVelocity=new F};y.prototype.b2BodyDef=function(){this.userData=null;this.position.Set(0,0);this.angle=0;this.linearVelocity.Set(0,0);this.angularDamping=this.linearDamping=this.angularVelocity=
0;this.awake=this.allowSleep=true;this.bullet=this.fixedRotation=false;this.type=j.b2_staticBody;this.active=true;this.inertiaScale=1};x.b2ContactFilter=function(){};x.prototype.ShouldCollide=function(a,b){var f=a.GetFilterData(),m=b.GetFilterData();if(f.groupIndex==m.groupIndex&&f.groupIndex!=0)return f.groupIndex>0;return(f.maskBits&m.categoryBits)!=0&&(f.categoryBits&m.maskBits)!=0};x.prototype.RayCollide=function(a,b){if(!a)return true;return this.ShouldCollide(a instanceof Z?a:null,b)};_A2J_postDefs.push(function(){Box2D.Dynamics.b2ContactFilter.b2_defaultFilter=
new x;Box2D.Dynamics.b2ContactFilter.prototype.b2_defaultFilter=Box2D.Dynamics.b2ContactFilter.b2_defaultFilter});J.b2ContactImpulse=function(){this.normalImpulses=new Vector_a2j_Number(A.b2_maxManifoldPoints);this.tangentImpulses=new Vector_a2j_Number(A.b2_maxManifoldPoints)};M.b2ContactListener=function(){};M.prototype.BeginContact=function(){};M.prototype.EndContact=function(){};M.prototype.PreSolve=function(){};M.prototype.PostSolve=function(){};_A2J_postDefs.push(function(){Box2D.Dynamics.b2ContactListener.b2_defaultListener=
new M;Box2D.Dynamics.b2ContactListener.prototype.b2_defaultListener=Box2D.Dynamics.b2ContactListener.b2_defaultListener});U.b2ContactManager=function(){};U.prototype.b2ContactManager=function(){this.m_world=null;this.m_contactCount=0;this.m_contactFilter=x.b2_defaultFilter;this.m_contactListener=M.b2_defaultListener;this.m_contactFactory=new h(this.m_allocator);this.m_broadPhase=new C};U.prototype.AddPair=function(a,b){var f=a instanceof Z?a:null,m=b instanceof Z?b:null,p=f.GetBody(),D=m.GetBody();
if(p!=D){for(var B=D.GetContactList();B;){if(B.other==p){var O=B.contact.GetFixtureA(),W=B.contact.GetFixtureB();if(O==f&&W==m)return;if(O==m&&W==f)return}B=B.next}if(D.ShouldCollide(p)!=false)if(this.m_contactFilter.ShouldCollide(f,m)!=false){B=this.m_contactFactory.Create(f,m);f=B.GetFixtureA();m=B.GetFixtureB();p=f.m_body;D=m.m_body;B.m_prev=null;B.m_next=this.m_world.m_contactList;if(this.m_world.m_contactList!=null)this.m_world.m_contactList.m_prev=B;this.m_world.m_contactList=B;B.m_nodeA.contact=
B;B.m_nodeA.other=D;B.m_nodeA.prev=null;B.m_nodeA.next=p.m_contactList;if(p.m_contactList!=null)p.m_contactList.prev=B.m_nodeA;p.m_contactList=B.m_nodeA;B.m_nodeB.contact=B;B.m_nodeB.other=p;B.m_nodeB.prev=null;B.m_nodeB.next=D.m_contactList;if(D.m_contactList!=null)D.m_contactList.prev=B.m_nodeB;D.m_contactList=B.m_nodeB;++this.m_world.m_contactCount}}};U.prototype.FindNewContacts=function(){this.m_broadPhase.UpdatePairs(a2j.generateCallback(this,this.AddPair))};U.prototype.Destroy=function(a){var b=
a.GetFixtureA(),f=a.GetFixtureB();b=b.GetBody();f=f.GetBody();a.IsTouching()&&this.m_contactListener.EndContact(a);if(a.m_prev)a.m_prev.m_next=a.m_next;if(a.m_next)a.m_next.m_prev=a.m_prev;if(a==this.m_world.m_contactList)this.m_world.m_contactList=a.m_next;if(a.m_nodeA.prev)a.m_nodeA.prev.next=a.m_nodeA.next;if(a.m_nodeA.next)a.m_nodeA.next.prev=a.m_nodeA.prev;if(a.m_nodeA==b.m_contactList)b.m_contactList=a.m_nodeA.next;if(a.m_nodeB.prev)a.m_nodeB.prev.next=a.m_nodeB.next;if(a.m_nodeB.next)a.m_nodeB.next.prev=
a.m_nodeB.prev;if(a.m_nodeB==f.m_contactList)f.m_contactList=a.m_nodeB.next;this.m_contactFactory.Destroy(a);--this.m_contactCount};U.prototype.Collide=function(){for(var a=this.m_world.m_contactList;a;){var b=a.GetFixtureA(),f=a.GetFixtureB(),m=b.GetBody(),p=f.GetBody();if(m.IsAwake()==false&&p.IsAwake()==false)a=a.GetNext();else{if(a.m_flags&k.e_filterFlag){if(p.ShouldCollide(m)==false){b=a;a=b.GetNext();this.Destroy(b);continue}if(this.m_contactFilter.ShouldCollide(b,f)==false){b=a;a=b.GetNext();
this.Destroy(b);continue}a.m_flags&=~k.e_filterFlag}if(this.m_broadPhase.TestOverlap(b.m_proxy,f.m_proxy)==false){b=a;a=b.GetNext();this.Destroy(b)}else{a.Update(this.m_contactListener);a=a.GetNext()}}}};_A2J_postDefs.push(function(){Box2D.Dynamics.b2ContactManager.s_evalCP=new s;Box2D.Dynamics.b2ContactManager.prototype.s_evalCP=Box2D.Dynamics.b2ContactManager.s_evalCP});K.b2DebugDraw=function(){};K.prototype.b2DebugDraw=function(){m_drawFlags=0};K.prototype.SetFlags=function(){};K.prototype.GetFlags=
function(){};K.prototype.AppendFlags=function(){};K.prototype.ClearFlags=function(){};K.prototype.SetSprite=function(){};K.prototype.GetSprite=function(){};K.prototype.SetDrawScale=function(){};K.prototype.GetDrawScale=function(){};K.prototype.SetLineThickness=function(){};K.prototype.GetLineThickness=function(){};K.prototype.SetAlpha=function(){};K.prototype.GetAlpha=function(){};K.prototype.SetFillAlpha=function(){};K.prototype.GetFillAlpha=function(){};K.prototype.SetXFormScale=function(){};K.prototype.GetXFormScale=
function(){};K.prototype.DrawPolygon=function(){};K.prototype.DrawSolidPolygon=function(){};K.prototype.DrawCircle=function(){};K.prototype.DrawSolidCircle=function(){};K.prototype.DrawSegment=function(){};K.prototype.DrawTransform=function(){};_A2J_postDefs.push(function(){Box2D.Dynamics.b2DebugDraw.e_shapeBit=1;Box2D.Dynamics.b2DebugDraw.prototype.e_shapeBit=Box2D.Dynamics.b2DebugDraw.e_shapeBit;Box2D.Dynamics.b2DebugDraw.e_jointBit=2;Box2D.Dynamics.b2DebugDraw.prototype.e_jointBit=Box2D.Dynamics.b2DebugDraw.e_jointBit;
Box2D.Dynamics.b2DebugDraw.e_aabbBit=4;Box2D.Dynamics.b2DebugDraw.prototype.e_aabbBit=Box2D.Dynamics.b2DebugDraw.e_aabbBit;Box2D.Dynamics.b2DebugDraw.e_pairBit=8;Box2D.Dynamics.b2DebugDraw.prototype.e_pairBit=Box2D.Dynamics.b2DebugDraw.e_pairBit;Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit=16;Box2D.Dynamics.b2DebugDraw.prototype.e_centerOfMassBit=Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit;Box2D.Dynamics.b2DebugDraw.e_controllerBit=32;Box2D.Dynamics.b2DebugDraw.prototype.e_controllerBit=Box2D.Dynamics.b2DebugDraw.e_controllerBit});
ba.b2DestructionListener=function(){};ba.prototype.SayGoodbyeJoint=function(){};ba.prototype.SayGoodbyeFixture=function(){};V.b2FilterData=function(){this.categoryBits=1;this.maskBits=65535;this.groupIndex=0};V.prototype.Copy=function(){var a=new V;a.categoryBits=this.categoryBits;a.maskBits=this.maskBits;a.groupIndex=this.groupIndex;return a};Z.b2Fixture=function(){this.m_filter=new V};Z.prototype.GetType=function(){return this.m_shape.GetType()};Z.prototype.GetShape=function(){return this.m_shape};
Z.prototype.SetSensor=function(a){if(this.m_isSensor!=a){this.m_isSensor=a;if(this.m_body!=null)for(a=this.m_body.GetContactList();a;){var b=a.contact,f=b.GetFixtureA(),m=b.GetFixtureB();if(f==this||m==this)b.SetSensor(f.IsSensor()||m.IsSensor());a=a.next}}};Z.prototype.IsSensor=function(){return this.m_isSensor};Z.prototype.SetFilterData=function(a){this.m_filter=a.Copy();if(!this.m_body)for(a=this.m_body.GetContactList();a;){var b=a.contact,f=b.GetFixtureA(),m=b.GetFixtureB();if(f==this||m==this)b.FlagForFiltering();
a=a.next}};Z.prototype.GetFilterData=function(){return this.m_filter.Copy()};Z.prototype.GetBody=function(){return this.m_body};Z.prototype.GetNext=function(){return this.m_next};Z.prototype.GetUserData=function(){return this.m_userData};Z.prototype.SetUserData=function(a){this.m_userData=a};Z.prototype.TestPoint=function(a){return this.m_shape.TestPoint(this.m_body.GetTransform(),a)};Z.prototype.RayCast=function(a,b){return this.m_shape.RayCast(a,b,this.m_body.GetTransform())};Z.prototype.GetMassData=
function(a){if(a===undefined)a=null;if(a==null)a=new Q;this.m_shape.ComputeMass(a,this.m_density);return a};Z.prototype.SetDensity=function(a){if(a===undefined)a=0;this.m_density=a};Z.prototype.GetDensity=function(){return this.m_density};Z.prototype.GetFriction=function(){return this.m_friction};Z.prototype.SetFriction=function(a){if(a===undefined)a=0;this.m_friction=a};Z.prototype.GetRestitution=function(){return this.m_restitution};Z.prototype.SetRestitution=function(a){if(a===undefined)a=0;this.m_restitution=
a};Z.prototype.GetAABB=function(){return this.m_aabb};Z.prototype.b2Fixture=function(){this.m_aabb=new N;this.m_shape=this.m_next=this.m_body=this.m_userData=null;this.m_restitution=this.m_friction=this.m_density=0};Z.prototype.Create=function(a,b,f){this.m_userData=f.userData;this.m_friction=f.friction;this.m_restitution=f.restitution;this.m_body=a;this.m_next=null;this.m_filter=f.filter.Copy();this.m_isSensor=f.isSensor;this.m_shape=f.shape.Copy();this.m_density=f.density};Z.prototype.Destroy=function(){this.m_shape=
null};Z.prototype.CreateProxy=function(a,b){this.m_shape.ComputeAABB(this.m_aabb,b);this.m_proxy=a.CreateProxy(this.m_aabb,this)};Z.prototype.DestroyProxy=function(a){if(this.m_proxy!=null){a.DestroyProxy(this.m_proxy);this.m_proxy=null}};Z.prototype.Synchronize=function(a,b,f){if(this.m_proxy){var m=new N,p=new N;this.m_shape.ComputeAABB(m,b);this.m_shape.ComputeAABB(p,f);this.m_aabb.Combine(m,p);b=L.SubtractVV(f.position,b.position);a.MoveProxy(this.m_proxy,this.m_aabb,b)}};ga.b2FixtureDef=function(){this.filter=
new V};ga.prototype.b2FixtureDef=function(){this.userData=this.shape=null;this.friction=0.2;this.density=this.restitution=0;this.filter.categoryBits=1;this.filter.maskBits=65535;this.filter.groupIndex=0;this.isSensor=false};fa.b2Island=function(){};fa.prototype.b2Island=function(){this.m_bodies=new Vector;this.m_contacts=new Vector;this.m_joints=new Vector};fa.prototype.Initialize=function(a,b,f,m,p,D){if(a===undefined)a=0;if(b===undefined)b=0;if(f===undefined)f=0;var B=0;this.m_bodyCapacity=a;this.m_contactCapacity=
b;this.m_jointCapacity=f;this.m_jointCount=this.m_contactCount=this.m_bodyCount=0;this.m_allocator=m;this.m_listener=p;this.m_contactSolver=D;for(B=this.m_bodies.length;B<a;B++)this.m_bodies[B]=null;for(B=this.m_contacts.length;B<b;B++)this.m_contacts[B]=null;for(B=this.m_joints.length;B<f;B++)this.m_joints[B]=null};fa.prototype.Clear=function(){this.m_jointCount=this.m_contactCount=this.m_bodyCount=0};fa.prototype.Solve=function(a,b,f){var m=0,p=0,D;for(m=0;m<this.m_bodyCount;++m){p=this.m_bodies[m];
if(p.GetType()==j.b2_dynamicBody){p.m_linearVelocity.x+=a.dt*(b.x+p.m_invMass*p.m_force.x);p.m_linearVelocity.y+=a.dt*(b.y+p.m_invMass*p.m_force.y);p.m_angularVelocity+=a.dt*p.m_invI*p.m_torque;p.m_linearVelocity.Multiply(L.Clamp(1-a.dt*p.m_linearDamping,0,1));p.m_angularVelocity*=L.Clamp(1-a.dt*p.m_angularDamping,0,1)}}this.m_contactSolver.Initialize(a,this.m_contacts,this.m_contactCount,this.m_allocator);b=this.m_contactSolver;b.InitVelocityConstraints(a);for(m=0;m<this.m_jointCount;++m){D=this.m_joints[m];
D.InitVelocityConstraints(a)}for(m=0;m<a.velocityIterations;++m){for(p=0;p<this.m_jointCount;++p){D=this.m_joints[p];D.SolveVelocityConstraints(a)}b.SolveVelocityConstraints()}for(m=0;m<this.m_jointCount;++m){D=this.m_joints[m];D.FinalizeVelocityConstraints()}b.FinalizeVelocityConstraints();for(m=0;m<this.m_bodyCount;++m){p=this.m_bodies[m];if(p.GetType()!=j.b2_staticBody){var B=a.dt*p.m_linearVelocity.x,O=a.dt*p.m_linearVelocity.y;if(B*B+O*O>A.b2_maxTranslationSquared){p.m_linearVelocity.Normalize();
p.m_linearVelocity.x*=A.b2_maxTranslation*a.inv_dt;p.m_linearVelocity.y*=A.b2_maxTranslation*a.inv_dt}B=a.dt*p.m_angularVelocity;if(B*B>A.b2_maxRotationSquared)p.m_angularVelocity=p.m_angularVelocity<0?-A.b2_maxRotation*a.inv_dt:A.b2_maxRotation*a.inv_dt;p.m_sweep.c0.SetV(p.m_sweep.c);p.m_sweep.a0=p.m_sweep.a;p.m_sweep.c.x+=a.dt*p.m_linearVelocity.x;p.m_sweep.c.y+=a.dt*p.m_linearVelocity.y;p.m_sweep.a+=a.dt*p.m_angularVelocity;p.SynchronizeTransform()}}for(m=0;m<a.positionIterations;++m){B=b.SolvePositionConstraints(A.b2_contactBaumgarte);
O=true;for(p=0;p<this.m_jointCount;++p){D=this.m_joints[p];D=D.SolvePositionConstraints(A.b2_contactBaumgarte);O=O&&D}if(B&&O)break}this.Report(b.m_constraints);if(f){f=Number.MAX_VALUE;b=A.b2_linearSleepTolerance*A.b2_linearSleepTolerance;B=A.b2_angularSleepTolerance*A.b2_angularSleepTolerance;for(m=0;m<this.m_bodyCount;++m){p=this.m_bodies[m];if(p.GetType()!=j.b2_staticBody){if((p.m_flags&j.e_allowSleepFlag)==0)f=p.m_sleepTime=0;if((p.m_flags&j.e_allowSleepFlag)==0||p.m_angularVelocity*p.m_angularVelocity>
B||L.Dot(p.m_linearVelocity,p.m_linearVelocity)>b)f=p.m_sleepTime=0;else{p.m_sleepTime+=a.dt;f=L.Min(f,p.m_sleepTime)}}}if(f>=A.b2_timeToSleep)for(m=0;m<this.m_bodyCount;++m){p=this.m_bodies[m];p.SetAwake(false)}}};fa.prototype.SolveTOI=function(a){var b=0,f=0;this.m_contactSolver.Initialize(a,this.m_contacts,this.m_contactCount,this.m_allocator);var m=this.m_contactSolver;for(b=0;b<this.m_jointCount;++b)this.m_joints[b].InitVelocityConstraints(a);for(b=0;b<a.velocityIterations;++b){m.SolveVelocityConstraints();
for(f=0;f<this.m_jointCount;++f)this.m_joints[f].SolveVelocityConstraints(a)}for(b=0;b<this.m_bodyCount;++b){f=this.m_bodies[b];if(f.GetType()!=j.b2_staticBody){var p=a.dt*f.m_linearVelocity.x,D=a.dt*f.m_linearVelocity.y;if(p*p+D*D>A.b2_maxTranslationSquared){f.m_linearVelocity.Normalize();f.m_linearVelocity.x*=A.b2_maxTranslation*a.inv_dt;f.m_linearVelocity.y*=A.b2_maxTranslation*a.inv_dt}p=a.dt*f.m_angularVelocity;if(p*p>A.b2_maxRotationSquared)f.m_angularVelocity=f.m_angularVelocity<0?-A.b2_maxRotation*
a.inv_dt:A.b2_maxRotation*a.inv_dt;f.m_sweep.c0.SetV(f.m_sweep.c);f.m_sweep.a0=f.m_sweep.a;f.m_sweep.c.x+=a.dt*f.m_linearVelocity.x;f.m_sweep.c.y+=a.dt*f.m_linearVelocity.y;f.m_sweep.a+=a.dt*f.m_angularVelocity;f.SynchronizeTransform()}}for(b=0;b<a.positionIterations;++b){p=m.SolvePositionConstraints(0.75);D=true;for(f=0;f<this.m_jointCount;++f){var B=this.m_joints[f].SolvePositionConstraints(A.b2_contactBaumgarte);D=D&&B}if(p&&D)break}this.Report(m.m_constraints)};fa.prototype.Report=function(a){if(this.m_listener!=
null)for(var b=0;b<this.m_contactCount;++b){for(var f=this.m_contacts[b],m=a[b],p=0;p<m.pointCount;++p){fa.s_impulse.normalImpulses[p]=m.points[p].normalImpulse;fa.s_impulse.tangentImpulses[p]=m.points[p].tangentImpulse}this.m_listener.PostSolve(f,fa.s_impulse)}};fa.prototype.AddBody=function(a){a.m_islandIndex=this.m_bodyCount;this.m_bodies[this.m_bodyCount++]=a};fa.prototype.AddContact=function(a){this.m_contacts[this.m_contactCount++]=a};fa.prototype.AddJoint=function(a){this.m_joints[this.m_jointCount++]=
a};_A2J_postDefs.push(function(){Box2D.Dynamics.b2Island.s_impulse=new J;Box2D.Dynamics.b2Island.prototype.s_impulse=Box2D.Dynamics.b2Island.s_impulse});c.b2TimeStep=function(){};c.prototype.Set=function(a){this.dt=a.dt;this.inv_dt=a.inv_dt;this.positionIterations=a.positionIterations;this.velocityIterations=a.velocityIterations;this.warmStarting=a.warmStarting};g.b2World=function(){this.s_stack=new Vector;this.m_contactManager=new U;this.m_contactSolver=new o;this.m_island=new fa};g.prototype.b2World=
function(a,b){this.m_controllerList=this.m_jointList=this.m_contactList=this.m_bodyList=this.m_debugDraw=this.m_destructionListener=null;this.m_controllerCount=this.m_jointCount=this.m_contactCount=this.m_bodyCount=0;g.m_warmStarting=true;g.m_continuousPhysics=true;this.m_allowSleep=b;this.m_gravity=a;this.m_inv_dt0=0;this.m_contactManager.m_world=this;this.m_groundBody=this.CreateBody(new y)};g.prototype.SetDestructionListener=function(a){this.m_destructionListener=a};g.prototype.SetContactFilter=
function(a){this.m_contactManager.m_contactFilter=a};g.prototype.SetContactListener=function(a){this.m_contactManager.m_contactListener=a};g.prototype.SetDebugDraw=function(a){this.m_debugDraw=a};g.prototype.SetBroadPhase=function(a){var b=this.m_contactManager.m_broadPhase;this.m_contactManager.m_broadPhase=a;for(var f=this.m_bodyList;f;f=f.m_next)for(var m=f.m_fixtureList;m;m=m.m_next)m.m_proxy=a.CreateProxy(b.GetFatAABB(m.m_proxy),m)};g.prototype.Validate=function(){this.m_contactManager.m_broadPhase.Validate()};
g.prototype.GetProxyCount=function(){return this.m_contactManager.m_broadPhase.GetProxyCount()};g.prototype.CreateBody=function(a){if(this.IsLocked()==true)return null;a=new j(a,this);a.m_prev=null;if(a.m_next=this.m_bodyList)this.m_bodyList.m_prev=a;this.m_bodyList=a;++this.m_bodyCount;return a};g.prototype.DestroyBody=function(a){if(this.IsLocked()!=true){for(var b=a.m_jointList;b;){var f=b;b=b.next;this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(f.joint);this.DestroyJoint(f.joint)}for(b=
a.m_controllerList;b;){f=b;b=b.nextController;f.controller.RemoveBody(a)}for(b=a.m_contactList;b;){f=b;b=b.next;this.m_contactManager.Destroy(f.contact)}a.m_contactList=null;for(b=a.m_fixtureList;b;){f=b;b=b.m_next;this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(f);f.DestroyProxy(this.m_contactManager.m_broadPhase);f.Destroy()}a.m_fixtureList=null;a.m_fixtureCount=0;if(a.m_prev)a.m_prev.m_next=a.m_next;if(a.m_next)a.m_next.m_prev=a.m_prev;if(a==this.m_bodyList)this.m_bodyList=
a.m_next;--this.m_bodyCount}};g.prototype.CreateJoint=function(a){var b=q.Create(a,null);b.m_prev=null;if(b.m_next=this.m_jointList)this.m_jointList.m_prev=b;this.m_jointList=b;++this.m_jointCount;b.m_edgeA.joint=b;b.m_edgeA.other=b.m_bodyB;b.m_edgeA.prev=null;if(b.m_edgeA.next=b.m_bodyA.m_jointList)b.m_bodyA.m_jointList.prev=b.m_edgeA;b.m_bodyA.m_jointList=b.m_edgeA;b.m_edgeB.joint=b;b.m_edgeB.other=b.m_bodyA;b.m_edgeB.prev=null;if(b.m_edgeB.next=b.m_bodyB.m_jointList)b.m_bodyB.m_jointList.prev=
b.m_edgeB;b.m_bodyB.m_jointList=b.m_edgeB;var f=a.bodyA,m=a.bodyB;if(a.collideConnected==false)for(a=m.GetContactList();a;){a.other==f&&a.contact.FlagForFiltering();a=a.next}return b};g.prototype.DestroyJoint=function(a){var b=a.m_collideConnected;if(a.m_prev)a.m_prev.m_next=a.m_next;if(a.m_next)a.m_next.m_prev=a.m_prev;if(a==this.m_jointList)this.m_jointList=a.m_next;var f=a.m_bodyA,m=a.m_bodyB;f.SetAwake(true);m.SetAwake(true);if(a.m_edgeA.prev)a.m_edgeA.prev.next=a.m_edgeA.next;if(a.m_edgeA.next)a.m_edgeA.next.prev=
a.m_edgeA.prev;if(a.m_edgeA==f.m_jointList)f.m_jointList=a.m_edgeA.next;a.m_edgeA.prev=null;a.m_edgeA.next=null;if(a.m_edgeB.prev)a.m_edgeB.prev.next=a.m_edgeB.next;if(a.m_edgeB.next)a.m_edgeB.next.prev=a.m_edgeB.prev;if(a.m_edgeB==m.m_jointList)m.m_jointList=a.m_edgeB.next;a.m_edgeB.prev=null;a.m_edgeB.next=null;q.Destroy(a,null);--this.m_jointCount;if(b==false)for(a=m.GetContactList();a;){a.other==f&&a.contact.FlagForFiltering();a=a.next}};g.prototype.AddController=function(a){a.m_next=this.m_controllerList;
a.m_prev=null;this.m_controllerList=a;a.m_world=this;this.m_controllerCount++;return a};g.prototype.RemoveController=function(a){if(a.m_prev)a.m_prev.m_next=a.m_next;if(a.m_next)a.m_next.m_prev=a.m_prev;if(this.m_controllerList==a)this.m_controllerList=a.m_next;this.m_controllerCount--};g.prototype.CreateController=function(a){if(a.m_world!=this)throw Error("Controller can only be a member of one world");a.m_next=this.m_controllerList;a.m_prev=null;if(this.m_controllerList)this.m_controllerList.m_prev=
a;this.m_controllerList=a;++this.m_controllerCount;a.m_world=this;return a};g.prototype.DestroyController=function(a){a.Clear();if(a.m_next)a.m_next.m_prev=a.m_prev;if(a.m_prev)a.m_prev.m_next=a.m_next;if(a==this.m_controllerList)this.m_controllerList=a.m_next;--this.m_controllerCount};g.prototype.SetWarmStarting=function(a){g.m_warmStarting=a};g.prototype.SetContinuousPhysics=function(a){g.m_continuousPhysics=a};g.prototype.GetBodyCount=function(){return this.m_bodyCount};g.prototype.GetJointCount=
function(){return this.m_jointCount};g.prototype.GetContactCount=function(){return this.m_contactCount};g.prototype.SetGravity=function(a){this.m_gravity=a};g.prototype.GetGravity=function(){return this.m_gravity};g.prototype.GetGroundBody=function(){return this.m_groundBody};g.prototype.Step=function(a,b,f){if(a===undefined)a=0;if(b===undefined)b=0;if(f===undefined)f=0;if(this.m_flags&g.e_newFixture){this.m_contactManager.FindNewContacts();this.m_flags&=~g.e_newFixture}this.m_flags|=g.e_locked;var m=
g.s_timestep2;m.dt=a;m.velocityIterations=b;m.positionIterations=f;m.inv_dt=a>0?1/a:0;m.dtRatio=this.m_inv_dt0*a;m.warmStarting=g.m_warmStarting;this.m_contactManager.Collide();m.dt>0&&this.Solve(m);g.m_continuousPhysics&&m.dt>0&&this.SolveTOI(m);if(m.dt>0)this.m_inv_dt0=m.inv_dt;this.m_flags&=~g.e_locked};g.prototype.ClearForces=function(){for(var a=this.m_bodyList;a;a=a.m_next){a.m_force.SetZero();a.m_torque=0}};g.prototype.DrawDebugData=function(){if(this.m_debugDraw!=null){this.m_debugDraw.m_sprite.graphics.clear();
var a=this.m_debugDraw.GetFlags(),b,f,m;new F;new F;new F;var p;new N;new N;p=[new F,new F,new F,new F];var D=new G(0,0,0);if(a&K.e_shapeBit)for(b=this.m_bodyList;b;b=b.m_next){p=b.m_xf;for(f=b.GetFixtureList();f;f=f.m_next){m=f.GetShape();if(b.IsActive()==false)D.Set(0.5,0.5,0.3);else if(b.GetType()==j.b2_staticBody)D.Set(0.5,0.9,0.5);else if(b.GetType()==j.b2_kinematicBody)D.Set(0.5,0.5,0.9);else b.IsAwake()==false?D.Set(0.6,0.6,0.6):D.Set(0.9,0.7,0.7);this.DrawShape(m,p,D)}}if(a&K.e_jointBit)for(b=
this.m_jointList;b;b=b.m_next)this.DrawJoint(b);if(a&K.e_controllerBit)for(b=this.m_controllerList;b;b=b.m_next)b.Draw(this.m_debugDraw);if(a&K.e_pairBit){D.Set(0.3,0.9,0.9);for(b=this.m_contactManager.m_contactList;b;b=b.GetNext()){m=b.GetFixtureA();f=b.GetFixtureB();m=m.GetAABB().GetCenter();f=f.GetAABB().GetCenter();this.m_debugDraw.DrawSegment(m,f,D)}}if(a&K.e_aabbBit){m=this.m_contactManager.m_broadPhase;p=[new F,new F,new F,new F];for(b=this.m_bodyList;b;b=b.GetNext())if(b.IsActive()!=false)for(f=
b.GetFixtureList();f;f=f.GetNext()){var B=m.GetFatAABB(f.m_proxy);p[0].Set(B.lowerBound.x,B.lowerBound.y);p[1].Set(B.upperBound.x,B.lowerBound.y);p[2].Set(B.upperBound.x,B.upperBound.y);p[3].Set(B.lowerBound.x,B.upperBound.y);this.m_debugDraw.DrawPolygon(p,4,D)}}if(a&K.e_centerOfMassBit)for(b=this.m_bodyList;b;b=b.m_next){p=g.s_xf;p.R=b.m_xf.R;p.position=b.GetWorldCenter();this.m_debugDraw.DrawTransform(p)}}};g.prototype.QueryAABB=function(a,b){var f=this.m_contactManager.m_broadPhase;f.Query(function(m){return a(f.GetUserData(m))},
b)};g.prototype.QueryShape=function(a,b,f){if(f===undefined)f=null;if(f==null){f=new H;f.SetIdentity()}var m=this.m_contactManager.m_broadPhase,p=new N;b.ComputeAABB(p,f);m.Query(function(D){D=m.GetUserData(D)instanceof Z?m.GetUserData(D):null;if(da.TestOverlap(b,f,D.GetShape(),D.GetBody().GetTransform()))return a(D);return true},p)};g.prototype.QueryPoint=function(a,b){var f=this.m_contactManager.m_broadPhase,m=new N;m.lowerBound.Set(b.x-A.b2_linearSlop,b.y-A.b2_linearSlop);m.upperBound.Set(b.x+
A.b2_linearSlop,b.y+A.b2_linearSlop);f.Query(function(p){p=f.GetUserData(p)instanceof Z?f.GetUserData(p):null;if(p.TestPoint(b))return a(p);return true},m)};g.prototype.RayCast=function(a,b,f){var m=this.m_contactManager.m_broadPhase,p=new aa,D=new R(b,f);m.RayCast(function(B,O){var W=m.GetUserData(O);W=W instanceof Z?W:null;if(W.RayCast(p,B)){var ca=p.fraction,d=new F((1-ca)*b.x+ca*f.x,(1-ca)*b.y+ca*f.y);return a(W,d,p.normal,ca)}return B.maxFraction},D)};g.prototype.RayCastOne=function(a,b){var f;
this.RayCast(function(m,p,D,B){if(B===undefined)B=0;f=m;return B},a,b);return f};g.prototype.RayCastAll=function(a,b){var f=new Vector;this.RayCast(function(m){f[f.length]=m;return 1},a,b);return f};g.prototype.GetBodyList=function(){return this.m_bodyList};g.prototype.GetJointList=function(){return this.m_jointList};g.prototype.GetContactList=function(){return this.m_contactList};g.prototype.IsLocked=function(){return(this.m_flags&g.e_locked)>0};g.prototype.Solve=function(a){for(var b,f=this.m_controllerList;f;f=
f.m_next)f.Step(a);f=this.m_island;f.Initialize(this.m_bodyCount,this.m_contactCount,this.m_jointCount,null,this.m_contactManager.m_contactListener,this.m_contactSolver);for(b=this.m_bodyList;b;b=b.m_next)b.m_flags&=~j.e_islandFlag;for(var m=this.m_contactList;m;m=m.m_next)m.m_flags&=~k.e_islandFlag;for(m=this.m_jointList;m;m=m.m_next)m.m_islandFlag=false;parseInt(this.m_bodyCount);m=this.s_stack;for(var p=this.m_bodyList;p;p=p.m_next)if(!(p.m_flags&j.e_islandFlag))if(!(p.IsAwake()==false||p.IsActive()==
false))if(p.GetType()!=j.b2_staticBody){f.Clear();var D=0;m[D++]=p;for(p.m_flags|=j.e_islandFlag;D>0;){b=m[--D];f.AddBody(b);b.IsAwake()==false&&b.SetAwake(true);if(b.GetType()!=j.b2_staticBody){for(var B,O=b.m_contactList;O;O=O.next)if(!(O.contact.m_flags&k.e_islandFlag))if(!(O.contact.IsSensor()==true||O.contact.IsEnabled()==false||O.contact.IsTouching()==false)){f.AddContact(O.contact);O.contact.m_flags|=k.e_islandFlag;B=O.other;if(!(B.m_flags&j.e_islandFlag)){m[D++]=B;B.m_flags|=j.e_islandFlag}}for(b=
b.m_jointList;b;b=b.next)if(b.joint.m_islandFlag!=true){B=b.other;if(B.IsActive()!=false){f.AddJoint(b.joint);b.joint.m_islandFlag=true;if(!(B.m_flags&j.e_islandFlag)){m[D++]=B;B.m_flags|=j.e_islandFlag}}}}}f.Solve(a,this.m_gravity,this.m_allowSleep);for(D=0;D<f.m_bodyCount;++D){b=f.m_bodies[D];if(b.GetType()==j.b2_staticBody)b.m_flags&=~j.e_islandFlag}}for(D=0;D<m.length;++D){if(!m[D])break;m[D]=null}for(b=this.m_bodyList;b;b=b.m_next)b.IsAwake()==false||b.IsActive()==false||b.GetType()!=j.b2_staticBody&&
b.SynchronizeFixtures();this.m_contactManager.FindNewContacts()};g.prototype.SolveTOI=function(a){var b,f,m,p=this.m_island;p.Initialize(this.m_bodyCount,A.b2_maxTOIContactsPerIsland,A.b2_maxTOIJointsPerIsland,null,this.m_contactManager.m_contactListener,this.m_contactSolver);var D=g.s_queue;for(b=this.m_bodyList;b;b=b.m_next){b.m_flags&=~j.e_islandFlag;b.m_sweep.t0=0}for(m=this.m_contactList;m;m=m.m_next)m.m_flags&=~(k.e_toiFlag|k.e_islandFlag);for(m=this.m_jointList;m;m=m.m_next)m.m_islandFlag=
false;for(;;){var B=null,O=1;for(m=this.m_contactList;m;m=m.m_next)if(!(m.IsSensor()==true||m.IsEnabled()==false||m.IsContinuous()==false)){b=1;if(m.m_flags&k.e_toiFlag)b=m.m_toi;else{b=m.m_fixtureA;f=m.m_fixtureB;b=b.m_body;f=f.m_body;if((b.GetType()!=j.b2_dynamicBody||b.IsAwake()==false)&&(f.GetType()!=j.b2_dynamicBody||f.IsAwake()==false))continue;var W=b.m_sweep.t0;if(b.m_sweep.t0<f.m_sweep.t0){W=f.m_sweep.t0;b.m_sweep.Advance(W)}else if(f.m_sweep.t0<b.m_sweep.t0){W=b.m_sweep.t0;f.m_sweep.Advance(W)}b=
m.ComputeTOI(b.m_sweep,f.m_sweep);A.b2Assert(0<=b&&b<=1);if(b>0&&b<1){b=(1-b)*W+b;if(b>1)b=1}m.m_toi=b;m.m_flags|=k.e_toiFlag}if(Number.MIN_VALUE<b&&b<O){B=m;O=b}}if(B==null||1-100*Number.MIN_VALUE<O)break;b=B.m_fixtureA;f=B.m_fixtureB;b=b.m_body;f=f.m_body;g.s_backupA.Set(b.m_sweep);g.s_backupB.Set(f.m_sweep);b.Advance(O);f.Advance(O);B.Update(this.m_contactManager.m_contactListener);B.m_flags&=~k.e_toiFlag;if(B.IsSensor()==true||B.IsEnabled()==false){b.m_sweep.Set(g.s_backupA);f.m_sweep.Set(g.s_backupB);
b.SynchronizeTransform();f.SynchronizeTransform()}else if(B.IsTouching()!=false){b=b;if(b.GetType()!=j.b2_dynamicBody)b=f;p.Clear();B=m=0;D[m+B++]=b;for(b.m_flags|=j.e_islandFlag;B>0;){b=D[m++];--B;p.AddBody(b);b.IsAwake()==false&&b.SetAwake(true);if(b.GetType()==j.b2_dynamicBody){for(f=b.m_contactList;f;f=f.next){if(p.m_contactCount==p.m_contactCapacity)break;if(!(f.contact.m_flags&k.e_islandFlag))if(!(f.contact.IsSensor()==true||f.contact.IsEnabled()==false||f.contact.IsTouching()==false)){p.AddContact(f.contact);
f.contact.m_flags|=k.e_islandFlag;W=f.other;if(!(W.m_flags&j.e_islandFlag)){if(W.GetType()!=j.b2_staticBody){W.Advance(O);W.SetAwake(true)}D[m+B]=W;++B;W.m_flags|=j.e_islandFlag}}}for(b=b.m_jointList;b;b=b.next)if(p.m_jointCount!=p.m_jointCapacity)if(b.joint.m_islandFlag!=true){W=b.other;if(W.IsActive()!=false){p.AddJoint(b.joint);b.joint.m_islandFlag=true;if(!(W.m_flags&j.e_islandFlag)){if(W.GetType()!=j.b2_staticBody){W.Advance(O);W.SetAwake(true)}D[m+B]=W;++B;W.m_flags|=j.e_islandFlag}}}}}m=g.s_timestep;
m.warmStarting=false;m.dt=(1-O)*a.dt;m.inv_dt=1/m.dt;m.dtRatio=0;m.velocityIterations=a.velocityIterations;m.positionIterations=a.positionIterations;p.SolveTOI(m);for(O=O=0;O<p.m_bodyCount;++O){b=p.m_bodies[O];b.m_flags&=~j.e_islandFlag;if(b.IsAwake()!=false)if(b.GetType()==j.b2_dynamicBody){b.SynchronizeFixtures();for(f=b.m_contactList;f;f=f.next)f.contact.m_flags&=~k.e_toiFlag}}for(O=0;O<p.m_contactCount;++O){m=p.m_contacts[O];m.m_flags&=~(k.e_toiFlag|k.e_islandFlag)}for(O=0;O<p.m_jointCount;++O){m=
p.m_joints[O];m.m_islandFlag=false}this.m_contactManager.FindNewContacts()}}};g.prototype.DrawJoint=function(a){var b=a.GetBodyA(),f=a.GetBodyB(),m=b.m_xf.position,p=f.m_xf.position,D=a.GetAnchorA(),B=a.GetAnchorB(),O=g.s_jointColor;switch(a.m_type){case q.e_distanceJoint:this.m_debugDraw.DrawSegment(D,B,O);break;case q.e_pulleyJoint:b=a instanceof l?a:null;a=b.GetGroundAnchorA();b=b.GetGroundAnchorB();this.m_debugDraw.DrawSegment(a,D,O);this.m_debugDraw.DrawSegment(b,B,O);this.m_debugDraw.DrawSegment(a,
b,O);break;case q.e_mouseJoint:this.m_debugDraw.DrawSegment(D,B,O);break;default:b!=this.m_groundBody&&this.m_debugDraw.DrawSegment(m,D,O);this.m_debugDraw.DrawSegment(D,B,O);f!=this.m_groundBody&&this.m_debugDraw.DrawSegment(p,B,O)}};g.prototype.DrawShape=function(a,b,f){switch(a.m_type){case da.e_circleShape:var m=a instanceof $?a:null;this.m_debugDraw.DrawSolidCircle(L.MulX(b,m.m_p),m.m_radius,b.R.col1,f);break;case da.e_polygonShape:m=0;m=a instanceof X?a:null;a=parseInt(m.GetVertexCount());var p=
m.GetVertices(),D=new Vector(a);for(m=0;m<a;++m)D[m]=L.MulX(b,p[m]);this.m_debugDraw.DrawSolidPolygon(D,a,f);break;case da.e_edgeShape:m=a instanceof T?a:null;this.m_debugDraw.DrawSegment(L.MulX(b,m.GetVertex1()),L.MulX(b,m.GetVertex2()),f)}};_A2J_postDefs.push(function(){Box2D.Dynamics.b2World.s_timestep2=new c;Box2D.Dynamics.b2World.prototype.s_timestep2=Box2D.Dynamics.b2World.s_timestep2;Box2D.Dynamics.b2World.s_xf=new H;Box2D.Dynamics.b2World.prototype.s_xf=Box2D.Dynamics.b2World.s_xf;Box2D.Dynamics.b2World.s_backupA=
new I;Box2D.Dynamics.b2World.prototype.s_backupA=Box2D.Dynamics.b2World.s_backupA;Box2D.Dynamics.b2World.s_backupB=new I;Box2D.Dynamics.b2World.prototype.s_backupB=Box2D.Dynamics.b2World.s_backupB;Box2D.Dynamics.b2World.s_timestep=new c;Box2D.Dynamics.b2World.prototype.s_timestep=Box2D.Dynamics.b2World.s_timestep;Box2D.Dynamics.b2World.s_queue=new Vector;Box2D.Dynamics.b2World.prototype.s_queue=Box2D.Dynamics.b2World.s_queue;Box2D.Dynamics.b2World.s_jointColor=new G(0.5,0.8,0.8);Box2D.Dynamics.b2World.prototype.s_jointColor=
Box2D.Dynamics.b2World.s_jointColor;Box2D.Dynamics.b2World.e_newFixture=1;Box2D.Dynamics.b2World.prototype.e_newFixture=Box2D.Dynamics.b2World.e_newFixture;Box2D.Dynamics.b2World.e_locked=2;Box2D.Dynamics.b2World.prototype.e_locked=Box2D.Dynamics.b2World.e_locked})})();
(function(){var L=Box2D.Collision.Shapes.b2CircleShape,I=Box2D.Collision.Shapes.b2EdgeShape,H=Box2D.Collision.Shapes.b2PolygonShape,F=Box2D.Collision.Shapes.b2Shape,G=Box2D.Dynamics.Contacts.b2CircleContact,A=Box2D.Dynamics.Contacts.b2Contact,N=Box2D.Dynamics.Contacts.b2ContactConstraint,s=Box2D.Dynamics.Contacts.b2ContactConstraintPoint,C=Box2D.Dynamics.Contacts.b2ContactEdge,R=Box2D.Dynamics.Contacts.b2ContactFactory,aa=Box2D.Dynamics.Contacts.b2ContactRegister,$=Box2D.Dynamics.Contacts.b2ContactResult,
T=Box2D.Dynamics.Contacts.b2ContactSolver,Q=Box2D.Dynamics.Contacts.b2EdgeAndCircleContact,X=Box2D.Dynamics.Contacts.b2NullContact,da=Box2D.Dynamics.Contacts.b2PolyAndCircleContact,j=Box2D.Dynamics.Contacts.b2PolyAndEdgeContact,y=Box2D.Dynamics.Contacts.b2PolygonContact,x=Box2D.Dynamics.Contacts.b2PositionSolverManifold,J=Box2D.Dynamics.b2Body,M=Box2D.Dynamics.b2TimeStep,U=Box2D.Common.b2Settings,K=Box2D.Common.Math.b2Mat22,ba=Box2D.Common.Math.b2Math,V=Box2D.Common.Math.b2Vec2,Z=Box2D.Collision.b2Collision,
ga=Box2D.Collision.b2ContactID,fa=Box2D.Collision.b2Manifold,c=Box2D.Collision.b2TimeOfImpact,g=Box2D.Collision.b2TOIInput,k=Box2D.Collision.b2WorldManifold;G=Box2D.Dynamics.Contacts.b2CircleContact;A=Box2D.Dynamics.Contacts.b2Contact;N=Box2D.Dynamics.Contacts.b2ContactConstraint;s=Box2D.Dynamics.Contacts.b2ContactConstraintPoint;C=Box2D.Dynamics.Contacts.b2ContactEdge;R=Box2D.Dynamics.Contacts.b2ContactFactory;aa=Box2D.Dynamics.Contacts.b2ContactRegister;$=Box2D.Dynamics.Contacts.b2ContactResult;
T=Box2D.Dynamics.Contacts.b2ContactSolver;Q=Box2D.Dynamics.Contacts.b2EdgeAndCircleContact;X=Box2D.Dynamics.Contacts.b2NullContact;da=Box2D.Dynamics.Contacts.b2PolyAndCircleContact;j=Box2D.Dynamics.Contacts.b2PolyAndEdgeContact;y=Box2D.Dynamics.Contacts.b2PolygonContact;x=Box2D.Dynamics.Contacts.b2PositionSolverManifold;G.inherit(Box2D.Dynamics.Contacts.b2Contact);G.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;G.b2CircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,
arguments)};G.prototype.Create=function(){return new G};G.Create=G.prototype.Create;G.prototype.Destroy=function(){};G.Destroy=G.prototype.Destroy;G.prototype.Reset=function(h,o){this.__super.Reset.call(this,h,o)};G.prototype.Evaluate=function(){var h=this.m_fixtureA.GetBody(),o=this.m_fixtureB.GetBody();Z.CollideCircles(this.m_manifold,this.m_fixtureA.GetShape()instanceof L?this.m_fixtureA.GetShape():null,h.m_xf,this.m_fixtureB.GetShape()instanceof L?this.m_fixtureB.GetShape():null,o.m_xf)};A.b2Contact=
function(){this.m_nodeA=new C;this.m_nodeB=new C;this.m_manifold=new fa;this.m_oldManifold=new fa};A.prototype.GetManifold=function(){return this.m_manifold};A.prototype.GetWorldManifold=function(h){var o=this.m_fixtureA.GetBody(),q=this.m_fixtureB.GetBody(),l=this.m_fixtureA.GetShape(),a=this.m_fixtureB.GetShape();h.Initialize(this.m_manifold,o.GetTransform(),l.m_radius,q.GetTransform(),a.m_radius)};A.prototype.IsTouching=function(){return(this.m_flags&A.e_touchingFlag)==A.e_touchingFlag};A.prototype.IsContinuous=
function(){return(this.m_flags&A.e_continuousFlag)==A.e_continuousFlag};A.prototype.SetSensor=function(h){if(h)this.m_flags|=A.e_sensorFlag;else this.m_flags&=~A.e_sensorFlag};A.prototype.IsSensor=function(){return(this.m_flags&A.e_sensorFlag)==A.e_sensorFlag};A.prototype.SetEnabled=function(h){if(h)this.m_flags|=A.e_enabledFlag;else this.m_flags&=~A.e_enabledFlag};A.prototype.IsEnabled=function(){return(this.m_flags&A.e_enabledFlag)==A.e_enabledFlag};A.prototype.GetNext=function(){return this.m_next};
A.prototype.GetFixtureA=function(){return this.m_fixtureA};A.prototype.GetFixtureB=function(){return this.m_fixtureB};A.prototype.FlagForFiltering=function(){this.m_flags|=A.e_filterFlag};A.prototype.b2Contact=function(){};A.prototype.Reset=function(h,o){if(h===undefined)h=null;if(o===undefined)o=null;this.m_flags=A.e_enabledFlag;if(!h||!o)this.m_fixtureB=this.m_fixtureA=null;else{if(h.IsSensor()||o.IsSensor())this.m_flags|=A.e_sensorFlag;var q=h.GetBody(),l=o.GetBody();if(q.GetType()!=J.b2_dynamicBody||
q.IsBullet()||l.GetType()!=J.b2_dynamicBody||l.IsBullet())this.m_flags|=A.e_continuousFlag;this.m_fixtureA=h;this.m_fixtureB=o;this.m_manifold.m_pointCount=0;this.m_next=this.m_prev=null;this.m_nodeA.contact=null;this.m_nodeA.prev=null;this.m_nodeA.next=null;this.m_nodeA.other=null;this.m_nodeB.contact=null;this.m_nodeB.prev=null;this.m_nodeB.next=null;this.m_nodeB.other=null}};A.prototype.Update=function(h){var o=this.m_oldManifold;this.m_oldManifold=this.m_manifold;this.m_manifold=o;this.m_flags|=
A.e_enabledFlag;var q=false;o=(this.m_flags&A.e_touchingFlag)==A.e_touchingFlag;var l=this.m_fixtureA.m_body,a=this.m_fixtureB.m_body,b=this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb);if(this.m_flags&A.e_sensorFlag){if(b){q=this.m_fixtureA.GetShape();b=this.m_fixtureB.GetShape();l=l.GetTransform();a=a.GetTransform();q=F.TestOverlap(q,l,b,a)}this.m_manifold.m_pointCount=0}else{if(l.GetType()!=J.b2_dynamicBody||l.IsBullet()||a.GetType()!=J.b2_dynamicBody||a.IsBullet())this.m_flags|=A.e_continuousFlag;
else this.m_flags&=~A.e_continuousFlag;if(b){this.Evaluate();q=this.m_manifold.m_pointCount>0;for(b=0;b<this.m_manifold.m_pointCount;++b){var f=this.m_manifold.m_points[b];f.m_normalImpulse=0;f.m_tangentImpulse=0;for(var m=f.m_id,p=0;p<this.m_oldManifold.m_pointCount;++p){var D=this.m_oldManifold.m_points[p];if(D.m_id.key==m.key){f.m_normalImpulse=D.m_normalImpulse;f.m_tangentImpulse=D.m_tangentImpulse;break}}}}else this.m_manifold.m_pointCount=0;if(q!=o){l.SetAwake(true);a.SetAwake(true)}}if(q)this.m_flags|=
A.e_touchingFlag;else this.m_flags&=~A.e_touchingFlag;o==false&&q==true&&h.BeginContact(this);o==true&&q==false&&h.EndContact(this);(this.m_flags&A.e_sensorFlag)==0&&h.PreSolve(this,this.m_oldManifold)};A.prototype.Evaluate=function(){};A.prototype.ComputeTOI=function(h,o){A.s_input.proxyA.Set(this.m_fixtureA.GetShape());A.s_input.proxyB.Set(this.m_fixtureB.GetShape());A.s_input.sweepA=h;A.s_input.sweepB=o;A.s_input.tolerance=U.b2_linearSlop;return c.TimeOfImpact(A.s_input)};_A2J_postDefs.push(function(){Box2D.Dynamics.Contacts.b2Contact.e_sensorFlag=
1;Box2D.Dynamics.Contacts.b2Contact.prototype.e_sensorFlag=Box2D.Dynamics.Contacts.b2Contact.e_sensorFlag;Box2D.Dynamics.Contacts.b2Contact.e_continuousFlag=2;Box2D.Dynamics.Contacts.b2Contact.prototype.e_continuousFlag=Box2D.Dynamics.Contacts.b2Contact.e_continuousFlag;Box2D.Dynamics.Contacts.b2Contact.e_islandFlag=4;Box2D.Dynamics.Contacts.b2Contact.prototype.e_islandFlag=Box2D.Dynamics.Contacts.b2Contact.e_islandFlag;Box2D.Dynamics.Contacts.b2Contact.e_toiFlag=8;Box2D.Dynamics.Contacts.b2Contact.prototype.e_toiFlag=
Box2D.Dynamics.Contacts.b2Contact.e_toiFlag;Box2D.Dynamics.Contacts.b2Contact.e_touchingFlag=16;Box2D.Dynamics.Contacts.b2Contact.prototype.e_touchingFlag=Box2D.Dynamics.Contacts.b2Contact.e_touchingFlag;Box2D.Dynamics.Contacts.b2Contact.e_enabledFlag=32;Box2D.Dynamics.Contacts.b2Contact.prototype.e_enabledFlag=Box2D.Dynamics.Contacts.b2Contact.e_enabledFlag;Box2D.Dynamics.Contacts.b2Contact.e_filterFlag=64;Box2D.Dynamics.Contacts.b2Contact.prototype.e_filterFlag=Box2D.Dynamics.Contacts.b2Contact.e_filterFlag;
Box2D.Dynamics.Contacts.b2Contact.s_input=new g;Box2D.Dynamics.Contacts.b2Contact.prototype.s_input=Box2D.Dynamics.Contacts.b2Contact.s_input});N.b2ContactConstraint=function(){this.localPlaneNormal=new V;this.localPoint=new V;this.normal=new V;this.normalMass=new K;this.K=new K};N.prototype.b2ContactConstraint=function(){this.points=new Vector(U.b2_maxManifoldPoints);for(var h=0;h<U.b2_maxManifoldPoints;h++)this.points[h]=new s};s.b2ContactConstraintPoint=function(){this.localPoint=new V;this.rA=
new V;this.rB=new V};C.b2ContactEdge=function(){};R.b2ContactFactory=function(){};R.prototype.b2ContactFactory=function(h){this.m_allocator=h;this.InitializeRegisters()};R.prototype.AddType=function(h,o,q,l){if(q===undefined)q=0;if(l===undefined)l=0;this.m_registers[q][l].createFcn=h;this.m_registers[q][l].destroyFcn=o;this.m_registers[q][l].primary=true;if(q!=l){this.m_registers[l][q].createFcn=h;this.m_registers[l][q].destroyFcn=o;this.m_registers[l][q].primary=false}};R.prototype.InitializeRegisters=
function(){this.m_registers=new Vector(F.e_shapeTypeCount);for(var h=0;h<F.e_shapeTypeCount;h++){this.m_registers[h]=new Vector(F.e_shapeTypeCount);for(var o=0;o<F.e_shapeTypeCount;o++)this.m_registers[h][o]=new aa}this.AddType(G.Create,G.Destroy,F.e_circleShape,F.e_circleShape);this.AddType(da.Create,da.Destroy,F.e_polygonShape,F.e_circleShape);this.AddType(y.Create,y.Destroy,F.e_polygonShape,F.e_polygonShape);this.AddType(Q.Create,Q.Destroy,F.e_edgeShape,F.e_circleShape);this.AddType(j.Create,j.Destroy,
F.e_polygonShape,F.e_edgeShape)};R.prototype.Create=function(h,o){var q=parseInt(h.GetType()),l=parseInt(o.GetType());q=this.m_registers[q][l];if(q.pool){l=q.pool;q.pool=l.m_next;q.poolCount--;l.Reset(h,o);return l}l=q.createFcn;if(l!=null){if(q.primary){l=l(this.m_allocator);l.Reset(h,o)}else{l=l(this.m_allocator);l.Reset(o,h)}return l}else return null};R.prototype.Destroy=function(h){if(h.m_manifold.m_pointCount>0){h.m_fixtureA.m_body.SetAwake(true);h.m_fixtureB.m_body.SetAwake(true)}var o=parseInt(h.m_fixtureA.GetType()),
q=parseInt(h.m_fixtureB.GetType());o=this.m_registers[o][q];o.poolCount++;h.m_next=o.pool;o.pool=h;o=o.destroyFcn;o(h,this.m_allocator)};aa.b2ContactRegister=function(){};$.b2ContactResult=function(){this.position=new V;this.normal=new V;this.id=new ga};T.b2ContactSolver=function(){this.m_step=new M;this.m_constraints=new Vector};T.prototype.b2ContactSolver=function(){};T.prototype.Initialize=function(h,o,q,l){if(q===undefined)q=0;var a;this.m_step.Set(h);this.m_allocator=l;h=0;for(this.m_constraintCount=
q;this.m_constraints.length<this.m_constraintCount;)this.m_constraints[this.m_constraints.length]=new N;for(h=0;h<q;++h){a=o[h];l=a.m_fixtureA;var b=a.m_fixtureB,f=l.m_shape.m_radius,m=b.m_shape.m_radius,p=l.m_body,D=b.m_body,B=a.GetManifold(),O=U.b2MixFriction(l.GetFriction(),b.GetFriction()),W=U.b2MixRestitution(l.GetRestitution(),b.GetRestitution()),ca=p.m_linearVelocity.x,d=p.m_linearVelocity.y,n=D.m_linearVelocity.x,e=D.m_linearVelocity.y,r=p.m_angularVelocity,t=D.m_angularVelocity;U.b2Assert(B.m_pointCount>
0);T.s_worldManifold.Initialize(B,p.m_xf,f,D.m_xf,m);b=T.s_worldManifold.m_normal.x;a=T.s_worldManifold.m_normal.y;l=this.m_constraints[h];l.bodyA=p;l.bodyB=D;l.manifold=B;l.normal.x=b;l.normal.y=a;l.pointCount=B.m_pointCount;l.friction=O;l.restitution=W;l.localPlaneNormal.x=B.m_localPlaneNormal.x;l.localPlaneNormal.y=B.m_localPlaneNormal.y;l.localPoint.x=B.m_localPoint.x;l.localPoint.y=B.m_localPoint.y;l.radius=f+m;l.type=B.m_type;for(f=0;f<l.pointCount;++f){O=B.m_points[f];m=l.points[f];m.normalImpulse=
O.m_normalImpulse;m.tangentImpulse=O.m_tangentImpulse;m.localPoint.SetV(O.m_localPoint);O=m.rA.x=T.s_worldManifold.m_points[f].x-p.m_sweep.c.x;W=m.rA.y=T.s_worldManifold.m_points[f].y-p.m_sweep.c.y;var v=m.rB.x=T.s_worldManifold.m_points[f].x-D.m_sweep.c.x,z=m.rB.y=T.s_worldManifold.m_points[f].y-D.m_sweep.c.y,u=O*a-W*b,w=v*a-z*b;u*=u;w*=w;m.normalMass=1/(p.m_invMass+D.m_invMass+p.m_invI*u+D.m_invI*w);var E=p.m_mass*p.m_invMass+D.m_mass*D.m_invMass;E+=p.m_mass*p.m_invI*u+D.m_mass*D.m_invI*w;m.equalizedMass=
1/E;w=a;E=-b;u=O*E-W*w;w=v*E-z*w;u*=u;w*=w;m.tangentMass=1/(p.m_invMass+D.m_invMass+p.m_invI*u+D.m_invI*w);m.velocityBias=0;O=l.normal.x*(n+-t*z-ca- -r*W)+l.normal.y*(e+t*v-d-r*O);if(O<-U.b2_velocityThreshold)m.velocityBias+=-l.restitution*O}if(l.pointCount==2){e=l.points[0];n=l.points[1];B=p.m_invMass;p=p.m_invI;ca=D.m_invMass;D=D.m_invI;d=e.rA.x*a-e.rA.y*b;e=e.rB.x*a-e.rB.y*b;r=n.rA.x*a-n.rA.y*b;n=n.rB.x*a-n.rB.y*b;b=B+ca+p*d*d+D*e*e;a=B+ca+p*r*r+D*n*n;D=B+ca+p*d*r+D*e*n;if(b*b<100*(b*a-D*D)){l.K.col1.Set(b,
D);l.K.col2.Set(D,a);l.K.GetInverse(l.normalMass)}else l.pointCount=1}}};T.prototype.InitVelocityConstraints=function(h){for(var o=0;o<this.m_constraintCount;++o){var q=this.m_constraints[o],l=q.bodyA,a=q.bodyB,b=l.m_invMass,f=l.m_invI,m=a.m_invMass,p=a.m_invI,D=q.normal.x,B=q.normal.y,O=B,W=-D,ca=0,d=0;if(h.warmStarting){d=q.pointCount;for(ca=0;ca<d;++ca){var n=q.points[ca];n.normalImpulse*=h.dtRatio;n.tangentImpulse*=h.dtRatio;var e=n.normalImpulse*D+n.tangentImpulse*O,r=n.normalImpulse*B+n.tangentImpulse*
W;l.m_angularVelocity-=f*(n.rA.x*r-n.rA.y*e);l.m_linearVelocity.x-=b*e;l.m_linearVelocity.y-=b*r;a.m_angularVelocity+=p*(n.rB.x*r-n.rB.y*e);a.m_linearVelocity.x+=m*e;a.m_linearVelocity.y+=m*r}}else{d=q.pointCount;for(ca=0;ca<d;++ca){l=q.points[ca];l.normalImpulse=0;l.tangentImpulse=0}}}};T.prototype.SolveVelocityConstraints=function(){for(var h=0,o,q=0,l=0,a=0,b=l=l=q=q=0,f=q=q=0,m=q=a=0,p=0,D,B=0;B<this.m_constraintCount;++B){a=this.m_constraints[B];var O=a.bodyA,W=a.bodyB,ca=O.m_angularVelocity,
d=W.m_angularVelocity,n=O.m_linearVelocity,e=W.m_linearVelocity,r=O.m_invMass,t=O.m_invI,v=W.m_invMass,z=W.m_invI;m=a.normal.x;var u=p=a.normal.y;D=-m;f=a.friction;for(h=0;h<a.pointCount;h++){o=a.points[h];q=e.x-d*o.rB.y-n.x+ca*o.rA.y;l=e.y+d*o.rB.x-n.y-ca*o.rA.x;q=q*u+l*D;q=o.tangentMass*-q;l=f*o.normalImpulse;l=ba.Clamp(o.tangentImpulse+q,-l,l);q=l-o.tangentImpulse;b=q*u;q=q*D;n.x-=r*b;n.y-=r*q;ca-=t*(o.rA.x*q-o.rA.y*b);e.x+=v*b;e.y+=v*q;d+=z*(o.rB.x*q-o.rB.y*b);o.tangentImpulse=l}parseInt(a.pointCount);
if(a.pointCount==1){o=a.points[0];q=e.x+-d*o.rB.y-n.x- -ca*o.rA.y;l=e.y+d*o.rB.x-n.y-ca*o.rA.x;a=q*m+l*p;q=-o.normalMass*(a-o.velocityBias);l=o.normalImpulse+q;l=l>0?l:0;q=l-o.normalImpulse;b=q*m;q=q*p;n.x-=r*b;n.y-=r*q;ca-=t*(o.rA.x*q-o.rA.y*b);e.x+=v*b;e.y+=v*q;d+=z*(o.rB.x*q-o.rB.y*b);o.normalImpulse=l}else{o=a.points[0];h=a.points[1];q=o.normalImpulse;f=h.normalImpulse;var w=(e.x-d*o.rB.y-n.x+ca*o.rA.y)*m+(e.y+d*o.rB.x-n.y-ca*o.rA.x)*p,E=(e.x-d*h.rB.y-n.x+ca*h.rA.y)*m+(e.y+d*h.rB.x-n.y-ca*h.rA.x)*
p;l=w-o.velocityBias;b=E-h.velocityBias;D=a.K;l-=D.col1.x*q+D.col2.x*f;for(b-=D.col1.y*q+D.col2.y*f;;){D=a.normalMass;u=-(D.col1.x*l+D.col2.x*b);D=-(D.col1.y*l+D.col2.y*b);if(u>=0&&D>=0){q=u-q;f=D-f;a=q*m;q=q*p;m=f*m;p=f*p;n.x-=r*(a+m);n.y-=r*(q+p);ca-=t*(o.rA.x*q-o.rA.y*a+h.rA.x*p-h.rA.y*m);e.x+=v*(a+m);e.y+=v*(q+p);d+=z*(o.rB.x*q-o.rB.y*a+h.rB.x*p-h.rB.y*m);o.normalImpulse=u;h.normalImpulse=D;break}u=-o.normalMass*l;D=0;E=a.K.col1.y*u+b;if(u>=0&&E>=0){q=u-q;f=D-f;a=q*m;q=q*p;m=f*m;p=f*p;n.x-=r*
(a+m);n.y-=r*(q+p);ca-=t*(o.rA.x*q-o.rA.y*a+h.rA.x*p-h.rA.y*m);e.x+=v*(a+m);e.y+=v*(q+p);d+=z*(o.rB.x*q-o.rB.y*a+h.rB.x*p-h.rB.y*m);o.normalImpulse=u;h.normalImpulse=D;break}u=0;D=-h.normalMass*b;w=a.K.col2.x*D+l;if(D>=0&&w>=0){q=u-q;f=D-f;a=q*m;q=q*p;m=f*m;p=f*p;n.x-=r*(a+m);n.y-=r*(q+p);ca-=t*(o.rA.x*q-o.rA.y*a+h.rA.x*p-h.rA.y*m);e.x+=v*(a+m);e.y+=v*(q+p);d+=z*(o.rB.x*q-o.rB.y*a+h.rB.x*p-h.rB.y*m);o.normalImpulse=u;h.normalImpulse=D;break}D=u=0;w=l;E=b;if(w>=0&&E>=0){q=u-q;f=D-f;a=q*m;q=q*p;m=f*
m;p=f*p;n.x-=r*(a+m);n.y-=r*(q+p);ca-=t*(o.rA.x*q-o.rA.y*a+h.rA.x*p-h.rA.y*m);e.x+=v*(a+m);e.y+=v*(q+p);d+=z*(o.rB.x*q-o.rB.y*a+h.rB.x*p-h.rB.y*m);o.normalImpulse=u;h.normalImpulse=D;break}break}}O.m_angularVelocity=ca;W.m_angularVelocity=d}};T.prototype.FinalizeVelocityConstraints=function(){for(var h=0;h<this.m_constraintCount;++h)for(var o=this.m_constraints[h],q=o.manifold,l=0;l<o.pointCount;++l){var a=q.m_points[l],b=o.points[l];a.m_normalImpulse=b.normalImpulse;a.m_tangentImpulse=b.tangentImpulse}};
T.prototype.SolvePositionConstraints=function(h){if(h===undefined)h=0;for(var o=0,q=0;q<this.m_constraintCount;q++){var l=this.m_constraints[q],a=l.bodyA,b=l.bodyB,f=a.m_mass*a.m_invMass,m=a.m_mass*a.m_invI,p=b.m_mass*b.m_invMass,D=b.m_mass*b.m_invI;T.s_psm.Initialize(l);for(var B=T.s_psm.m_normal,O=0;O<l.pointCount;O++){var W=l.points[O],ca=T.s_psm.m_points[O],d=T.s_psm.m_separations[O],n=ca.x-a.m_sweep.c.x,e=ca.y-a.m_sweep.c.y,r=ca.x-b.m_sweep.c.x;ca=ca.y-b.m_sweep.c.y;o=o<d?o:d;d=ba.Clamp(h*(d+
U.b2_linearSlop),-U.b2_maxLinearCorrection,0);d=-W.equalizedMass*d;W=d*B.x;d=d*B.y;a.m_sweep.c.x-=f*W;a.m_sweep.c.y-=f*d;a.m_sweep.a-=m*(n*d-e*W);a.SynchronizeTransform();b.m_sweep.c.x+=p*W;b.m_sweep.c.y+=p*d;b.m_sweep.a+=D*(r*d-ca*W);b.SynchronizeTransform()}}return o>-1.5*U.b2_linearSlop};_A2J_postDefs.push(function(){Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold=new k;Box2D.Dynamics.Contacts.b2ContactSolver.prototype.s_worldManifold=Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold;
Box2D.Dynamics.Contacts.b2ContactSolver.s_psm=new x;Box2D.Dynamics.Contacts.b2ContactSolver.prototype.s_psm=Box2D.Dynamics.Contacts.b2ContactSolver.s_psm});Q.inherit(Box2D.Dynamics.Contacts.b2Contact);Q.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;Q.b2EdgeAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};Q.prototype.Create=function(){return new Q};Q.Create=Q.prototype.Create;Q.prototype.Destroy=function(){};Q.Destroy=Q.prototype.Destroy;
Q.prototype.Reset=function(h,o){this.__super.Reset.call(this,h,o)};Q.prototype.Evaluate=function(){var h=this.m_fixtureA.GetBody(),o=this.m_fixtureB.GetBody();this.b2CollideEdgeAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof I?this.m_fixtureA.GetShape():null,h.m_xf,this.m_fixtureB.GetShape()instanceof L?this.m_fixtureB.GetShape():null,o.m_xf)};Q.prototype.b2CollideEdgeAndCircle=function(){};X.inherit(Box2D.Dynamics.Contacts.b2Contact);X.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;
X.b2NullContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};X.prototype.b2NullContact=function(){this.__super.b2Contact.call(this)};X.prototype.Evaluate=function(){};da.inherit(Box2D.Dynamics.Contacts.b2Contact);da.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;da.b2PolyAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};da.prototype.Create=function(){return new da};da.Create=da.prototype.Create;da.prototype.Destroy=
function(){};da.Destroy=da.prototype.Destroy;da.prototype.Reset=function(h,o){this.__super.Reset.call(this,h,o);U.b2Assert(h.GetType()==F.e_polygonShape);U.b2Assert(o.GetType()==F.e_circleShape)};da.prototype.Evaluate=function(){var h=this.m_fixtureA.m_body,o=this.m_fixtureB.m_body;Z.CollidePolygonAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof H?this.m_fixtureA.GetShape():null,h.m_xf,this.m_fixtureB.GetShape()instanceof L?this.m_fixtureB.GetShape():null,o.m_xf)};j.inherit(Box2D.Dynamics.Contacts.b2Contact);
j.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;j.b2PolyAndEdgeContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};j.prototype.Create=function(){return new j};j.Create=j.prototype.Create;j.prototype.Destroy=function(){};j.Destroy=j.prototype.Destroy;j.prototype.Reset=function(h,o){this.__super.Reset.call(this,h,o);U.b2Assert(h.GetType()==F.e_polygonShape);U.b2Assert(o.GetType()==F.e_edgeShape)};j.prototype.Evaluate=function(){var h=this.m_fixtureA.GetBody(),
o=this.m_fixtureB.GetBody();this.b2CollidePolyAndEdge(this.m_manifold,this.m_fixtureA.GetShape()instanceof H?this.m_fixtureA.GetShape():null,h.m_xf,this.m_fixtureB.GetShape()instanceof I?this.m_fixtureB.GetShape():null,o.m_xf)};j.prototype.b2CollidePolyAndEdge=function(){};y.inherit(Box2D.Dynamics.Contacts.b2Contact);y.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;y.b2PolygonContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};y.prototype.Create=function(){return new y};
y.Create=y.prototype.Create;y.prototype.Destroy=function(){};y.Destroy=y.prototype.Destroy;y.prototype.Reset=function(h,o){this.__super.Reset.call(this,h,o)};y.prototype.Evaluate=function(){var h=this.m_fixtureA.GetBody(),o=this.m_fixtureB.GetBody();Z.CollidePolygons(this.m_manifold,this.m_fixtureA.GetShape()instanceof H?this.m_fixtureA.GetShape():null,h.m_xf,this.m_fixtureB.GetShape()instanceof H?this.m_fixtureB.GetShape():null,o.m_xf)};x.b2PositionSolverManifold=function(){};x.prototype.b2PositionSolverManifold=
function(){this.m_normal=new V;this.m_separations=new Vector_a2j_Number(U.b2_maxManifoldPoints);this.m_points=new Vector(U.b2_maxManifoldPoints);for(var h=0;h<U.b2_maxManifoldPoints;h++)this.m_points[h]=new V};x.prototype.Initialize=function(h){U.b2Assert(h.pointCount>0);var o=0,q=0,l=0,a,b=0,f=0;switch(h.type){case fa.e_circles:a=h.bodyA.m_xf.R;l=h.localPoint;o=h.bodyA.m_xf.position.x+(a.col1.x*l.x+a.col2.x*l.y);q=h.bodyA.m_xf.position.y+(a.col1.y*l.x+a.col2.y*l.y);a=h.bodyB.m_xf.R;l=h.points[0].localPoint;
b=h.bodyB.m_xf.position.x+(a.col1.x*l.x+a.col2.x*l.y);a=h.bodyB.m_xf.position.y+(a.col1.y*l.x+a.col2.y*l.y);l=b-o;f=a-q;var m=l*l+f*f;if(m>Number.MIN_VALUE*Number.MIN_VALUE){m=Math.sqrt(m);this.m_normal.x=l/m;this.m_normal.y=f/m}else{this.m_normal.x=1;this.m_normal.y=0}this.m_points[0].x=0.5*(o+b);this.m_points[0].y=0.5*(q+a);this.m_separations[0]=l*this.m_normal.x+f*this.m_normal.y-h.radius;break;case fa.e_faceA:a=h.bodyA.m_xf.R;l=h.localPlaneNormal;this.m_normal.x=a.col1.x*l.x+a.col2.x*l.y;this.m_normal.y=
a.col1.y*l.x+a.col2.y*l.y;a=h.bodyA.m_xf.R;l=h.localPoint;b=h.bodyA.m_xf.position.x+(a.col1.x*l.x+a.col2.x*l.y);f=h.bodyA.m_xf.position.y+(a.col1.y*l.x+a.col2.y*l.y);a=h.bodyB.m_xf.R;for(o=0;o<h.pointCount;++o){l=h.points[o].localPoint;q=h.bodyB.m_xf.position.x+(a.col1.x*l.x+a.col2.x*l.y);l=h.bodyB.m_xf.position.y+(a.col1.y*l.x+a.col2.y*l.y);this.m_separations[o]=(q-b)*this.m_normal.x+(l-f)*this.m_normal.y-h.radius;this.m_points[o].x=q;this.m_points[o].y=l}break;case fa.e_faceB:a=h.bodyB.m_xf.R;l=
h.localPlaneNormal;this.m_normal.x=a.col1.x*l.x+a.col2.x*l.y;this.m_normal.y=a.col1.y*l.x+a.col2.y*l.y;a=h.bodyB.m_xf.R;l=h.localPoint;b=h.bodyB.m_xf.position.x+(a.col1.x*l.x+a.col2.x*l.y);f=h.bodyB.m_xf.position.y+(a.col1.y*l.x+a.col2.y*l.y);a=h.bodyA.m_xf.R;for(o=0;o<h.pointCount;++o){l=h.points[o].localPoint;q=h.bodyA.m_xf.position.x+(a.col1.x*l.x+a.col2.x*l.y);l=h.bodyA.m_xf.position.y+(a.col1.y*l.x+a.col2.y*l.y);this.m_separations[o]=(q-b)*this.m_normal.x+(l-f)*this.m_normal.y-h.radius;this.m_points[o].Set(q,
l)}this.m_normal.x*=-1;this.m_normal.y*=-1}};_A2J_postDefs.push(function(){Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointA=new V;Box2D.Dynamics.Contacts.b2PositionSolverManifold.prototype.circlePointA=Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointA;Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointB=new V;Box2D.Dynamics.Contacts.b2PositionSolverManifold.prototype.circlePointB=Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointB})})();
(function(){var L=Box2D.Common.Math.b2Mat22,I=Box2D.Common.Math.b2Math,H=Box2D.Common.Math.b2Vec2,F=Box2D.Common.b2Color,G=Box2D.Dynamics.Controllers.b2BuoyancyController,A=Box2D.Dynamics.Controllers.b2ConstantAccelController,N=Box2D.Dynamics.Controllers.b2ConstantForceController,s=Box2D.Dynamics.Controllers.b2Controller,C=Box2D.Dynamics.Controllers.b2ControllerEdge,R=Box2D.Dynamics.Controllers.b2GravityController,aa=Box2D.Dynamics.Controllers.b2TensorDampingController;G.inherit(Box2D.Dynamics.Controllers.b2Controller);
G.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;G.b2BuoyancyController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.normal=new H(0,-1);this.density=this.offset=0;this.velocity=new H(0,0);this.linearDrag=2;this.angularDrag=1;this.useDensity=false;this.useWorldGravity=true;this.gravity=null};G.prototype.Step=function(){if(this.m_bodyList){if(this.useWorldGravity)this.gravity=this.GetWorld().GetGravity().Copy();for(var $=this.m_bodyList;$;$=
$.nextBody){var T=$.body;if(T.IsAwake()!=false){for(var Q=new H,X=new H,da=0,j=0,y=T.GetFixtureList();y;y=y.GetNext()){var x=new H,J=y.GetShape().ComputeSubmergedArea(this.normal,this.offset,T.GetTransform(),x);da+=J;Q.x+=J*x.x;Q.y+=J*x.y;var M=0;M=1;j+=J*M;X.x+=J*x.x*M;X.y+=J*x.y*M}Q.x/=da;Q.y/=da;X.x/=j;X.y/=j;if(!(da<Number.MIN_VALUE)){j=this.gravity.GetNegative();j.Multiply(this.density*da);T.ApplyForce(j,X);X=T.GetLinearVelocityFromWorldPoint(Q);X.Subtract(this.velocity);X.Multiply(-this.linearDrag*
da);T.ApplyForce(X,Q);T.ApplyTorque(-T.GetInertia()/T.GetMass()*da*T.GetAngularVelocity()*this.angularDrag)}}}}};G.prototype.Draw=function($){var T=new H,Q=new H;T.x=this.normal.x*this.offset+this.normal.y*1E3;T.y=this.normal.y*this.offset-this.normal.x*1E3;Q.x=this.normal.x*this.offset-this.normal.y*1E3;Q.y=this.normal.y*this.offset+this.normal.x*1E3;var X=new F(0,0,1);$.DrawSegment(T,Q,X)};A.inherit(Box2D.Dynamics.Controllers.b2Controller);A.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;
A.b2ConstantAccelController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.A=new H(0,0)};A.prototype.Step=function($){$=new H(this.A.x*$.dt,this.A.y*$.dt);for(var T=this.m_bodyList;T;T=T.nextBody){var Q=T.body;Q.IsAwake()&&Q.SetLinearVelocity(new H(Q.GetLinearVelocity().x+$.x,Q.GetLinearVelocity().y+$.y))}};N.inherit(Box2D.Dynamics.Controllers.b2Controller);N.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;N.b2ConstantForceController=
function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.F=new H(0,0)};N.prototype.Step=function(){for(var $=this.m_bodyList;$;$=$.nextBody){var T=$.body;T.IsAwake()&&T.ApplyForce(this.F,T.GetWorldCenter())}};s.b2Controller=function(){};s.prototype.Step=function(){};s.prototype.Draw=function(){};s.prototype.AddBody=function($){var T=new C;T.controller=this;T.body=$;T.nextBody=this.m_bodyList;T.prevBody=null;this.m_bodyList=T;if(T.nextBody)T.nextBody.prevBody=T;this.m_bodyCount++;
T.nextController=$.m_controllerList;T.prevController=null;$.m_controllerList=T;if(T.nextController)T.nextController.prevController=T;$.m_controllerCount++};s.prototype.RemoveBody=function($){for(var T=$.m_controllerList;T&&T.controller!=this;)T=T.nextController;if(T.prevBody)T.prevBody.nextBody=T.nextBody;if(T.nextBody)T.nextBody.prevBody=T.prevBody;if(T.nextController)T.nextController.prevController=T.prevController;if(T.prevController)T.prevController.nextController=T.nextController;if(this.m_bodyList==
T)this.m_bodyList=T.nextBody;if($.m_controllerList==T)$.m_controllerList=T.nextController;$.m_controllerCount--;this.m_bodyCount--};s.prototype.Clear=function(){for(;this.m_bodyList;)this.RemoveBody(this.m_bodyList.body)};s.prototype.GetNext=function(){return this.m_next};s.prototype.GetWorld=function(){return this.m_world};s.prototype.GetBodyList=function(){return this.m_bodyList};C.b2ControllerEdge=function(){};R.inherit(Box2D.Dynamics.Controllers.b2Controller);R.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;
R.b2GravityController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.G=1;this.invSqr=true};R.prototype.Step=function(){var $=null,T=null,Q=null,X=0,da=null,j=null,y=null,x=0,J=0,M=0;x=null;if(this.invSqr)for($=this.m_bodyList;$;$=$.nextBody){T=$.body;Q=T.GetWorldCenter();X=T.GetMass();for(da=this.m_bodyList;da!=$;da=da.nextBody){j=da.body;y=j.GetWorldCenter();x=y.x-Q.x;J=y.y-Q.y;M=x*x+J*J;if(!(M<Number.MIN_VALUE)){x=new H(x,J);x.Multiply(this.G/M/Math.sqrt(M)*
X*j.GetMass());T.IsAwake()&&T.ApplyForce(x,Q);x.Multiply(-1);j.IsAwake()&&j.ApplyForce(x,y)}}}else for($=this.m_bodyList;$;$=$.nextBody){T=$.body;Q=T.GetWorldCenter();X=T.GetMass();for(da=this.m_bodyList;da!=$;da=da.nextBody){j=da.body;y=j.GetWorldCenter();x=y.x-Q.x;J=y.y-Q.y;M=x*x+J*J;if(!(M<Number.MIN_VALUE)){x=new H(x,J);x.Multiply(this.G/M*X*j.GetMass());T.IsAwake()&&T.ApplyForce(x,Q);x.Multiply(-1);j.IsAwake()&&j.ApplyForce(x,y)}}}};aa.inherit(Box2D.Dynamics.Controllers.b2Controller);aa.prototype.__super=
Box2D.Dynamics.Controllers.b2Controller.prototype;aa.b2TensorDampingController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.T=new L;this.maxTimestep=0};aa.prototype.SetAxisAligned=function($,T){if($===undefined)$=0;if(T===undefined)T=0;this.T.col1.x=-$;this.T.col1.y=0;this.T.col2.x=0;this.T.col2.y=-T;this.maxTimestep=$>0||T>0?1/Math.max($,T):0};aa.prototype.Step=function($){$=$.dt;if(!($<=Number.MIN_VALUE)){if($>this.maxTimestep&&this.maxTimestep>0)$=
this.maxTimestep;for(var T=this.m_bodyList;T;T=T.nextBody){var Q=T.body;if(Q.IsAwake()){var X=Q.GetWorldVector(I.MulMV(this.T,Q.GetLocalVector(Q.GetLinearVelocity())));Q.SetLinearVelocity(new H(Q.GetLinearVelocity().x+X.x*$,Q.GetLinearVelocity().y+X.y*$))}}}}})();
(function(){var L=Box2D.Common.b2Settings;L=Box2D.Common.b2Settings;var I=Box2D.Common.Math.b2Mat22,H=Box2D.Common.Math.b2Mat33,F=Box2D.Common.Math.b2Math,G=Box2D.Common.Math.b2Vec2,A=Box2D.Common.Math.b2Vec3,N=Box2D.Dynamics.Joints.b2DistanceJoint,s=Box2D.Dynamics.Joints.b2DistanceJointDef,C=Box2D.Dynamics.Joints.b2FrictionJoint,R=Box2D.Dynamics.Joints.b2FrictionJointDef,aa=Box2D.Dynamics.Joints.b2GearJoint,$=Box2D.Dynamics.Joints.b2GearJointDef,T=Box2D.Dynamics.Joints.b2Jacobian,Q=Box2D.Dynamics.Joints.b2Joint,
X=Box2D.Dynamics.Joints.b2JointDef,da=Box2D.Dynamics.Joints.b2JointEdge,j=Box2D.Dynamics.Joints.b2LineJoint,y=Box2D.Dynamics.Joints.b2LineJointDef,x=Box2D.Dynamics.Joints.b2MouseJoint,J=Box2D.Dynamics.Joints.b2MouseJointDef,M=Box2D.Dynamics.Joints.b2PrismaticJoint,U=Box2D.Dynamics.Joints.b2PrismaticJointDef,K=Box2D.Dynamics.Joints.b2PulleyJoint,ba=Box2D.Dynamics.Joints.b2PulleyJointDef,V=Box2D.Dynamics.Joints.b2RevoluteJoint,Z=Box2D.Dynamics.Joints.b2RevoluteJointDef,ga=Box2D.Dynamics.Joints.b2WeldJoint,
fa=Box2D.Dynamics.Joints.b2WeldJointDef;N=Box2D.Dynamics.Joints.b2DistanceJoint;s=Box2D.Dynamics.Joints.b2DistanceJointDef;C=Box2D.Dynamics.Joints.b2FrictionJoint;R=Box2D.Dynamics.Joints.b2FrictionJointDef;aa=Box2D.Dynamics.Joints.b2GearJoint;$=Box2D.Dynamics.Joints.b2GearJointDef;T=Box2D.Dynamics.Joints.b2Jacobian;Q=Box2D.Dynamics.Joints.b2Joint;X=Box2D.Dynamics.Joints.b2JointDef;da=Box2D.Dynamics.Joints.b2JointEdge;j=Box2D.Dynamics.Joints.b2LineJoint;y=Box2D.Dynamics.Joints.b2LineJointDef;x=Box2D.Dynamics.Joints.b2MouseJoint;
J=Box2D.Dynamics.Joints.b2MouseJointDef;M=Box2D.Dynamics.Joints.b2PrismaticJoint;U=Box2D.Dynamics.Joints.b2PrismaticJointDef;K=Box2D.Dynamics.Joints.b2PulleyJoint;ba=Box2D.Dynamics.Joints.b2PulleyJointDef;V=Box2D.Dynamics.Joints.b2RevoluteJoint;Z=Box2D.Dynamics.Joints.b2RevoluteJointDef;ga=Box2D.Dynamics.Joints.b2WeldJoint;fa=Box2D.Dynamics.Joints.b2WeldJointDef;N.inherit(Box2D.Dynamics.Joints.b2Joint);N.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;N.b2DistanceJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,
arguments);this.m_localAnchor1=new G;this.m_localAnchor2=new G;this.m_u=new G};N.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};N.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};N.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*this.m_impulse*this.m_u.x,c*this.m_impulse*this.m_u.y)};N.prototype.GetReactionTorque=function(){return 0};N.prototype.GetLength=function(){return this.m_length};N.prototype.SetLength=
function(c){if(c===undefined)c=0;this.m_length=c};N.prototype.GetFrequency=function(){return this.m_frequencyHz};N.prototype.SetFrequency=function(c){if(c===undefined)c=0;this.m_frequencyHz=c};N.prototype.GetDampingRatio=function(){return this.m_dampingRatio};N.prototype.SetDampingRatio=function(c){if(c===undefined)c=0;this.m_dampingRatio=c};N.prototype.b2DistanceJoint=function(c){this.__super.b2Joint.call(this,c);this.m_localAnchor1.SetV(c.localAnchorA);this.m_localAnchor2.SetV(c.localAnchorB);this.m_length=
c.length;this.m_frequencyHz=c.frequencyHz;this.m_dampingRatio=c.dampingRatio;this.m_bias=this.m_gamma=this.m_impulse=0};N.prototype.InitVelocityConstraints=function(c){var g,k=0,h=this.m_bodyA,o=this.m_bodyB;g=h.m_xf.R;var q=this.m_localAnchor1.x-h.m_sweep.localCenter.x,l=this.m_localAnchor1.y-h.m_sweep.localCenter.y;k=g.col1.x*q+g.col2.x*l;l=g.col1.y*q+g.col2.y*l;q=k;g=o.m_xf.R;var a=this.m_localAnchor2.x-o.m_sweep.localCenter.x,b=this.m_localAnchor2.y-o.m_sweep.localCenter.y;k=g.col1.x*a+g.col2.x*
b;b=g.col1.y*a+g.col2.y*b;a=k;this.m_u.x=o.m_sweep.c.x+a-h.m_sweep.c.x-q;this.m_u.y=o.m_sweep.c.y+b-h.m_sweep.c.y-l;k=Math.sqrt(this.m_u.x*this.m_u.x+this.m_u.y*this.m_u.y);k>L.b2_linearSlop?this.m_u.Multiply(1/k):this.m_u.SetZero();g=q*this.m_u.y-l*this.m_u.x;var f=a*this.m_u.y-b*this.m_u.x;g=h.m_invMass+h.m_invI*g*g+o.m_invMass+o.m_invI*f*f;this.m_mass=g!=0?1/g:0;if(this.m_frequencyHz>0){k=k-this.m_length;f=2*Math.PI*this.m_frequencyHz;var m=this.m_mass*f*f;this.m_gamma=c.dt*(2*this.m_mass*this.m_dampingRatio*
f+c.dt*m);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=k*c.dt*m*this.m_gamma;this.m_mass=g+this.m_gamma;this.m_mass=this.m_mass!=0?1/this.m_mass:0}if(c.warmStarting){this.m_impulse*=c.dtRatio;c=this.m_impulse*this.m_u.x;g=this.m_impulse*this.m_u.y;h.m_linearVelocity.x-=h.m_invMass*c;h.m_linearVelocity.y-=h.m_invMass*g;h.m_angularVelocity-=h.m_invI*(q*g-l*c);o.m_linearVelocity.x+=o.m_invMass*c;o.m_linearVelocity.y+=o.m_invMass*g;o.m_angularVelocity+=o.m_invI*(a*g-b*c)}else this.m_impulse=
0};N.prototype.SolveVelocityConstraints=function(){var c,g=this.m_bodyA,k=this.m_bodyB;c=g.m_xf.R;var h=this.m_localAnchor1.x-g.m_sweep.localCenter.x,o=this.m_localAnchor1.y-g.m_sweep.localCenter.y,q=c.col1.x*h+c.col2.x*o;o=c.col1.y*h+c.col2.y*o;h=q;c=k.m_xf.R;var l=this.m_localAnchor2.x-k.m_sweep.localCenter.x,a=this.m_localAnchor2.y-k.m_sweep.localCenter.y;q=c.col1.x*l+c.col2.x*a;a=c.col1.y*l+c.col2.y*a;l=q;q=-this.m_mass*(this.m_u.x*(k.m_linearVelocity.x+-k.m_angularVelocity*a-(g.m_linearVelocity.x+
-g.m_angularVelocity*o))+this.m_u.y*(k.m_linearVelocity.y+k.m_angularVelocity*l-(g.m_linearVelocity.y+g.m_angularVelocity*h))+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=q;c=q*this.m_u.x;q=q*this.m_u.y;g.m_linearVelocity.x-=g.m_invMass*c;g.m_linearVelocity.y-=g.m_invMass*q;g.m_angularVelocity-=g.m_invI*(h*q-o*c);k.m_linearVelocity.x+=k.m_invMass*c;k.m_linearVelocity.y+=k.m_invMass*q;k.m_angularVelocity+=k.m_invI*(l*q-a*c)};N.prototype.SolvePositionConstraints=function(){var c;if(this.m_frequencyHz>
0)return true;var g=this.m_bodyA,k=this.m_bodyB;c=g.m_xf.R;var h=this.m_localAnchor1.x-g.m_sweep.localCenter.x,o=this.m_localAnchor1.y-g.m_sweep.localCenter.y,q=c.col1.x*h+c.col2.x*o;o=c.col1.y*h+c.col2.y*o;h=q;c=k.m_xf.R;var l=this.m_localAnchor2.x-k.m_sweep.localCenter.x,a=this.m_localAnchor2.y-k.m_sweep.localCenter.y;q=c.col1.x*l+c.col2.x*a;a=c.col1.y*l+c.col2.y*a;l=q;q=k.m_sweep.c.x+l-g.m_sweep.c.x-h;var b=k.m_sweep.c.y+a-g.m_sweep.c.y-o;c=Math.sqrt(q*q+b*b);q/=c;b/=c;c=c-this.m_length;c=F.Clamp(c,
-L.b2_maxLinearCorrection,L.b2_maxLinearCorrection);var f=-this.m_mass*c;this.m_u.Set(q,b);q=f*this.m_u.x;b=f*this.m_u.y;g.m_sweep.c.x-=g.m_invMass*q;g.m_sweep.c.y-=g.m_invMass*b;g.m_sweep.a-=g.m_invI*(h*b-o*q);k.m_sweep.c.x+=k.m_invMass*q;k.m_sweep.c.y+=k.m_invMass*b;k.m_sweep.a+=k.m_invI*(l*b-a*q);g.SynchronizeTransform();k.SynchronizeTransform();return F.Abs(c)<L.b2_linearSlop};s.inherit(Box2D.Dynamics.Joints.b2JointDef);s.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;s.b2DistanceJointDef=
function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new G;this.localAnchorB=new G};s.prototype.b2DistanceJointDef=function(){this.__super.b2JointDef.call(this);this.type=Q.e_distanceJoint;this.length=1;this.dampingRatio=this.frequencyHz=0};s.prototype.Initialize=function(c,g,k,h){this.bodyA=c;this.bodyB=g;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(k));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(h));c=h.x-k.x;k=h.y-k.y;this.length=Math.sqrt(c*c+k*
k);this.dampingRatio=this.frequencyHz=0};C.inherit(Box2D.Dynamics.Joints.b2Joint);C.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;C.b2FrictionJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchorA=new G;this.m_localAnchorB=new G;this.m_linearMass=new I;this.m_linearImpulse=new G};C.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};C.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};
C.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*this.m_linearImpulse.x,c*this.m_linearImpulse.y)};C.prototype.GetReactionTorque=function(c){if(c===undefined)c=0;return c*this.m_angularImpulse};C.prototype.SetMaxForce=function(c){if(c===undefined)c=0;this.m_maxForce=c};C.prototype.GetMaxForce=function(){return this.m_maxForce};C.prototype.SetMaxTorque=function(c){if(c===undefined)c=0;this.m_maxTorque=c};C.prototype.GetMaxTorque=function(){return this.m_maxTorque};C.prototype.b2FrictionJoint=
function(c){this.__super.b2Joint.call(this,c);this.m_localAnchorA.SetV(c.localAnchorA);this.m_localAnchorB.SetV(c.localAnchorB);this.m_linearMass.SetZero();this.m_angularMass=0;this.m_linearImpulse.SetZero();this.m_angularImpulse=0;this.m_maxForce=c.maxForce;this.m_maxTorque=c.maxTorque};C.prototype.InitVelocityConstraints=function(c){var g,k=0,h=this.m_bodyA,o=this.m_bodyB;g=h.m_xf.R;var q=this.m_localAnchorA.x-h.m_sweep.localCenter.x,l=this.m_localAnchorA.y-h.m_sweep.localCenter.y;k=g.col1.x*q+
g.col2.x*l;l=g.col1.y*q+g.col2.y*l;q=k;g=o.m_xf.R;var a=this.m_localAnchorB.x-o.m_sweep.localCenter.x,b=this.m_localAnchorB.y-o.m_sweep.localCenter.y;k=g.col1.x*a+g.col2.x*b;b=g.col1.y*a+g.col2.y*b;a=k;g=h.m_invMass;k=o.m_invMass;var f=h.m_invI,m=o.m_invI,p=new I;p.col1.x=g+k;p.col2.x=0;p.col1.y=0;p.col2.y=g+k;p.col1.x+=f*l*l;p.col2.x+=-f*q*l;p.col1.y+=-f*q*l;p.col2.y+=f*q*q;p.col1.x+=m*b*b;p.col2.x+=-m*a*b;p.col1.y+=-m*a*b;p.col2.y+=m*a*a;p.GetInverse(this.m_linearMass);this.m_angularMass=f+m;if(this.m_angularMass>
0)this.m_angularMass=1/this.m_angularMass;if(c.warmStarting){this.m_linearImpulse.x*=c.dtRatio;this.m_linearImpulse.y*=c.dtRatio;this.m_angularImpulse*=c.dtRatio;c=this.m_linearImpulse;h.m_linearVelocity.x-=g*c.x;h.m_linearVelocity.y-=g*c.y;h.m_angularVelocity-=f*(q*c.y-l*c.x+this.m_angularImpulse);o.m_linearVelocity.x+=k*c.x;o.m_linearVelocity.y+=k*c.y;o.m_angularVelocity+=m*(a*c.y-b*c.x+this.m_angularImpulse)}else{this.m_linearImpulse.SetZero();this.m_angularImpulse=0}};C.prototype.SolveVelocityConstraints=
function(c){var g,k=0,h=this.m_bodyA,o=this.m_bodyB,q=h.m_linearVelocity,l=h.m_angularVelocity,a=o.m_linearVelocity,b=o.m_angularVelocity,f=h.m_invMass,m=o.m_invMass,p=h.m_invI,D=o.m_invI;g=h.m_xf.R;var B=this.m_localAnchorA.x-h.m_sweep.localCenter.x,O=this.m_localAnchorA.y-h.m_sweep.localCenter.y;k=g.col1.x*B+g.col2.x*O;O=g.col1.y*B+g.col2.y*O;B=k;g=o.m_xf.R;var W=this.m_localAnchorB.x-o.m_sweep.localCenter.x,ca=this.m_localAnchorB.y-o.m_sweep.localCenter.y;k=g.col1.x*W+g.col2.x*ca;ca=g.col1.y*W+
g.col2.y*ca;W=k;g=0;k=-this.m_angularMass*(b-l);var d=this.m_angularImpulse;g=c.dt*this.m_maxTorque;this.m_angularImpulse=F.Clamp(this.m_angularImpulse+k,-g,g);k=this.m_angularImpulse-d;l-=p*k;b+=D*k;g=F.MulMV(this.m_linearMass,new G(-(a.x-b*ca-q.x+l*O),-(a.y+b*W-q.y-l*B)));k=this.m_linearImpulse.Copy();this.m_linearImpulse.Add(g);g=c.dt*this.m_maxForce;if(this.m_linearImpulse.LengthSquared()>g*g){this.m_linearImpulse.Normalize();this.m_linearImpulse.Multiply(g)}g=F.SubtractVV(this.m_linearImpulse,
k);q.x-=f*g.x;q.y-=f*g.y;l-=p*(B*g.y-O*g.x);a.x+=m*g.x;a.y+=m*g.y;b+=D*(W*g.y-ca*g.x);h.m_angularVelocity=l;o.m_angularVelocity=b};C.prototype.SolvePositionConstraints=function(){return true};R.inherit(Box2D.Dynamics.Joints.b2JointDef);R.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;R.b2FrictionJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new G;this.localAnchorB=new G};R.prototype.b2FrictionJointDef=function(){this.__super.b2JointDef.call(this);
this.type=Q.e_frictionJoint;this.maxTorque=this.maxForce=0};R.prototype.Initialize=function(c,g,k){this.bodyA=c;this.bodyB=g;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(k));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(k))};aa.inherit(Box2D.Dynamics.Joints.b2Joint);aa.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;aa.b2GearJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_groundAnchor1=new G;this.m_groundAnchor2=new G;this.m_localAnchor1=new G;this.m_localAnchor2=
new G;this.m_J=new T};aa.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};aa.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};aa.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*this.m_impulse*this.m_J.linearB.x,c*this.m_impulse*this.m_J.linearB.y)};aa.prototype.GetReactionTorque=function(c){if(c===undefined)c=0;var g=this.m_bodyB.m_xf.R,k=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,
h=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,o=g.col1.x*k+g.col2.x*h;h=g.col1.y*k+g.col2.y*h;k=o;return c*(this.m_impulse*this.m_J.angularB-k*this.m_impulse*this.m_J.linearB.y+h*this.m_impulse*this.m_J.linearB.x)};aa.prototype.GetRatio=function(){return this.m_ratio};aa.prototype.SetRatio=function(c){if(c===undefined)c=0;this.m_ratio=c};aa.prototype.b2GearJoint=function(c){this.__super.b2Joint.call(this,c);var g=parseInt(c.joint1.m_type),k=parseInt(c.joint2.m_type);this.m_prismatic2=
this.m_revolute2=this.m_prismatic1=this.m_revolute1=null;var h=0,o=0;this.m_ground1=c.joint1.GetBodyA();this.m_bodyA=c.joint1.GetBodyB();if(g==Q.e_revoluteJoint){this.m_revolute1=c.joint1 instanceof V?c.joint1:null;this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1);this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2);h=this.m_revolute1.GetJointAngle()}else{this.m_prismatic1=c.joint1 instanceof M?c.joint1:null;this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1);this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2);
h=this.m_prismatic1.GetJointTranslation()}this.m_ground2=c.joint2.GetBodyA();this.m_bodyB=c.joint2.GetBodyB();if(k==Q.e_revoluteJoint){this.m_revolute2=c.joint2 instanceof V?c.joint2:null;this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1);this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2);o=this.m_revolute2.GetJointAngle()}else{this.m_prismatic2=c.joint2 instanceof M?c.joint2:null;this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1);this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2);
o=this.m_prismatic2.GetJointTranslation()}this.m_ratio=c.ratio;this.m_constant=h+this.m_ratio*o;this.m_impulse=0};aa.prototype.InitVelocityConstraints=function(c){var g=this.m_ground1,k=this.m_ground2,h=this.m_bodyA,o=this.m_bodyB,q=0,l=0,a=0,b=0,f=a=0,m=0;this.m_J.SetZero();if(this.m_revolute1){this.m_J.angularA=-1;m+=h.m_invI}else{g=g.m_xf.R;l=this.m_prismatic1.m_localXAxis1;q=g.col1.x*l.x+g.col2.x*l.y;l=g.col1.y*l.x+g.col2.y*l.y;g=h.m_xf.R;a=this.m_localAnchor1.x-h.m_sweep.localCenter.x;b=this.m_localAnchor1.y-
h.m_sweep.localCenter.y;f=g.col1.x*a+g.col2.x*b;b=g.col1.y*a+g.col2.y*b;a=f;a=a*l-b*q;this.m_J.linearA.Set(-q,-l);this.m_J.angularA=-a;m+=h.m_invMass+h.m_invI*a*a}if(this.m_revolute2){this.m_J.angularB=-this.m_ratio;m+=this.m_ratio*this.m_ratio*o.m_invI}else{g=k.m_xf.R;l=this.m_prismatic2.m_localXAxis1;q=g.col1.x*l.x+g.col2.x*l.y;l=g.col1.y*l.x+g.col2.y*l.y;g=o.m_xf.R;a=this.m_localAnchor2.x-o.m_sweep.localCenter.x;b=this.m_localAnchor2.y-o.m_sweep.localCenter.y;f=g.col1.x*a+g.col2.x*b;b=g.col1.y*
a+g.col2.y*b;a=f;a=a*l-b*q;this.m_J.linearB.Set(-this.m_ratio*q,-this.m_ratio*l);this.m_J.angularB=-this.m_ratio*a;m+=this.m_ratio*this.m_ratio*(o.m_invMass+o.m_invI*a*a)}this.m_mass=m>0?1/m:0;if(c.warmStarting){h.m_linearVelocity.x+=h.m_invMass*this.m_impulse*this.m_J.linearA.x;h.m_linearVelocity.y+=h.m_invMass*this.m_impulse*this.m_J.linearA.y;h.m_angularVelocity+=h.m_invI*this.m_impulse*this.m_J.angularA;o.m_linearVelocity.x+=o.m_invMass*this.m_impulse*this.m_J.linearB.x;o.m_linearVelocity.y+=
o.m_invMass*this.m_impulse*this.m_J.linearB.y;o.m_angularVelocity+=o.m_invI*this.m_impulse*this.m_J.angularB}else this.m_impulse=0};aa.prototype.SolveVelocityConstraints=function(){var c=this.m_bodyA,g=this.m_bodyB,k=-this.m_mass*this.m_J.Compute(c.m_linearVelocity,c.m_angularVelocity,g.m_linearVelocity,g.m_angularVelocity);this.m_impulse+=k;c.m_linearVelocity.x+=c.m_invMass*k*this.m_J.linearA.x;c.m_linearVelocity.y+=c.m_invMass*k*this.m_J.linearA.y;c.m_angularVelocity+=c.m_invI*k*this.m_J.angularA;
g.m_linearVelocity.x+=g.m_invMass*k*this.m_J.linearB.x;g.m_linearVelocity.y+=g.m_invMass*k*this.m_J.linearB.y;g.m_angularVelocity+=g.m_invI*k*this.m_J.angularB};aa.prototype.SolvePositionConstraints=function(){var c=this.m_bodyA,g=this.m_bodyB,k=0,h=0;k=this.m_revolute1?this.m_revolute1.GetJointAngle():this.m_prismatic1.GetJointTranslation();h=this.m_revolute2?this.m_revolute2.GetJointAngle():this.m_prismatic2.GetJointTranslation();k=-this.m_mass*(this.m_constant-(k+this.m_ratio*h));c.m_sweep.c.x+=
c.m_invMass*k*this.m_J.linearA.x;c.m_sweep.c.y+=c.m_invMass*k*this.m_J.linearA.y;c.m_sweep.a+=c.m_invI*k*this.m_J.angularA;g.m_sweep.c.x+=g.m_invMass*k*this.m_J.linearB.x;g.m_sweep.c.y+=g.m_invMass*k*this.m_J.linearB.y;g.m_sweep.a+=g.m_invI*k*this.m_J.angularB;c.SynchronizeTransform();g.SynchronizeTransform();return 0<L.b2_linearSlop};$.inherit(Box2D.Dynamics.Joints.b2JointDef);$.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;$.b2GearJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,
arguments)};$.prototype.b2GearJointDef=function(){this.__super.b2JointDef.call(this);this.type=Q.e_gearJoint;this.joint2=this.joint1=null;this.ratio=1};T.b2Jacobian=function(){this.linearA=new G;this.linearB=new G};T.prototype.SetZero=function(){this.linearA.SetZero();this.angularA=0;this.linearB.SetZero();this.angularB=0};T.prototype.Set=function(c,g,k,h){if(g===undefined)g=0;if(h===undefined)h=0;this.linearA.SetV(c);this.angularA=g;this.linearB.SetV(k);this.angularB=h};T.prototype.Compute=function(c,
g,k,h){if(g===undefined)g=0;if(h===undefined)h=0;return this.linearA.x*c.x+this.linearA.y*c.y+this.angularA*g+(this.linearB.x*k.x+this.linearB.y*k.y)+this.angularB*h};Q.b2Joint=function(){this.m_edgeA=new da;this.m_edgeB=new da;this.m_localCenterA=new G;this.m_localCenterB=new G};Q.prototype.GetType=function(){return this.m_type};Q.prototype.GetAnchorA=function(){return null};Q.prototype.GetAnchorB=function(){return null};Q.prototype.GetReactionForce=function(){return null};Q.prototype.GetReactionTorque=
function(){return 0};Q.prototype.GetBodyA=function(){return this.m_bodyA};Q.prototype.GetBodyB=function(){return this.m_bodyB};Q.prototype.GetNext=function(){return this.m_next};Q.prototype.GetUserData=function(){return this.m_userData};Q.prototype.SetUserData=function(c){this.m_userData=c};Q.prototype.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()};Q.prototype.Create=function(c){var g=null;switch(c.type){case Q.e_distanceJoint:g=new N(c instanceof s?c:null);break;case Q.e_mouseJoint:g=
new x(c instanceof J?c:null);break;case Q.e_prismaticJoint:g=new M(c instanceof U?c:null);break;case Q.e_revoluteJoint:g=new V(c instanceof Z?c:null);break;case Q.e_pulleyJoint:g=new K(c instanceof ba?c:null);break;case Q.e_gearJoint:g=new aa(c instanceof $?c:null);break;case Q.e_lineJoint:g=new j(c instanceof y?c:null);break;case Q.e_weldJoint:g=new ga(c instanceof fa?c:null);break;case Q.e_frictionJoint:g=new C(c instanceof R?c:null)}return g};Q.Create=Q.prototype.Create;Q.prototype.Destroy=function(){};
Q.Destroy=Q.prototype.Destroy;Q.prototype.b2Joint=function(c){L.b2Assert(c.bodyA!=c.bodyB);this.m_type=c.type;this.m_next=this.m_prev=null;this.m_bodyA=c.bodyA;this.m_bodyB=c.bodyB;this.m_collideConnected=c.collideConnected;this.m_islandFlag=false;this.m_userData=c.userData};Q.prototype.InitVelocityConstraints=function(){};Q.prototype.SolveVelocityConstraints=function(){};Q.prototype.FinalizeVelocityConstraints=function(){};Q.prototype.SolvePositionConstraints=function(){return false};_A2J_postDefs.push(function(){Box2D.Dynamics.Joints.b2Joint.e_unknownJoint=
0;Box2D.Dynamics.Joints.b2Joint.prototype.e_unknownJoint=Box2D.Dynamics.Joints.b2Joint.e_unknownJoint;Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint=1;Box2D.Dynamics.Joints.b2Joint.prototype.e_revoluteJoint=Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint;Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint=2;Box2D.Dynamics.Joints.b2Joint.prototype.e_prismaticJoint=Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint;Box2D.Dynamics.Joints.b2Joint.e_distanceJoint=3;Box2D.Dynamics.Joints.b2Joint.prototype.e_distanceJoint=
Box2D.Dynamics.Joints.b2Joint.e_distanceJoint;Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint=4;Box2D.Dynamics.Joints.b2Joint.prototype.e_pulleyJoint=Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint;Box2D.Dynamics.Joints.b2Joint.e_mouseJoint=5;Box2D.Dynamics.Joints.b2Joint.prototype.e_mouseJoint=Box2D.Dynamics.Joints.b2Joint.e_mouseJoint;Box2D.Dynamics.Joints.b2Joint.e_gearJoint=6;Box2D.Dynamics.Joints.b2Joint.prototype.e_gearJoint=Box2D.Dynamics.Joints.b2Joint.e_gearJoint;Box2D.Dynamics.Joints.b2Joint.e_lineJoint=
7;Box2D.Dynamics.Joints.b2Joint.prototype.e_lineJoint=Box2D.Dynamics.Joints.b2Joint.e_lineJoint;Box2D.Dynamics.Joints.b2Joint.e_weldJoint=8;Box2D.Dynamics.Joints.b2Joint.prototype.e_weldJoint=Box2D.Dynamics.Joints.b2Joint.e_weldJoint;Box2D.Dynamics.Joints.b2Joint.e_frictionJoint=9;Box2D.Dynamics.Joints.b2Joint.prototype.e_frictionJoint=Box2D.Dynamics.Joints.b2Joint.e_frictionJoint;Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit=0;Box2D.Dynamics.Joints.b2Joint.prototype.e_inactiveLimit=Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit;
Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit=1;Box2D.Dynamics.Joints.b2Joint.prototype.e_atLowerLimit=Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit;Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit=2;Box2D.Dynamics.Joints.b2Joint.prototype.e_atUpperLimit=Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit;Box2D.Dynamics.Joints.b2Joint.e_equalLimits=3;Box2D.Dynamics.Joints.b2Joint.prototype.e_equalLimits=Box2D.Dynamics.Joints.b2Joint.e_equalLimits});X.b2JointDef=function(){};X.prototype.b2JointDef=function(){this.type=
Q.e_unknownJoint;this.bodyB=this.bodyA=this.userData=null;this.collideConnected=false};da.b2JointEdge=function(){};j.inherit(Box2D.Dynamics.Joints.b2Joint);j.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;j.b2LineJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchor1=new G;this.m_localAnchor2=new G;this.m_localXAxis1=new G;this.m_localYAxis1=new G;this.m_axis=new G;this.m_perp=new G;this.m_K=new I;this.m_impulse=new G};j.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};
j.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};j.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x),c*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y))};j.prototype.GetReactionTorque=function(c){if(c===undefined)c=0;return c*this.m_impulse.y};j.prototype.GetJointTranslation=function(){var c=this.m_bodyA,g=this.m_bodyB,
k=c.GetWorldPoint(this.m_localAnchor1),h=g.GetWorldPoint(this.m_localAnchor2);g=h.x-k.x;k=h.y-k.y;c=c.GetWorldVector(this.m_localXAxis1);return c.x*g+c.y*k};j.prototype.GetJointSpeed=function(){var c=this.m_bodyA,g=this.m_bodyB,k;k=c.m_xf.R;var h=this.m_localAnchor1.x-c.m_sweep.localCenter.x,o=this.m_localAnchor1.y-c.m_sweep.localCenter.y,q=k.col1.x*h+k.col2.x*o;o=k.col1.y*h+k.col2.y*o;h=q;k=g.m_xf.R;var l=this.m_localAnchor2.x-g.m_sweep.localCenter.x,a=this.m_localAnchor2.y-g.m_sweep.localCenter.y;
q=k.col1.x*l+k.col2.x*a;a=k.col1.y*l+k.col2.y*a;l=q;k=g.m_sweep.c.x+l-(c.m_sweep.c.x+h);q=g.m_sweep.c.y+a-(c.m_sweep.c.y+o);var b=c.GetWorldVector(this.m_localXAxis1),f=c.m_linearVelocity,m=g.m_linearVelocity;c=c.m_angularVelocity;g=g.m_angularVelocity;return k*-c*b.y+q*c*b.x+(b.x*(m.x+-g*a-f.x- -c*o)+b.y*(m.y+g*l-f.y-c*h))};j.prototype.IsLimitEnabled=function(){return this.m_enableLimit};j.prototype.EnableLimit=function(c){this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_enableLimit=
c};j.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};j.prototype.GetUpperLimit=function(){return this.m_upperTranslation};j.prototype.SetLimits=function(c,g){if(c===undefined)c=0;if(g===undefined)g=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_lowerTranslation=c;this.m_upperTranslation=g};j.prototype.IsMotorEnabled=function(){return this.m_enableMotor};j.prototype.EnableMotor=function(c){this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_enableMotor=
c};j.prototype.SetMotorSpeed=function(c){if(c===undefined)c=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_motorSpeed=c};j.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};j.prototype.SetMaxMotorForce=function(c){if(c===undefined)c=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_maxMotorForce=c};j.prototype.GetMaxMotorForce=function(){return this.m_maxMotorForce};j.prototype.GetMotorForce=function(){return this.m_motorImpulse};j.prototype.b2LineJoint=
function(c){this.__super.b2Joint.call(this,c);this.m_localAnchor1.SetV(c.localAnchorA);this.m_localAnchor2.SetV(c.localAnchorB);this.m_localXAxis1.SetV(c.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y;this.m_localYAxis1.y=this.m_localXAxis1.x;this.m_impulse.SetZero();this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=c.lowerTranslation;this.m_upperTranslation=c.upperTranslation;this.m_maxMotorForce=c.maxMotorForce;this.m_motorSpeed=c.motorSpeed;this.m_enableLimit=c.enableLimit;
this.m_enableMotor=c.enableMotor;this.m_limitState=this.e_inactiveLimit;this.m_axis.SetZero();this.m_perp.SetZero()};j.prototype.InitVelocityConstraints=function(c){var g=this.m_bodyA,k=this.m_bodyB,h,o=0;this.m_localCenterA.SetV(g.GetLocalCenter());this.m_localCenterB.SetV(k.GetLocalCenter());var q=g.GetTransform();k.GetTransform();h=g.m_xf.R;var l=this.m_localAnchor1.x-this.m_localCenterA.x,a=this.m_localAnchor1.y-this.m_localCenterA.y;o=h.col1.x*l+h.col2.x*a;a=h.col1.y*l+h.col2.y*a;l=o;h=k.m_xf.R;
var b=this.m_localAnchor2.x-this.m_localCenterB.x,f=this.m_localAnchor2.y-this.m_localCenterB.y;o=h.col1.x*b+h.col2.x*f;f=h.col1.y*b+h.col2.y*f;b=o;h=k.m_sweep.c.x+b-g.m_sweep.c.x-l;o=k.m_sweep.c.y+f-g.m_sweep.c.y-a;this.m_invMassA=g.m_invMass;this.m_invMassB=k.m_invMass;this.m_invIA=g.m_invI;this.m_invIB=k.m_invI;this.m_axis.SetV(F.MulMV(q.R,this.m_localXAxis1));this.m_a1=(h+l)*this.m_axis.y-(o+a)*this.m_axis.x;this.m_a2=b*this.m_axis.y-f*this.m_axis.x;this.m_motorMass=this.m_invMassA+this.m_invMassB+
this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2;this.m_motorMass=this.m_motorMass>Number.MIN_VALUE?1/this.m_motorMass:0;this.m_perp.SetV(F.MulMV(q.R,this.m_localYAxis1));this.m_s1=(h+l)*this.m_perp.y-(o+a)*this.m_perp.x;this.m_s2=b*this.m_perp.y-f*this.m_perp.x;q=this.m_invMassA;l=this.m_invMassB;a=this.m_invIA;b=this.m_invIB;this.m_K.col1.x=q+l+a*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2;this.m_K.col1.y=a*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;
this.m_K.col2.y=q+l+a*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2;if(this.m_enableLimit){h=this.m_axis.x*h+this.m_axis.y*o;if(F.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*L.b2_linearSlop)this.m_limitState=this.e_equalLimits;else if(h<=this.m_lowerTranslation){if(this.m_limitState!=this.e_atLowerLimit){this.m_limitState=this.e_atLowerLimit;this.m_impulse.y=0}}else if(h>=this.m_upperTranslation){if(this.m_limitState!=this.e_atUpperLimit){this.m_limitState=this.e_atUpperLimit;this.m_impulse.y=
0}}else{this.m_limitState=this.e_inactiveLimit;this.m_impulse.y=0}}else this.m_limitState=this.e_inactiveLimit;if(this.m_enableMotor==false)this.m_motorImpulse=0;if(c.warmStarting){this.m_impulse.x*=c.dtRatio;this.m_impulse.y*=c.dtRatio;this.m_motorImpulse*=c.dtRatio;c=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x;h=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y;o=this.m_impulse.x*this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*
this.m_a1;q=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2;g.m_linearVelocity.x-=this.m_invMassA*c;g.m_linearVelocity.y-=this.m_invMassA*h;g.m_angularVelocity-=this.m_invIA*o;k.m_linearVelocity.x+=this.m_invMassB*c;k.m_linearVelocity.y+=this.m_invMassB*h;k.m_angularVelocity+=this.m_invIB*q}else{this.m_impulse.SetZero();this.m_motorImpulse=0}};j.prototype.SolveVelocityConstraints=function(c){var g=this.m_bodyA,k=this.m_bodyB,h=g.m_linearVelocity,o=g.m_angularVelocity,q=
k.m_linearVelocity,l=k.m_angularVelocity,a=0,b=0,f=0,m=0;if(this.m_enableMotor&&this.m_limitState!=this.e_equalLimits){m=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(q.x-h.x)+this.m_axis.y*(q.y-h.y)+this.m_a2*l-this.m_a1*o));a=this.m_motorImpulse;b=c.dt*this.m_maxMotorForce;this.m_motorImpulse=F.Clamp(this.m_motorImpulse+m,-b,b);m=this.m_motorImpulse-a;a=m*this.m_axis.x;b=m*this.m_axis.y;f=m*this.m_a1;m=m*this.m_a2;h.x-=this.m_invMassA*a;h.y-=this.m_invMassA*b;o-=this.m_invIA*f;q.x+=this.m_invMassB*
a;q.y+=this.m_invMassB*b;l+=this.m_invIB*m}b=this.m_perp.x*(q.x-h.x)+this.m_perp.y*(q.y-h.y)+this.m_s2*l-this.m_s1*o;if(this.m_enableLimit&&this.m_limitState!=this.e_inactiveLimit){f=this.m_axis.x*(q.x-h.x)+this.m_axis.y*(q.y-h.y)+this.m_a2*l-this.m_a1*o;a=this.m_impulse.Copy();c=this.m_K.Solve(new G,-b,-f);this.m_impulse.Add(c);if(this.m_limitState==this.e_atLowerLimit)this.m_impulse.y=F.Max(this.m_impulse.y,0);else if(this.m_limitState==this.e_atUpperLimit)this.m_impulse.y=F.Min(this.m_impulse.y,
0);b=-b-(this.m_impulse.y-a.y)*this.m_K.col2.x;f=0;f=this.m_K.col1.x!=0?b/this.m_K.col1.x+a.x:a.x;this.m_impulse.x=f;c.x=this.m_impulse.x-a.x;c.y=this.m_impulse.y-a.y;a=c.x*this.m_perp.x+c.y*this.m_axis.x;b=c.x*this.m_perp.y+c.y*this.m_axis.y;f=c.x*this.m_s1+c.y*this.m_a1;m=c.x*this.m_s2+c.y*this.m_a2}else{c=0;c=this.m_K.col1.x!=0?-b/this.m_K.col1.x:0;this.m_impulse.x+=c;a=c*this.m_perp.x;b=c*this.m_perp.y;f=c*this.m_s1;m=c*this.m_s2}h.x-=this.m_invMassA*a;h.y-=this.m_invMassA*b;o-=this.m_invIA*f;
q.x+=this.m_invMassB*a;q.y+=this.m_invMassB*b;l+=this.m_invIB*m;g.m_linearVelocity.SetV(h);g.m_angularVelocity=o;k.m_linearVelocity.SetV(q);k.m_angularVelocity=l};j.prototype.SolvePositionConstraints=function(){var c=this.m_bodyA,g=this.m_bodyB,k=c.m_sweep.c,h=c.m_sweep.a,o=g.m_sweep.c,q=g.m_sweep.a,l,a=0,b=0,f=0,m=0,p=l=0,D=0;b=false;var B=0,O=I.FromAngle(h);f=I.FromAngle(q);l=O;D=this.m_localAnchor1.x-this.m_localCenterA.x;var W=this.m_localAnchor1.y-this.m_localCenterA.y;a=l.col1.x*D+l.col2.x*
W;W=l.col1.y*D+l.col2.y*W;D=a;l=f;f=this.m_localAnchor2.x-this.m_localCenterB.x;m=this.m_localAnchor2.y-this.m_localCenterB.y;a=l.col1.x*f+l.col2.x*m;m=l.col1.y*f+l.col2.y*m;f=a;l=o.x+f-k.x-D;a=o.y+m-k.y-W;if(this.m_enableLimit){this.m_axis=F.MulMV(O,this.m_localXAxis1);this.m_a1=(l+D)*this.m_axis.y-(a+W)*this.m_axis.x;this.m_a2=f*this.m_axis.y-m*this.m_axis.x;var ca=this.m_axis.x*l+this.m_axis.y*a;if(F.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*L.b2_linearSlop){B=F.Clamp(ca,-L.b2_maxLinearCorrection,
L.b2_maxLinearCorrection);p=F.Abs(ca);b=true}else if(ca<=this.m_lowerTranslation){B=F.Clamp(ca-this.m_lowerTranslation+L.b2_linearSlop,-L.b2_maxLinearCorrection,0);p=this.m_lowerTranslation-ca;b=true}else if(ca>=this.m_upperTranslation){B=F.Clamp(ca-this.m_upperTranslation+L.b2_linearSlop,0,L.b2_maxLinearCorrection);p=ca-this.m_upperTranslation;b=true}}this.m_perp=F.MulMV(O,this.m_localYAxis1);this.m_s1=(l+D)*this.m_perp.y-(a+W)*this.m_perp.x;this.m_s2=f*this.m_perp.y-m*this.m_perp.x;O=new G;W=this.m_perp.x*
l+this.m_perp.y*a;p=F.Max(p,F.Abs(W));D=0;if(b){b=this.m_invMassA;f=this.m_invMassB;m=this.m_invIA;l=this.m_invIB;this.m_K.col1.x=b+f+m*this.m_s1*this.m_s1+l*this.m_s2*this.m_s2;this.m_K.col1.y=m*this.m_s1*this.m_a1+l*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=b+f+m*this.m_a1*this.m_a1+l*this.m_a2*this.m_a2;this.m_K.Solve(O,-W,-B)}else{b=this.m_invMassA;f=this.m_invMassB;m=this.m_invIA;l=this.m_invIB;B=b+f+m*this.m_s1*this.m_s1+l*this.m_s2*this.m_s2;b=0;b=B!=0?-W/B:0;O.x=
b;O.y=0}B=O.x*this.m_perp.x+O.y*this.m_axis.x;b=O.x*this.m_perp.y+O.y*this.m_axis.y;W=O.x*this.m_s1+O.y*this.m_a1;O=O.x*this.m_s2+O.y*this.m_a2;k.x-=this.m_invMassA*B;k.y-=this.m_invMassA*b;h-=this.m_invIA*W;o.x+=this.m_invMassB*B;o.y+=this.m_invMassB*b;q+=this.m_invIB*O;c.m_sweep.a=h;g.m_sweep.a=q;c.SynchronizeTransform();g.SynchronizeTransform();return p<=L.b2_linearSlop&&D<=L.b2_angularSlop};y.inherit(Box2D.Dynamics.Joints.b2JointDef);y.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;
y.b2LineJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new G;this.localAnchorB=new G;this.localAxisA=new G};y.prototype.b2LineJointDef=function(){this.__super.b2JointDef.call(this);this.type=Q.e_lineJoint;this.localAxisA.Set(1,0);this.enableLimit=false;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=false;this.motorSpeed=this.maxMotorForce=0};y.prototype.Initialize=function(c,g,k,h){this.bodyA=c;this.bodyB=g;this.localAnchorA=
this.bodyA.GetLocalPoint(k);this.localAnchorB=this.bodyB.GetLocalPoint(k);this.localAxisA=this.bodyA.GetLocalVector(h)};x.inherit(Box2D.Dynamics.Joints.b2Joint);x.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;x.b2MouseJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.K=new I;this.K1=new I;this.K2=new I;this.m_localAnchor=new G;this.m_target=new G;this.m_impulse=new G;this.m_mass=new I;this.m_C=new G};x.prototype.GetAnchorA=function(){return this.m_target};
x.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor)};x.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*this.m_impulse.x,c*this.m_impulse.y)};x.prototype.GetReactionTorque=function(){return 0};x.prototype.GetTarget=function(){return this.m_target};x.prototype.SetTarget=function(c){this.m_bodyB.IsAwake()==false&&this.m_bodyB.SetAwake(true);this.m_target=c};x.prototype.GetMaxForce=function(){return this.m_maxForce};x.prototype.SetMaxForce=
function(c){if(c===undefined)c=0;this.m_maxForce=c};x.prototype.GetFrequency=function(){return this.m_frequencyHz};x.prototype.SetFrequency=function(c){if(c===undefined)c=0;this.m_frequencyHz=c};x.prototype.GetDampingRatio=function(){return this.m_dampingRatio};x.prototype.SetDampingRatio=function(c){if(c===undefined)c=0;this.m_dampingRatio=c};x.prototype.b2MouseJoint=function(c){this.__super.b2Joint.call(this,c);this.m_target.SetV(c.target);var g=this.m_target.x-this.m_bodyB.m_xf.position.x,k=this.m_target.y-
this.m_bodyB.m_xf.position.y,h=this.m_bodyB.m_xf.R;this.m_localAnchor.x=g*h.col1.x+k*h.col1.y;this.m_localAnchor.y=g*h.col2.x+k*h.col2.y;this.m_maxForce=c.maxForce;this.m_impulse.SetZero();this.m_frequencyHz=c.frequencyHz;this.m_dampingRatio=c.dampingRatio;this.m_gamma=this.m_beta=0};x.prototype.InitVelocityConstraints=function(c){var g=this.m_bodyB,k=g.GetMass(),h=2*Math.PI*this.m_frequencyHz,o=k*h*h;this.m_gamma=c.dt*(2*k*this.m_dampingRatio*h+c.dt*o);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:
0;this.m_beta=c.dt*o*this.m_gamma;o=g.m_xf.R;k=this.m_localAnchor.x-g.m_sweep.localCenter.x;h=this.m_localAnchor.y-g.m_sweep.localCenter.y;var q=o.col1.x*k+o.col2.x*h;h=o.col1.y*k+o.col2.y*h;k=q;o=g.m_invMass;q=g.m_invI;this.K1.col1.x=o;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=o;this.K2.col1.x=q*h*h;this.K2.col2.x=-q*k*h;this.K2.col1.y=-q*k*h;this.K2.col2.y=q*k*k;this.K.SetM(this.K1);this.K.AddM(this.K2);this.K.col1.x+=this.m_gamma;this.K.col2.y+=this.m_gamma;this.K.GetInverse(this.m_mass);
this.m_C.x=g.m_sweep.c.x+k-this.m_target.x;this.m_C.y=g.m_sweep.c.y+h-this.m_target.y;g.m_angularVelocity*=0.98;this.m_impulse.x*=c.dtRatio;this.m_impulse.y*=c.dtRatio;g.m_linearVelocity.x+=o*this.m_impulse.x;g.m_linearVelocity.y+=o*this.m_impulse.y;g.m_angularVelocity+=q*(k*this.m_impulse.y-h*this.m_impulse.x)};x.prototype.SolveVelocityConstraints=function(c){var g=this.m_bodyB,k,h=0,o=0;k=g.m_xf.R;var q=this.m_localAnchor.x-g.m_sweep.localCenter.x,l=this.m_localAnchor.y-g.m_sweep.localCenter.y;
h=k.col1.x*q+k.col2.x*l;l=k.col1.y*q+k.col2.y*l;q=h;h=g.m_linearVelocity.x+-g.m_angularVelocity*l;var a=g.m_linearVelocity.y+g.m_angularVelocity*q;k=this.m_mass;h=h+this.m_beta*this.m_C.x+this.m_gamma*this.m_impulse.x;o=a+this.m_beta*this.m_C.y+this.m_gamma*this.m_impulse.y;a=-(k.col1.x*h+k.col2.x*o);o=-(k.col1.y*h+k.col2.y*o);k=this.m_impulse.x;h=this.m_impulse.y;this.m_impulse.x+=a;this.m_impulse.y+=o;c=c.dt*this.m_maxForce;this.m_impulse.LengthSquared()>c*c&&this.m_impulse.Multiply(c/this.m_impulse.Length());
a=this.m_impulse.x-k;o=this.m_impulse.y-h;g.m_linearVelocity.x+=g.m_invMass*a;g.m_linearVelocity.y+=g.m_invMass*o;g.m_angularVelocity+=g.m_invI*(q*o-l*a)};x.prototype.SolvePositionConstraints=function(){return true};J.inherit(Box2D.Dynamics.Joints.b2JointDef);J.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;J.b2MouseJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.target=new G};J.prototype.b2MouseJointDef=function(){this.__super.b2JointDef.call(this);
this.type=Q.e_mouseJoint;this.maxForce=0;this.frequencyHz=5;this.dampingRatio=0.7};M.inherit(Box2D.Dynamics.Joints.b2Joint);M.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;M.b2PrismaticJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchor1=new G;this.m_localAnchor2=new G;this.m_localXAxis1=new G;this.m_localYAxis1=new G;this.m_axis=new G;this.m_perp=new G;this.m_K=new H;this.m_impulse=new A};M.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};
M.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};M.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),c*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))};M.prototype.GetReactionTorque=function(c){if(c===undefined)c=0;return c*this.m_impulse.y};M.prototype.GetJointTranslation=function(){var c=this.m_bodyA,g=this.m_bodyB,
k=c.GetWorldPoint(this.m_localAnchor1),h=g.GetWorldPoint(this.m_localAnchor2);g=h.x-k.x;k=h.y-k.y;c=c.GetWorldVector(this.m_localXAxis1);return c.x*g+c.y*k};M.prototype.GetJointSpeed=function(){var c=this.m_bodyA,g=this.m_bodyB,k;k=c.m_xf.R;var h=this.m_localAnchor1.x-c.m_sweep.localCenter.x,o=this.m_localAnchor1.y-c.m_sweep.localCenter.y,q=k.col1.x*h+k.col2.x*o;o=k.col1.y*h+k.col2.y*o;h=q;k=g.m_xf.R;var l=this.m_localAnchor2.x-g.m_sweep.localCenter.x,a=this.m_localAnchor2.y-g.m_sweep.localCenter.y;
q=k.col1.x*l+k.col2.x*a;a=k.col1.y*l+k.col2.y*a;l=q;k=g.m_sweep.c.x+l-(c.m_sweep.c.x+h);q=g.m_sweep.c.y+a-(c.m_sweep.c.y+o);var b=c.GetWorldVector(this.m_localXAxis1),f=c.m_linearVelocity,m=g.m_linearVelocity;c=c.m_angularVelocity;g=g.m_angularVelocity;return k*-c*b.y+q*c*b.x+(b.x*(m.x+-g*a-f.x- -c*o)+b.y*(m.y+g*l-f.y-c*h))};M.prototype.IsLimitEnabled=function(){return this.m_enableLimit};M.prototype.EnableLimit=function(c){this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_enableLimit=
c};M.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};M.prototype.GetUpperLimit=function(){return this.m_upperTranslation};M.prototype.SetLimits=function(c,g){if(c===undefined)c=0;if(g===undefined)g=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_lowerTranslation=c;this.m_upperTranslation=g};M.prototype.IsMotorEnabled=function(){return this.m_enableMotor};M.prototype.EnableMotor=function(c){this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_enableMotor=
c};M.prototype.SetMotorSpeed=function(c){if(c===undefined)c=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_motorSpeed=c};M.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};M.prototype.SetMaxMotorForce=function(c){if(c===undefined)c=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_maxMotorForce=c};M.prototype.GetMotorForce=function(){return this.m_motorImpulse};M.prototype.b2PrismaticJoint=function(c){this.__super.b2Joint.call(this,c);this.m_localAnchor1.SetV(c.localAnchorA);
this.m_localAnchor2.SetV(c.localAnchorB);this.m_localXAxis1.SetV(c.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y;this.m_localYAxis1.y=this.m_localXAxis1.x;this.m_refAngle=c.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=c.lowerTranslation;this.m_upperTranslation=c.upperTranslation;this.m_maxMotorForce=c.maxMotorForce;this.m_motorSpeed=c.motorSpeed;this.m_enableLimit=c.enableLimit;this.m_enableMotor=c.enableMotor;this.m_limitState=this.e_inactiveLimit;
this.m_axis.SetZero();this.m_perp.SetZero()};M.prototype.InitVelocityConstraints=function(c){var g=this.m_bodyA,k=this.m_bodyB,h,o=0;this.m_localCenterA.SetV(g.GetLocalCenter());this.m_localCenterB.SetV(k.GetLocalCenter());var q=g.GetTransform();k.GetTransform();h=g.m_xf.R;var l=this.m_localAnchor1.x-this.m_localCenterA.x,a=this.m_localAnchor1.y-this.m_localCenterA.y;o=h.col1.x*l+h.col2.x*a;a=h.col1.y*l+h.col2.y*a;l=o;h=k.m_xf.R;var b=this.m_localAnchor2.x-this.m_localCenterB.x,f=this.m_localAnchor2.y-
this.m_localCenterB.y;o=h.col1.x*b+h.col2.x*f;f=h.col1.y*b+h.col2.y*f;b=o;h=k.m_sweep.c.x+b-g.m_sweep.c.x-l;o=k.m_sweep.c.y+f-g.m_sweep.c.y-a;this.m_invMassA=g.m_invMass;this.m_invMassB=k.m_invMass;this.m_invIA=g.m_invI;this.m_invIB=k.m_invI;this.m_axis.SetV(F.MulMV(q.R,this.m_localXAxis1));this.m_a1=(h+l)*this.m_axis.y-(o+a)*this.m_axis.x;this.m_a2=b*this.m_axis.y-f*this.m_axis.x;this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2;if(this.m_motorMass>
Number.MIN_VALUE)this.m_motorMass=1/this.m_motorMass;this.m_perp.SetV(F.MulMV(q.R,this.m_localYAxis1));this.m_s1=(h+l)*this.m_perp.y-(o+a)*this.m_perp.x;this.m_s2=b*this.m_perp.y-f*this.m_perp.x;q=this.m_invMassA;l=this.m_invMassB;a=this.m_invIA;b=this.m_invIB;this.m_K.col1.x=q+l+a*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2;this.m_K.col1.y=a*this.m_s1+b*this.m_s2;this.m_K.col1.z=a*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=a+b;this.m_K.col2.z=a*this.m_a1+
b*this.m_a2;this.m_K.col3.x=this.m_K.col1.z;this.m_K.col3.y=this.m_K.col2.z;this.m_K.col3.z=q+l+a*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2;if(this.m_enableLimit){h=this.m_axis.x*h+this.m_axis.y*o;if(F.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*L.b2_linearSlop)this.m_limitState=this.e_equalLimits;else if(h<=this.m_lowerTranslation){if(this.m_limitState!=this.e_atLowerLimit){this.m_limitState=this.e_atLowerLimit;this.m_impulse.z=0}}else if(h>=this.m_upperTranslation){if(this.m_limitState!=
this.e_atUpperLimit){this.m_limitState=this.e_atUpperLimit;this.m_impulse.z=0}}else{this.m_limitState=this.e_inactiveLimit;this.m_impulse.z=0}}else this.m_limitState=this.e_inactiveLimit;if(this.m_enableMotor==false)this.m_motorImpulse=0;if(c.warmStarting){this.m_impulse.x*=c.dtRatio;this.m_impulse.y*=c.dtRatio;this.m_motorImpulse*=c.dtRatio;c=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x;h=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*
this.m_axis.y;o=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1;q=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;g.m_linearVelocity.x-=this.m_invMassA*c;g.m_linearVelocity.y-=this.m_invMassA*h;g.m_angularVelocity-=this.m_invIA*o;k.m_linearVelocity.x+=this.m_invMassB*c;k.m_linearVelocity.y+=this.m_invMassB*h;k.m_angularVelocity+=this.m_invIB*q}else{this.m_impulse.SetZero();this.m_motorImpulse=0}};M.prototype.SolveVelocityConstraints=
function(c){var g=this.m_bodyA,k=this.m_bodyB,h=g.m_linearVelocity,o=g.m_angularVelocity,q=k.m_linearVelocity,l=k.m_angularVelocity,a=0,b=0,f=0,m=0;if(this.m_enableMotor&&this.m_limitState!=this.e_equalLimits){m=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(q.x-h.x)+this.m_axis.y*(q.y-h.y)+this.m_a2*l-this.m_a1*o));a=this.m_motorImpulse;c=c.dt*this.m_maxMotorForce;this.m_motorImpulse=F.Clamp(this.m_motorImpulse+m,-c,c);m=this.m_motorImpulse-a;a=m*this.m_axis.x;b=m*this.m_axis.y;f=m*this.m_a1;
m=m*this.m_a2;h.x-=this.m_invMassA*a;h.y-=this.m_invMassA*b;o-=this.m_invIA*f;q.x+=this.m_invMassB*a;q.y+=this.m_invMassB*b;l+=this.m_invIB*m}f=this.m_perp.x*(q.x-h.x)+this.m_perp.y*(q.y-h.y)+this.m_s2*l-this.m_s1*o;b=l-o;if(this.m_enableLimit&&this.m_limitState!=this.e_inactiveLimit){c=this.m_axis.x*(q.x-h.x)+this.m_axis.y*(q.y-h.y)+this.m_a2*l-this.m_a1*o;a=this.m_impulse.Copy();c=this.m_K.Solve33(new A,-f,-b,-c);this.m_impulse.Add(c);if(this.m_limitState==this.e_atLowerLimit)this.m_impulse.z=F.Max(this.m_impulse.z,
0);else if(this.m_limitState==this.e_atUpperLimit)this.m_impulse.z=F.Min(this.m_impulse.z,0);f=-f-(this.m_impulse.z-a.z)*this.m_K.col3.x;b=-b-(this.m_impulse.z-a.z)*this.m_K.col3.y;b=this.m_K.Solve22(new G,f,b);b.x+=a.x;b.y+=a.y;this.m_impulse.x=b.x;this.m_impulse.y=b.y;c.x=this.m_impulse.x-a.x;c.y=this.m_impulse.y-a.y;c.z=this.m_impulse.z-a.z;a=c.x*this.m_perp.x+c.z*this.m_axis.x;b=c.x*this.m_perp.y+c.z*this.m_axis.y;f=c.x*this.m_s1+c.y+c.z*this.m_a1;m=c.x*this.m_s2+c.y+c.z*this.m_a2}else{c=this.m_K.Solve22(new G,
-f,-b);this.m_impulse.x+=c.x;this.m_impulse.y+=c.y;a=c.x*this.m_perp.x;b=c.x*this.m_perp.y;f=c.x*this.m_s1+c.y;m=c.x*this.m_s2+c.y}h.x-=this.m_invMassA*a;h.y-=this.m_invMassA*b;o-=this.m_invIA*f;q.x+=this.m_invMassB*a;q.y+=this.m_invMassB*b;l+=this.m_invIB*m;g.m_linearVelocity.SetV(h);g.m_angularVelocity=o;k.m_linearVelocity.SetV(q);k.m_angularVelocity=l};M.prototype.SolvePositionConstraints=function(){var c=this.m_bodyA,g=this.m_bodyB,k=c.m_sweep.c,h=c.m_sweep.a,o=g.m_sweep.c,q=g.m_sweep.a,l,a=0,
b=0,f=0,m=a=l=0,p=0;b=false;var D=0,B=I.FromAngle(h),O=I.FromAngle(q);l=B;p=this.m_localAnchor1.x-this.m_localCenterA.x;var W=this.m_localAnchor1.y-this.m_localCenterA.y;a=l.col1.x*p+l.col2.x*W;W=l.col1.y*p+l.col2.y*W;p=a;l=O;O=this.m_localAnchor2.x-this.m_localCenterB.x;f=this.m_localAnchor2.y-this.m_localCenterB.y;a=l.col1.x*O+l.col2.x*f;f=l.col1.y*O+l.col2.y*f;O=a;l=o.x+O-k.x-p;a=o.y+f-k.y-W;if(this.m_enableLimit){this.m_axis=F.MulMV(B,this.m_localXAxis1);this.m_a1=(l+p)*this.m_axis.y-(a+W)*this.m_axis.x;
this.m_a2=O*this.m_axis.y-f*this.m_axis.x;var ca=this.m_axis.x*l+this.m_axis.y*a;if(F.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*L.b2_linearSlop){D=F.Clamp(ca,-L.b2_maxLinearCorrection,L.b2_maxLinearCorrection);m=F.Abs(ca);b=true}else if(ca<=this.m_lowerTranslation){D=F.Clamp(ca-this.m_lowerTranslation+L.b2_linearSlop,-L.b2_maxLinearCorrection,0);m=this.m_lowerTranslation-ca;b=true}else if(ca>=this.m_upperTranslation){D=F.Clamp(ca-this.m_upperTranslation+L.b2_linearSlop,0,L.b2_maxLinearCorrection);
m=ca-this.m_upperTranslation;b=true}}this.m_perp=F.MulMV(B,this.m_localYAxis1);this.m_s1=(l+p)*this.m_perp.y-(a+W)*this.m_perp.x;this.m_s2=O*this.m_perp.y-f*this.m_perp.x;B=new A;W=this.m_perp.x*l+this.m_perp.y*a;O=q-h-this.m_refAngle;m=F.Max(m,F.Abs(W));p=F.Abs(O);if(b){b=this.m_invMassA;f=this.m_invMassB;l=this.m_invIA;a=this.m_invIB;this.m_K.col1.x=b+f+l*this.m_s1*this.m_s1+a*this.m_s2*this.m_s2;this.m_K.col1.y=l*this.m_s1+a*this.m_s2;this.m_K.col1.z=l*this.m_s1*this.m_a1+a*this.m_s2*this.m_a2;
this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=l+a;this.m_K.col2.z=l*this.m_a1+a*this.m_a2;this.m_K.col3.x=this.m_K.col1.z;this.m_K.col3.y=this.m_K.col2.z;this.m_K.col3.z=b+f+l*this.m_a1*this.m_a1+a*this.m_a2*this.m_a2;this.m_K.Solve33(B,-W,-O,-D)}else{b=this.m_invMassA;f=this.m_invMassB;l=this.m_invIA;a=this.m_invIB;D=l*this.m_s1+a*this.m_s2;ca=l+a;this.m_K.col1.Set(b+f+l*this.m_s1*this.m_s1+a*this.m_s2*this.m_s2,D,0);this.m_K.col2.Set(D,ca,0);D=this.m_K.Solve22(new G,-W,-O);B.x=D.x;B.y=D.y;B.z=
0}D=B.x*this.m_perp.x+B.z*this.m_axis.x;b=B.x*this.m_perp.y+B.z*this.m_axis.y;W=B.x*this.m_s1+B.y+B.z*this.m_a1;B=B.x*this.m_s2+B.y+B.z*this.m_a2;k.x-=this.m_invMassA*D;k.y-=this.m_invMassA*b;h-=this.m_invIA*W;o.x+=this.m_invMassB*D;o.y+=this.m_invMassB*b;q+=this.m_invIB*B;c.m_sweep.a=h;g.m_sweep.a=q;c.SynchronizeTransform();g.SynchronizeTransform();return m<=L.b2_linearSlop&&p<=L.b2_angularSlop};U.inherit(Box2D.Dynamics.Joints.b2JointDef);U.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;
U.b2PrismaticJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new G;this.localAnchorB=new G;this.localAxisA=new G};U.prototype.b2PrismaticJointDef=function(){this.__super.b2JointDef.call(this);this.type=Q.e_prismaticJoint;this.localAxisA.Set(1,0);this.referenceAngle=0;this.enableLimit=false;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=false;this.motorSpeed=this.maxMotorForce=0};U.prototype.Initialize=function(c,g,k,h){this.bodyA=
c;this.bodyB=g;this.localAnchorA=this.bodyA.GetLocalPoint(k);this.localAnchorB=this.bodyB.GetLocalPoint(k);this.localAxisA=this.bodyA.GetLocalVector(h);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};K.inherit(Box2D.Dynamics.Joints.b2Joint);K.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;K.b2PulleyJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_groundAnchor1=new G;this.m_groundAnchor2=new G;this.m_localAnchor1=new G;this.m_localAnchor2=
new G;this.m_u1=new G;this.m_u2=new G};K.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};K.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};K.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*this.m_impulse*this.m_u2.x,c*this.m_impulse*this.m_u2.y)};K.prototype.GetReactionTorque=function(){return 0};K.prototype.GetGroundAnchorA=function(){var c=this.m_ground.m_xf.position.Copy();c.Add(this.m_groundAnchor1);
return c};K.prototype.GetGroundAnchorB=function(){var c=this.m_ground.m_xf.position.Copy();c.Add(this.m_groundAnchor2);return c};K.prototype.GetLength1=function(){var c=this.m_bodyA.GetWorldPoint(this.m_localAnchor1),g=c.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x);c=c.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y);return Math.sqrt(g*g+c*c)};K.prototype.GetLength2=function(){var c=this.m_bodyB.GetWorldPoint(this.m_localAnchor2),g=c.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor2.x);
c=c.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor2.y);return Math.sqrt(g*g+c*c)};K.prototype.GetRatio=function(){return this.m_ratio};K.prototype.b2PulleyJoint=function(c){this.__super.b2Joint.call(this,c);this.m_ground=this.m_bodyA.m_world.m_groundBody;this.m_groundAnchor1.x=c.groundAnchorA.x-this.m_ground.m_xf.position.x;this.m_groundAnchor1.y=c.groundAnchorA.y-this.m_ground.m_xf.position.y;this.m_groundAnchor2.x=c.groundAnchorB.x-this.m_ground.m_xf.position.x;this.m_groundAnchor2.y=c.groundAnchorB.y-
this.m_ground.m_xf.position.y;this.m_localAnchor1.SetV(c.localAnchorA);this.m_localAnchor2.SetV(c.localAnchorB);this.m_ratio=c.ratio;this.m_constant=c.lengthA+this.m_ratio*c.lengthB;this.m_maxLength1=F.Min(c.maxLengthA,this.m_constant-this.m_ratio*K.b2_minPulleyLength);this.m_maxLength2=F.Min(c.maxLengthB,(this.m_constant-K.b2_minPulleyLength)/this.m_ratio);this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};K.prototype.InitVelocityConstraints=function(c){var g=this.m_bodyA,k=this.m_bodyB,
h;h=g.m_xf.R;var o=this.m_localAnchor1.x-g.m_sweep.localCenter.x,q=this.m_localAnchor1.y-g.m_sweep.localCenter.y,l=h.col1.x*o+h.col2.x*q;q=h.col1.y*o+h.col2.y*q;o=l;h=k.m_xf.R;var a=this.m_localAnchor2.x-k.m_sweep.localCenter.x,b=this.m_localAnchor2.y-k.m_sweep.localCenter.y;l=h.col1.x*a+h.col2.x*b;b=h.col1.y*a+h.col2.y*b;a=l;h=k.m_sweep.c.x+a;l=k.m_sweep.c.y+b;var f=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,m=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y;this.m_u1.Set(g.m_sweep.c.x+
o-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x),g.m_sweep.c.y+q-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y));this.m_u2.Set(h-f,l-m);h=this.m_u1.Length();l=this.m_u2.Length();h>L.b2_linearSlop?this.m_u1.Multiply(1/h):this.m_u1.SetZero();l>L.b2_linearSlop?this.m_u2.Multiply(1/l):this.m_u2.SetZero();if(this.m_constant-h-this.m_ratio*l>0){this.m_state=this.e_inactiveLimit;this.m_impulse=0}else this.m_state=this.e_atUpperLimit;if(h<this.m_maxLength1){this.m_limitState1=this.e_inactiveLimit;
this.m_limitImpulse1=0}else this.m_limitState1=this.e_atUpperLimit;if(l<this.m_maxLength2){this.m_limitState2=this.e_inactiveLimit;this.m_limitImpulse2=0}else this.m_limitState2=this.e_atUpperLimit;h=o*this.m_u1.y-q*this.m_u1.x;l=a*this.m_u2.y-b*this.m_u2.x;this.m_limitMass1=g.m_invMass+g.m_invI*h*h;this.m_limitMass2=k.m_invMass+k.m_invI*l*l;this.m_pulleyMass=this.m_limitMass1+this.m_ratio*this.m_ratio*this.m_limitMass2;this.m_limitMass1=1/this.m_limitMass1;this.m_limitMass2=1/this.m_limitMass2;this.m_pulleyMass=
1/this.m_pulleyMass;if(c.warmStarting){this.m_impulse*=c.dtRatio;this.m_limitImpulse1*=c.dtRatio;this.m_limitImpulse2*=c.dtRatio;c=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.x;h=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.y;l=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.x;f=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.y;g.m_linearVelocity.x+=g.m_invMass*c;g.m_linearVelocity.y+=g.m_invMass*h;g.m_angularVelocity+=g.m_invI*(o*h-q*c);k.m_linearVelocity.x+=
k.m_invMass*l;k.m_linearVelocity.y+=k.m_invMass*f;k.m_angularVelocity+=k.m_invI*(a*f-b*l)}else this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};K.prototype.SolveVelocityConstraints=function(){var c=this.m_bodyA,g=this.m_bodyB,k;k=c.m_xf.R;var h=this.m_localAnchor1.x-c.m_sweep.localCenter.x,o=this.m_localAnchor1.y-c.m_sweep.localCenter.y,q=k.col1.x*h+k.col2.x*o;o=k.col1.y*h+k.col2.y*o;h=q;k=g.m_xf.R;var l=this.m_localAnchor2.x-g.m_sweep.localCenter.x,a=this.m_localAnchor2.y-g.m_sweep.localCenter.y;
q=k.col1.x*l+k.col2.x*a;a=k.col1.y*l+k.col2.y*a;l=q;var b=q=k=0,f=0;k=f=k=f=b=q=k=0;if(this.m_state==this.e_atUpperLimit){k=c.m_linearVelocity.x+-c.m_angularVelocity*o;q=c.m_linearVelocity.y+c.m_angularVelocity*h;b=g.m_linearVelocity.x+-g.m_angularVelocity*a;f=g.m_linearVelocity.y+g.m_angularVelocity*l;k=-(this.m_u1.x*k+this.m_u1.y*q)-this.m_ratio*(this.m_u2.x*b+this.m_u2.y*f);f=this.m_pulleyMass*-k;k=this.m_impulse;this.m_impulse=F.Max(0,this.m_impulse+f);f=this.m_impulse-k;k=-f*this.m_u1.x;q=-f*
this.m_u1.y;b=-this.m_ratio*f*this.m_u2.x;f=-this.m_ratio*f*this.m_u2.y;c.m_linearVelocity.x+=c.m_invMass*k;c.m_linearVelocity.y+=c.m_invMass*q;c.m_angularVelocity+=c.m_invI*(h*q-o*k);g.m_linearVelocity.x+=g.m_invMass*b;g.m_linearVelocity.y+=g.m_invMass*f;g.m_angularVelocity+=g.m_invI*(l*f-a*b)}if(this.m_limitState1==this.e_atUpperLimit){k=c.m_linearVelocity.x+-c.m_angularVelocity*o;q=c.m_linearVelocity.y+c.m_angularVelocity*h;k=-(this.m_u1.x*k+this.m_u1.y*q);f=-this.m_limitMass1*k;k=this.m_limitImpulse1;
this.m_limitImpulse1=F.Max(0,this.m_limitImpulse1+f);f=this.m_limitImpulse1-k;k=-f*this.m_u1.x;q=-f*this.m_u1.y;c.m_linearVelocity.x+=c.m_invMass*k;c.m_linearVelocity.y+=c.m_invMass*q;c.m_angularVelocity+=c.m_invI*(h*q-o*k)}if(this.m_limitState2==this.e_atUpperLimit){b=g.m_linearVelocity.x+-g.m_angularVelocity*a;f=g.m_linearVelocity.y+g.m_angularVelocity*l;k=-(this.m_u2.x*b+this.m_u2.y*f);f=-this.m_limitMass2*k;k=this.m_limitImpulse2;this.m_limitImpulse2=F.Max(0,this.m_limitImpulse2+f);f=this.m_limitImpulse2-
k;b=-f*this.m_u2.x;f=-f*this.m_u2.y;g.m_linearVelocity.x+=g.m_invMass*b;g.m_linearVelocity.y+=g.m_invMass*f;g.m_angularVelocity+=g.m_invI*(l*f-a*b)}};K.prototype.SolvePositionConstraints=function(){var c=this.m_bodyA,g=this.m_bodyB,k,h=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,o=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,q=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,l=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,a=0,b=0,f=0,m=0,p=k=0,D=0,B=0,O=p=B=k=p=k=0;if(this.m_state==
this.e_atUpperLimit){k=c.m_xf.R;a=this.m_localAnchor1.x-c.m_sweep.localCenter.x;b=this.m_localAnchor1.y-c.m_sweep.localCenter.y;p=k.col1.x*a+k.col2.x*b;b=k.col1.y*a+k.col2.y*b;a=p;k=g.m_xf.R;f=this.m_localAnchor2.x-g.m_sweep.localCenter.x;m=this.m_localAnchor2.y-g.m_sweep.localCenter.y;p=k.col1.x*f+k.col2.x*m;m=k.col1.y*f+k.col2.y*m;f=p;k=c.m_sweep.c.x+a;p=c.m_sweep.c.y+b;D=g.m_sweep.c.x+f;B=g.m_sweep.c.y+m;this.m_u1.Set(k-h,p-o);this.m_u2.Set(D-q,B-l);k=this.m_u1.Length();p=this.m_u2.Length();k>
L.b2_linearSlop?this.m_u1.Multiply(1/k):this.m_u1.SetZero();p>L.b2_linearSlop?this.m_u2.Multiply(1/p):this.m_u2.SetZero();k=this.m_constant-k-this.m_ratio*p;O=F.Max(O,-k);k=F.Clamp(k+L.b2_linearSlop,-L.b2_maxLinearCorrection,0);B=-this.m_pulleyMass*k;k=-B*this.m_u1.x;p=-B*this.m_u1.y;D=-this.m_ratio*B*this.m_u2.x;B=-this.m_ratio*B*this.m_u2.y;c.m_sweep.c.x+=c.m_invMass*k;c.m_sweep.c.y+=c.m_invMass*p;c.m_sweep.a+=c.m_invI*(a*p-b*k);g.m_sweep.c.x+=g.m_invMass*D;g.m_sweep.c.y+=g.m_invMass*B;g.m_sweep.a+=
g.m_invI*(f*B-m*D);c.SynchronizeTransform();g.SynchronizeTransform()}if(this.m_limitState1==this.e_atUpperLimit){k=c.m_xf.R;a=this.m_localAnchor1.x-c.m_sweep.localCenter.x;b=this.m_localAnchor1.y-c.m_sweep.localCenter.y;p=k.col1.x*a+k.col2.x*b;b=k.col1.y*a+k.col2.y*b;a=p;k=c.m_sweep.c.x+a;p=c.m_sweep.c.y+b;this.m_u1.Set(k-h,p-o);k=this.m_u1.Length();if(k>L.b2_linearSlop){this.m_u1.x*=1/k;this.m_u1.y*=1/k}else this.m_u1.SetZero();k=this.m_maxLength1-k;O=F.Max(O,-k);k=F.Clamp(k+L.b2_linearSlop,-L.b2_maxLinearCorrection,
0);B=-this.m_limitMass1*k;k=-B*this.m_u1.x;p=-B*this.m_u1.y;c.m_sweep.c.x+=c.m_invMass*k;c.m_sweep.c.y+=c.m_invMass*p;c.m_sweep.a+=c.m_invI*(a*p-b*k);c.SynchronizeTransform()}if(this.m_limitState2==this.e_atUpperLimit){k=g.m_xf.R;f=this.m_localAnchor2.x-g.m_sweep.localCenter.x;m=this.m_localAnchor2.y-g.m_sweep.localCenter.y;p=k.col1.x*f+k.col2.x*m;m=k.col1.y*f+k.col2.y*m;f=p;D=g.m_sweep.c.x+f;B=g.m_sweep.c.y+m;this.m_u2.Set(D-q,B-l);p=this.m_u2.Length();if(p>L.b2_linearSlop){this.m_u2.x*=1/p;this.m_u2.y*=
1/p}else this.m_u2.SetZero();k=this.m_maxLength2-p;O=F.Max(O,-k);k=F.Clamp(k+L.b2_linearSlop,-L.b2_maxLinearCorrection,0);B=-this.m_limitMass2*k;D=-B*this.m_u2.x;B=-B*this.m_u2.y;g.m_sweep.c.x+=g.m_invMass*D;g.m_sweep.c.y+=g.m_invMass*B;g.m_sweep.a+=g.m_invI*(f*B-m*D);g.SynchronizeTransform()}return O<L.b2_linearSlop};_A2J_postDefs.push(function(){Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength=2;Box2D.Dynamics.Joints.b2PulleyJoint.prototype.b2_minPulleyLength=Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength});
ba.inherit(Box2D.Dynamics.Joints.b2JointDef);ba.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;ba.b2PulleyJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.groundAnchorA=new G;this.groundAnchorB=new G;this.localAnchorA=new G;this.localAnchorB=new G};ba.prototype.b2PulleyJointDef=function(){this.__super.b2JointDef.call(this);this.type=Q.e_pulleyJoint;this.groundAnchorA.Set(-1,1);this.groundAnchorB.Set(1,1);this.localAnchorA.Set(-1,0);this.localAnchorB.Set(1,
0);this.maxLengthB=this.lengthB=this.maxLengthA=this.lengthA=0;this.ratio=1;this.collideConnected=true};ba.prototype.Initialize=function(c,g,k,h,o,q,l){if(l===undefined)l=0;this.bodyA=c;this.bodyB=g;this.groundAnchorA.SetV(k);this.groundAnchorB.SetV(h);this.localAnchorA=this.bodyA.GetLocalPoint(o);this.localAnchorB=this.bodyB.GetLocalPoint(q);c=o.x-k.x;k=o.y-k.y;this.lengthA=Math.sqrt(c*c+k*k);k=q.x-h.x;h=q.y-h.y;this.lengthB=Math.sqrt(k*k+h*h);this.ratio=l;l=this.lengthA+this.ratio*this.lengthB;
this.maxLengthA=l-this.ratio*K.b2_minPulleyLength;this.maxLengthB=(l-K.b2_minPulleyLength)/this.ratio};V.inherit(Box2D.Dynamics.Joints.b2Joint);V.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;V.b2RevoluteJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.K=new I;this.K1=new I;this.K2=new I;this.K3=new I;this.impulse3=new A;this.impulse2=new G;this.reduced=new G;this.m_localAnchor1=new G;this.m_localAnchor2=new G;this.m_impulse=new A;this.m_mass=new H};V.prototype.GetAnchorA=
function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};V.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};V.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*this.m_impulse.x,c*this.m_impulse.y)};V.prototype.GetReactionTorque=function(c){if(c===undefined)c=0;return c*this.m_impulse.z};V.prototype.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle};V.prototype.GetJointSpeed=
function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity};V.prototype.IsLimitEnabled=function(){return this.m_enableLimit};V.prototype.EnableLimit=function(c){this.m_enableLimit=c};V.prototype.GetLowerLimit=function(){return this.m_lowerAngle};V.prototype.GetUpperLimit=function(){return this.m_upperAngle};V.prototype.SetLimits=function(c,g){if(c===undefined)c=0;if(g===undefined)g=0;this.m_lowerAngle=c;this.m_upperAngle=g};V.prototype.IsMotorEnabled=function(){this.m_bodyA.SetAwake(true);
this.m_bodyB.SetAwake(true);return this.m_enableMotor};V.prototype.EnableMotor=function(c){this.m_enableMotor=c};V.prototype.SetMotorSpeed=function(c){if(c===undefined)c=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_motorSpeed=c};V.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};V.prototype.SetMaxMotorTorque=function(c){if(c===undefined)c=0;this.m_maxMotorTorque=c};V.prototype.GetMotorTorque=function(){return this.m_maxMotorTorque};V.prototype.b2RevoluteJoint=function(c){this.__super.b2Joint.call(this,
c);this.m_localAnchor1.SetV(c.localAnchorA);this.m_localAnchor2.SetV(c.localAnchorB);this.m_referenceAngle=c.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=0;this.m_lowerAngle=c.lowerAngle;this.m_upperAngle=c.upperAngle;this.m_maxMotorTorque=c.maxMotorTorque;this.m_motorSpeed=c.motorSpeed;this.m_enableLimit=c.enableLimit;this.m_enableMotor=c.enableMotor;this.m_limitState=this.e_inactiveLimit};V.prototype.InitVelocityConstraints=function(c){var g=this.m_bodyA,k=this.m_bodyB,h,o=0;h=g.m_xf.R;
var q=this.m_localAnchor1.x-g.m_sweep.localCenter.x,l=this.m_localAnchor1.y-g.m_sweep.localCenter.y;o=h.col1.x*q+h.col2.x*l;l=h.col1.y*q+h.col2.y*l;q=o;h=k.m_xf.R;var a=this.m_localAnchor2.x-k.m_sweep.localCenter.x,b=this.m_localAnchor2.y-k.m_sweep.localCenter.y;o=h.col1.x*a+h.col2.x*b;b=h.col1.y*a+h.col2.y*b;a=o;h=g.m_invMass;o=k.m_invMass;var f=g.m_invI,m=k.m_invI;this.m_mass.col1.x=h+o+l*l*f+b*b*m;this.m_mass.col2.x=-l*q*f-b*a*m;this.m_mass.col3.x=-l*f-b*m;this.m_mass.col1.y=this.m_mass.col2.x;
this.m_mass.col2.y=h+o+q*q*f+a*a*m;this.m_mass.col3.y=q*f+a*m;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=f+m;this.m_motorMass=1/(f+m);if(this.m_enableMotor==false)this.m_motorImpulse=0;if(this.m_enableLimit){var p=k.m_sweep.a-g.m_sweep.a-this.m_referenceAngle;if(F.Abs(this.m_upperAngle-this.m_lowerAngle)<2*L.b2_angularSlop)this.m_limitState=this.e_equalLimits;else if(p<=this.m_lowerAngle){if(this.m_limitState!=this.e_atLowerLimit)this.m_impulse.z=
0;this.m_limitState=this.e_atLowerLimit}else if(p>=this.m_upperAngle){if(this.m_limitState!=this.e_atUpperLimit)this.m_impulse.z=0;this.m_limitState=this.e_atUpperLimit}else{this.m_limitState=this.e_inactiveLimit;this.m_impulse.z=0}}else this.m_limitState=this.e_inactiveLimit;if(c.warmStarting){this.m_impulse.x*=c.dtRatio;this.m_impulse.y*=c.dtRatio;this.m_motorImpulse*=c.dtRatio;c=this.m_impulse.x;p=this.m_impulse.y;g.m_linearVelocity.x-=h*c;g.m_linearVelocity.y-=h*p;g.m_angularVelocity-=f*(q*p-
l*c+this.m_motorImpulse+this.m_impulse.z);k.m_linearVelocity.x+=o*c;k.m_linearVelocity.y+=o*p;k.m_angularVelocity+=m*(a*p-b*c+this.m_motorImpulse+this.m_impulse.z)}else{this.m_impulse.SetZero();this.m_motorImpulse=0}};V.prototype.SolveVelocityConstraints=function(c){var g=this.m_bodyA,k=this.m_bodyB,h=0,o=h=0,q=0,l=0,a=0,b=g.m_linearVelocity,f=g.m_angularVelocity,m=k.m_linearVelocity,p=k.m_angularVelocity,D=g.m_invMass,B=k.m_invMass,O=g.m_invI,W=k.m_invI;if(this.m_enableMotor&&this.m_limitState!=
this.e_equalLimits){o=this.m_motorMass*-(p-f-this.m_motorSpeed);q=this.m_motorImpulse;l=c.dt*this.m_maxMotorTorque;this.m_motorImpulse=F.Clamp(this.m_motorImpulse+o,-l,l);o=this.m_motorImpulse-q;f-=O*o;p+=W*o}if(this.m_enableLimit&&this.m_limitState!=this.e_inactiveLimit){c=g.m_xf.R;o=this.m_localAnchor1.x-g.m_sweep.localCenter.x;q=this.m_localAnchor1.y-g.m_sweep.localCenter.y;h=c.col1.x*o+c.col2.x*q;q=c.col1.y*o+c.col2.y*q;o=h;c=k.m_xf.R;l=this.m_localAnchor2.x-k.m_sweep.localCenter.x;a=this.m_localAnchor2.y-
k.m_sweep.localCenter.y;h=c.col1.x*l+c.col2.x*a;a=c.col1.y*l+c.col2.y*a;l=h;c=m.x+-p*a-b.x- -f*q;var ca=m.y+p*l-b.y-f*o;this.m_mass.Solve33(this.impulse3,-c,-ca,-(p-f));if(this.m_limitState==this.e_equalLimits)this.m_impulse.Add(this.impulse3);else if(this.m_limitState==this.e_atLowerLimit){h=this.m_impulse.z+this.impulse3.z;if(h<0){this.m_mass.Solve22(this.reduced,-c,-ca);this.impulse3.x=this.reduced.x;this.impulse3.y=this.reduced.y;this.impulse3.z=-this.m_impulse.z;this.m_impulse.x+=this.reduced.x;
this.m_impulse.y+=this.reduced.y;this.m_impulse.z=0}}else if(this.m_limitState==this.e_atUpperLimit){h=this.m_impulse.z+this.impulse3.z;if(h>0){this.m_mass.Solve22(this.reduced,-c,-ca);this.impulse3.x=this.reduced.x;this.impulse3.y=this.reduced.y;this.impulse3.z=-this.m_impulse.z;this.m_impulse.x+=this.reduced.x;this.m_impulse.y+=this.reduced.y;this.m_impulse.z=0}}b.x-=D*this.impulse3.x;b.y-=D*this.impulse3.y;f-=O*(o*this.impulse3.y-q*this.impulse3.x+this.impulse3.z);m.x+=B*this.impulse3.x;m.y+=B*
this.impulse3.y;p+=W*(l*this.impulse3.y-a*this.impulse3.x+this.impulse3.z)}else{c=g.m_xf.R;o=this.m_localAnchor1.x-g.m_sweep.localCenter.x;q=this.m_localAnchor1.y-g.m_sweep.localCenter.y;h=c.col1.x*o+c.col2.x*q;q=c.col1.y*o+c.col2.y*q;o=h;c=k.m_xf.R;l=this.m_localAnchor2.x-k.m_sweep.localCenter.x;a=this.m_localAnchor2.y-k.m_sweep.localCenter.y;h=c.col1.x*l+c.col2.x*a;a=c.col1.y*l+c.col2.y*a;l=h;this.m_mass.Solve22(this.impulse2,-(m.x+-p*a-b.x- -f*q),-(m.y+p*l-b.y-f*o));this.m_impulse.x+=this.impulse2.x;
this.m_impulse.y+=this.impulse2.y;b.x-=D*this.impulse2.x;b.y-=D*this.impulse2.y;f-=O*(o*this.impulse2.y-q*this.impulse2.x);m.x+=B*this.impulse2.x;m.y+=B*this.impulse2.y;p+=W*(l*this.impulse2.y-a*this.impulse2.x)}g.m_linearVelocity.SetV(b);g.m_angularVelocity=f;k.m_linearVelocity.SetV(m);k.m_angularVelocity=p};V.prototype.SolvePositionConstraints=function(){var c=0,g,k=this.m_bodyA,h=this.m_bodyB,o=0,q=g=0,l=0,a=0;if(this.m_enableLimit&&this.m_limitState!=this.e_inactiveLimit){c=h.m_sweep.a-k.m_sweep.a-
this.m_referenceAngle;var b=0;if(this.m_limitState==this.e_equalLimits){c=F.Clamp(c-this.m_lowerAngle,-L.b2_maxAngularCorrection,L.b2_maxAngularCorrection);b=-this.m_motorMass*c;o=F.Abs(c)}else if(this.m_limitState==this.e_atLowerLimit){c=c-this.m_lowerAngle;o=-c;c=F.Clamp(c+L.b2_angularSlop,-L.b2_maxAngularCorrection,0);b=-this.m_motorMass*c}else if(this.m_limitState==this.e_atUpperLimit){o=c=c-this.m_upperAngle;c=F.Clamp(c-L.b2_angularSlop,0,L.b2_maxAngularCorrection);b=-this.m_motorMass*c}k.m_sweep.a-=
k.m_invI*b;h.m_sweep.a+=h.m_invI*b;k.SynchronizeTransform();h.SynchronizeTransform()}g=k.m_xf.R;b=this.m_localAnchor1.x-k.m_sweep.localCenter.x;c=this.m_localAnchor1.y-k.m_sweep.localCenter.y;q=g.col1.x*b+g.col2.x*c;c=g.col1.y*b+g.col2.y*c;b=q;g=h.m_xf.R;var f=this.m_localAnchor2.x-h.m_sweep.localCenter.x,m=this.m_localAnchor2.y-h.m_sweep.localCenter.y;q=g.col1.x*f+g.col2.x*m;m=g.col1.y*f+g.col2.y*m;f=q;l=h.m_sweep.c.x+f-k.m_sweep.c.x-b;a=h.m_sweep.c.y+m-k.m_sweep.c.y-c;var p=l*l+a*a;g=Math.sqrt(p);
q=k.m_invMass;var D=h.m_invMass,B=k.m_invI,O=h.m_invI,W=10*L.b2_linearSlop;if(p>W*W){p=1/(q+D);l=p*-l;a=p*-a;k.m_sweep.c.x-=0.5*q*l;k.m_sweep.c.y-=0.5*q*a;h.m_sweep.c.x+=0.5*D*l;h.m_sweep.c.y+=0.5*D*a;l=h.m_sweep.c.x+f-k.m_sweep.c.x-b;a=h.m_sweep.c.y+m-k.m_sweep.c.y-c}this.K1.col1.x=q+D;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=q+D;this.K2.col1.x=B*c*c;this.K2.col2.x=-B*b*c;this.K2.col1.y=-B*b*c;this.K2.col2.y=B*b*b;this.K3.col1.x=O*m*m;this.K3.col2.x=-O*f*m;this.K3.col1.y=-O*f*m;this.K3.col2.y=
O*f*f;this.K.SetM(this.K1);this.K.AddM(this.K2);this.K.AddM(this.K3);this.K.Solve(V.tImpulse,-l,-a);l=V.tImpulse.x;a=V.tImpulse.y;k.m_sweep.c.x-=k.m_invMass*l;k.m_sweep.c.y-=k.m_invMass*a;k.m_sweep.a-=k.m_invI*(b*a-c*l);h.m_sweep.c.x+=h.m_invMass*l;h.m_sweep.c.y+=h.m_invMass*a;h.m_sweep.a+=h.m_invI*(f*a-m*l);k.SynchronizeTransform();h.SynchronizeTransform();return g<=L.b2_linearSlop&&o<=L.b2_angularSlop};_A2J_postDefs.push(function(){Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse=new G;Box2D.Dynamics.Joints.b2RevoluteJoint.prototype.tImpulse=
Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse});Z.inherit(Box2D.Dynamics.Joints.b2JointDef);Z.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;Z.b2RevoluteJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new G;this.localAnchorB=new G};Z.prototype.b2RevoluteJointDef=function(){this.__super.b2JointDef.call(this);this.type=Q.e_revoluteJoint;this.localAnchorA.Set(0,0);this.localAnchorB.Set(0,0);this.motorSpeed=this.maxMotorTorque=this.upperAngle=
this.lowerAngle=this.referenceAngle=0;this.enableMotor=this.enableLimit=false};Z.prototype.Initialize=function(c,g,k){this.bodyA=c;this.bodyB=g;this.localAnchorA=this.bodyA.GetLocalPoint(k);this.localAnchorB=this.bodyB.GetLocalPoint(k);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};ga.inherit(Box2D.Dynamics.Joints.b2Joint);ga.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;ga.b2WeldJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchorA=
new G;this.m_localAnchorB=new G;this.m_impulse=new A;this.m_mass=new H};ga.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};ga.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};ga.prototype.GetReactionForce=function(c){if(c===undefined)c=0;return new G(c*this.m_impulse.x,c*this.m_impulse.y)};ga.prototype.GetReactionTorque=function(c){if(c===undefined)c=0;return c*this.m_impulse.z};ga.prototype.b2WeldJoint=function(c){this.__super.b2Joint.call(this,
c);this.m_localAnchorA.SetV(c.localAnchorA);this.m_localAnchorB.SetV(c.localAnchorB);this.m_referenceAngle=c.referenceAngle;this.m_impulse.SetZero();this.m_mass=new H};ga.prototype.InitVelocityConstraints=function(c){var g,k=0,h=this.m_bodyA,o=this.m_bodyB;g=h.m_xf.R;var q=this.m_localAnchorA.x-h.m_sweep.localCenter.x,l=this.m_localAnchorA.y-h.m_sweep.localCenter.y;k=g.col1.x*q+g.col2.x*l;l=g.col1.y*q+g.col2.y*l;q=k;g=o.m_xf.R;var a=this.m_localAnchorB.x-o.m_sweep.localCenter.x,b=this.m_localAnchorB.y-
o.m_sweep.localCenter.y;k=g.col1.x*a+g.col2.x*b;b=g.col1.y*a+g.col2.y*b;a=k;g=h.m_invMass;k=o.m_invMass;var f=h.m_invI,m=o.m_invI;this.m_mass.col1.x=g+k+l*l*f+b*b*m;this.m_mass.col2.x=-l*q*f-b*a*m;this.m_mass.col3.x=-l*f-b*m;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=g+k+q*q*f+a*a*m;this.m_mass.col3.y=q*f+a*m;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=f+m;if(c.warmStarting){this.m_impulse.x*=c.dtRatio;this.m_impulse.y*=c.dtRatio;this.m_impulse.z*=
c.dtRatio;h.m_linearVelocity.x-=g*this.m_impulse.x;h.m_linearVelocity.y-=g*this.m_impulse.y;h.m_angularVelocity-=f*(q*this.m_impulse.y-l*this.m_impulse.x+this.m_impulse.z);o.m_linearVelocity.x+=k*this.m_impulse.x;o.m_linearVelocity.y+=k*this.m_impulse.y;o.m_angularVelocity+=m*(a*this.m_impulse.y-b*this.m_impulse.x+this.m_impulse.z)}else this.m_impulse.SetZero()};ga.prototype.SolveVelocityConstraints=function(){var c,g=0,k=this.m_bodyA,h=this.m_bodyB,o=k.m_linearVelocity,q=k.m_angularVelocity,l=h.m_linearVelocity,
a=h.m_angularVelocity,b=k.m_invMass,f=h.m_invMass,m=k.m_invI,p=h.m_invI;c=k.m_xf.R;var D=this.m_localAnchorA.x-k.m_sweep.localCenter.x,B=this.m_localAnchorA.y-k.m_sweep.localCenter.y;g=c.col1.x*D+c.col2.x*B;B=c.col1.y*D+c.col2.y*B;D=g;c=h.m_xf.R;var O=this.m_localAnchorB.x-h.m_sweep.localCenter.x,W=this.m_localAnchorB.y-h.m_sweep.localCenter.y;g=c.col1.x*O+c.col2.x*W;W=c.col1.y*O+c.col2.y*W;O=g;c=l.x-a*W-o.x+q*B;g=l.y+a*O-o.y-q*D;var ca=a-q,d=new A;this.m_mass.Solve33(d,-c,-g,-ca);this.m_impulse.Add(d);
o.x-=b*d.x;o.y-=b*d.y;q-=m*(D*d.y-B*d.x+d.z);l.x+=f*d.x;l.y+=f*d.y;a+=p*(O*d.y-W*d.x+d.z);k.m_angularVelocity=q;h.m_angularVelocity=a};ga.prototype.SolvePositionConstraints=function(){var c,g=0,k=this.m_bodyA,h=this.m_bodyB;c=k.m_xf.R;var o=this.m_localAnchorA.x-k.m_sweep.localCenter.x,q=this.m_localAnchorA.y-k.m_sweep.localCenter.y;g=c.col1.x*o+c.col2.x*q;q=c.col1.y*o+c.col2.y*q;o=g;c=h.m_xf.R;var l=this.m_localAnchorB.x-h.m_sweep.localCenter.x,a=this.m_localAnchorB.y-h.m_sweep.localCenter.y;g=c.col1.x*
l+c.col2.x*a;a=c.col1.y*l+c.col2.y*a;l=g;c=k.m_invMass;g=h.m_invMass;var b=k.m_invI,f=h.m_invI,m=h.m_sweep.c.x+l-k.m_sweep.c.x-o,p=h.m_sweep.c.y+a-k.m_sweep.c.y-q,D=h.m_sweep.a-k.m_sweep.a-this.m_referenceAngle,B=10*L.b2_linearSlop,O=Math.sqrt(m*m+p*p),W=F.Abs(D);if(O>B){b*=1;f*=1}this.m_mass.col1.x=c+g+q*q*b+a*a*f;this.m_mass.col2.x=-q*o*b-a*l*f;this.m_mass.col3.x=-q*b-a*f;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=c+g+o*o*b+l*l*f;this.m_mass.col3.y=o*b+l*f;this.m_mass.col1.z=this.m_mass.col3.x;
this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=b+f;B=new A;this.m_mass.Solve33(B,-m,-p,-D);k.m_sweep.c.x-=c*B.x;k.m_sweep.c.y-=c*B.y;k.m_sweep.a-=b*(o*B.y-q*B.x+B.z);h.m_sweep.c.x+=g*B.x;h.m_sweep.c.y+=g*B.y;h.m_sweep.a+=f*(l*B.y-a*B.x+B.z);k.SynchronizeTransform();h.SynchronizeTransform();return O<=L.b2_linearSlop&&W<=L.b2_angularSlop};fa.inherit(Box2D.Dynamics.Joints.b2JointDef);fa.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;fa.b2WeldJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,
arguments);this.localAnchorA=new G;this.localAnchorB=new G};fa.prototype.b2WeldJointDef=function(){this.__super.b2JointDef.call(this);this.type=Q.e_weldJoint;this.referenceAngle=0};fa.prototype.Initialize=function(c,g,k){this.bodyA=c;this.bodyB=g;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(k));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(k));this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}})();Vector_a2j_Number=a2j.NVector;for(var i=0;i<_A2J_postDefs.length;++i)_A2J_postDefs[i]();
(function(){function L(){L.b2DebugDraw.apply(this,arguments);this.constructor===L&&this.b2DebugDraw.apply(this,arguments)}Box2D.Dynamics.b2DebugDraw=L})();_A2J_postDefs=[];
(function(){var L=Box2D.Dynamics.b2DebugDraw;L.b2DebugDraw=function(){this.m_xformScale=this.m_fillAlpha=this.m_alpha=this.m_lineThickness=this.m_drawScale=1;var I=this;this.m_sprite={graphics:{clear:function(){I.m_ctx.clearRect(0,0,I.m_ctx.canvas.width,I.m_ctx.canvas.height)}}}};L.prototype._color=function(I,H){return"rgba("+((I&16711680)>>16)+","+((I&65280)>>8)+","+(I&255)+","+H+")"};L.prototype.b2DebugDraw=function(){this.m_drawFlags=0};L.prototype.SetFlags=function(I){if(I===undefined)I=0;this.m_drawFlags=
I};L.prototype.GetFlags=function(){return this.m_drawFlags};L.prototype.AppendFlags=function(I){if(I===undefined)I=0;this.m_drawFlags|=I};L.prototype.ClearFlags=function(I){if(I===undefined)I=0;this.m_drawFlags&=~I};L.prototype.SetSprite=function(I){this.m_ctx=I};L.prototype.GetSprite=function(){return this.m_ctx};L.prototype.SetDrawScale=function(I){if(I===undefined)I=0;this.m_drawScale=I};L.prototype.GetDrawScale=function(){return this.m_drawScale};L.prototype.SetLineThickness=function(I){if(I===
undefined)I=0;this.m_lineThickness=I;this.m_ctx.strokeWidth=I};L.prototype.GetLineThickness=function(){return this.m_lineThickness};L.prototype.SetAlpha=function(I){if(I===undefined)I=0;this.m_alpha=I};L.prototype.GetAlpha=function(){return this.m_alpha};L.prototype.SetFillAlpha=function(I){if(I===undefined)I=0;this.m_fillAlpha=I};L.prototype.GetFillAlpha=function(){return this.m_fillAlpha};L.prototype.SetXFormScale=function(I){if(I===undefined)I=0;this.m_xformScale=I};L.prototype.GetXFormScale=function(){return this.m_xformScale};
L.prototype.DrawPolygon=function(I,H,F){if(H){var G=this.m_ctx,A=this.m_drawScale;G.beginPath();G.strokeStyle=this._color(F.color,this.m_alpha);G.moveTo(I[0].x*A,I[0].y*A);for(F=1;F<H;F++)G.lineTo(I[F].x*A,I[F].y*A);G.lineTo(I[0].x*A,I[0].y*A);G.closePath();G.stroke()}};L.prototype.DrawSolidPolygon=function(I,H,F){if(H){var G=this.m_ctx,A=this.m_drawScale;G.beginPath();G.strokeStyle=this._color(F.color,this.m_alpha);G.fillStyle=this._color(F.color,this.m_fillAlpha);G.moveTo(I[0].x*A,I[0].y*A);for(F=
1;F<H;F++)G.lineTo(I[F].x*A,I[F].y*A);G.lineTo(I[0].x*A,I[0].y*A);G.closePath();G.fill();G.stroke()}};L.prototype.DrawCircle=function(I,H,F){if(H){var G=this.m_ctx,A=this.m_drawScale;G.beginPath();G.strokeStyle=this._color(F.color,this.m_alpha);G.arc(I.x*A,I.y*A,H*A,0,Math.PI*2,true);G.closePath();G.stroke()}};L.prototype.DrawSolidCircle=function(I,H,F,G){if(H){var A=this.m_ctx,N=this.m_drawScale,s=I.x*N,C=I.y*N;A.moveTo(0,0);A.beginPath();A.strokeStyle=this._color(G.color,this.m_alpha);A.fillStyle=
this._color(G.color,this.m_fillAlpha);A.arc(s,C,H*N,0,Math.PI*2,true);A.moveTo(s,C);A.lineTo((I.x+F.x*H)*N,(I.y+F.y*H)*N);A.closePath();A.fill();A.stroke()}};L.prototype.DrawSegment=function(I,H,F){var G=this.m_ctx,A=this.m_drawScale;G.strokeStyle=this._color(F.color,this.m_alpha);G.beginPath();G.moveTo(I.x*A,I.y*A);G.lineTo(H.x*A,H.y*A);G.closePath();G.stroke()};L.prototype.DrawTransform=function(I){var H=this.m_ctx,F=this.m_drawScale;H.beginPath();H.strokeStyle=this._color(16711680,this.m_alpha);
H.moveTo(I.position.x*F,I.position.y*F);H.lineTo((I.position.x+this.m_xformScale*I.R.col1.x)*F,(I.position.y+this.m_xformScale*I.R.col1.y)*F);H.strokeStyle=this._color(65280,this.m_alpha);H.moveTo(I.position.x*F,I.position.y*F);H.lineTo((I.position.x+this.m_xformScale*I.R.col2.x)*F,(I.position.y+this.m_xformScale*I.R.col2.y)*F);H.closePath();H.stroke()};_A2J_postDefs.push(function(){Box2D.Dynamics.b2DebugDraw.e_shapeBit=1;Box2D.Dynamics.b2DebugDraw.prototype.e_shapeBit=Box2D.Dynamics.b2DebugDraw.e_shapeBit;
Box2D.Dynamics.b2DebugDraw.e_jointBit=2;Box2D.Dynamics.b2DebugDraw.prototype.e_jointBit=Box2D.Dynamics.b2DebugDraw.e_jointBit;Box2D.Dynamics.b2DebugDraw.e_aabbBit=4;Box2D.Dynamics.b2DebugDraw.prototype.e_aabbBit=Box2D.Dynamics.b2DebugDraw.e_aabbBit;Box2D.Dynamics.b2DebugDraw.e_pairBit=8;Box2D.Dynamics.b2DebugDraw.prototype.e_pairBit=Box2D.Dynamics.b2DebugDraw.e_pairBit;Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit=16;Box2D.Dynamics.b2DebugDraw.prototype.e_centerOfMassBit=Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit;
Box2D.Dynamics.b2DebugDraw.e_controllerBit=32;Box2D.Dynamics.b2DebugDraw.prototype.e_controllerBit=Box2D.Dynamics.b2DebugDraw.e_controllerBit})})();for(i=0;i<_A2J_postDefs.length;++i)_A2J_postDefs[i]();