var b2Settings=Class.create();b2Settings.prototype={initialize:function(){}},b2Settings.USHRT_MAX=65535,b2Settings.b2_pi=Math.PI,b2Settings.b2_massUnitsPerKilogram=1,b2Settings.b2_timeUnitsPerSecond=1,b2Settings.b2_lengthUnitsPerMeter=30,b2Settings.b2_maxManifoldPoints=2,b2Settings.b2_maxShapesPerBody=64,b2Settings.b2_maxPolyVertices=8,b2Settings.b2_maxProxies=1024,b2Settings.b2_maxPairs=8*b2Settings.b2_maxProxies,b2Settings.b2_linearSlop=.005*b2Settings.b2_lengthUnitsPerMeter,b2Settings.b2_angularSlop=2/180*b2Settings.b2_pi,b2Settings.b2_velocityThreshold=1*b2Settings.b2_lengthUnitsPerMeter/b2Settings.b2_timeUnitsPerSecond,b2Settings.b2_maxLinearCorrection=.2*b2Settings.b2_lengthUnitsPerMeter,b2Settings.b2_maxAngularCorrection=8/180*b2Settings.b2_pi,b2Settings.b2_contactBaumgarte=.2,b2Settings.b2_timeToSleep=.5*b2Settings.b2_timeUnitsPerSecond,b2Settings.b2_linearSleepTolerance=.01*b2Settings.b2_lengthUnitsPerMeter/b2Settings.b2_timeUnitsPerSecond,b2Settings.b2_angularSleepTolerance=2/180/b2Settings.b2_timeUnitsPerSecond,b2Settings.b2Assert=function(a){a||undefined.x++};var b2Vec2=Class.create();b2Vec2.prototype={initialize:function(x_,y_){this.x=x_,this.y=y_},SetZero:function(){this.x=0,this.y=0},Set:function(x_,y_){this.x=x_,this.y=y_},SetV:function(v){this.x=v.x,this.y=v.y},Negative:function(){return new b2Vec2(-this.x,-this.y)},Copy:function(){return new b2Vec2(this.x,this.y)},Add:function(v){this.x+=v.x,this.y+=v.y},Subtract:function(v){this.x-=v.x,this.y-=v.y},Multiply:function(a){this.x*=a,this.y*=a},MulM:function(A){var tX=this.x;this.x=A.col1.x*tX+A.col2.x*this.y,this.y=A.col1.y*tX+A.col2.y*this.y},MulTM:function(A){var tX=b2Math.b2Dot(this,A.col1);this.y=b2Math.b2Dot(this,A.col2),this.x=tX},CrossVF:function(s){var tX=this.x;this.x=s*this.y,this.y=-s*tX},CrossFV:function(s){var tX=this.x;this.x=-s*this.y,this.y=s*tX},MinV:function(b){this.x=this.xb.x?this.x:b.x,this.y=this.y>b.y?this.y:b.y},Abs:function(){this.x=Math.abs(this.x),this.y=Math.abs(this.y)},Length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},Normalize:function(){var length=this.Length();if(length0?a:-a},b2Math.b2AbsV=function(a){return new b2Vec2(b2Math.b2Abs(a.x),b2Math.b2Abs(a.y))},b2Math.b2AbsM=function(A){return new b2Mat22(0,b2Math.b2AbsV(A.col1),b2Math.b2AbsV(A.col2))},b2Math.b2Min=function(a,b){return ab?a:b},b2Math.b2MaxV=function(a,b){return new b2Vec2(b2Math.b2Max(a.x,b.x),b2Math.b2Max(a.y,b.y))},b2Math.b2Clamp=function(a,low,high){return b2Math.b2Max(low,b2Math.b2Min(a,high))},b2Math.b2ClampV=function(a,low,high){return b2Math.b2MaxV(low,b2Math.b2MinV(a,high))},b2Math.b2Swap=function(a,b){var tmp=a[0];a[0]=b[0],b[0]=tmp},b2Math.b2Random=function(){return 2*Math.random()-1},b2Math.b2NextPowerOfTwo=function(x){return x|=x>>1&2147483647,x|=x>>2&1073741823,x|=x>>4&268435455,x|=x>>8&16777215,(x|=x>>16&65535)+1},b2Math.b2IsPowerOfTwo=function(x){return x>0&&0==(x&x-1)},b2Math.tempVec2=new b2Vec2,b2Math.tempVec3=new b2Vec2,b2Math.tempVec4=new b2Vec2,b2Math.tempVec5=new b2Vec2,b2Math.tempMat=new b2Mat22;var b2AABB=Class.create();b2AABB.prototype={IsValid:function(){var dX=this.maxVertex.x,dY=this.maxVertex.y;dX=this.maxVertex.x,dY=this.maxVertex.y,dX-=this.minVertex.x,dY-=this.minVertex.y;var valid=dX>=0&&dY>=0;return valid=valid&&this.minVertex.IsValid()&&this.maxVertex.IsValid()},minVertex:new b2Vec2,maxVertex:new b2Vec2,initialize:function(){this.minVertex=new b2Vec2,this.maxVertex=new b2Vec2}};var b2Bound=Class.create();b2Bound.prototype={IsLower:function(){return 0==(1&this.value)},IsUpper:function(){return 1==(1&this.value)},Swap:function(b){var tempValue=this.value,tempProxyId=this.proxyId,tempStabbingCount=this.stabbingCount;this.value=b.value,this.proxyId=b.proxyId,this.stabbingCount=b.stabbingCount,b.value=tempValue,b.proxyId=tempProxyId,b.stabbingCount=tempStabbingCount},value:0,proxyId:0,stabbingCount:0,initialize:function(){}};var b2BoundValues=Class.create();b2BoundValues.prototype={lowerValues:[0,0],upperValues:[0,0],initialize:function(){this.lowerValues=[0,0],this.upperValues=[0,0]}};var b2Pair=Class.create();b2Pair.prototype={SetBuffered:function(){this.status|=b2Pair.e_pairBuffered},ClearBuffered:function(){this.status&=~b2Pair.e_pairBuffered},IsBuffered:function(){return(this.status&b2Pair.e_pairBuffered)==b2Pair.e_pairBuffered},SetRemoved:function(){this.status|=b2Pair.e_pairRemoved},ClearRemoved:function(){this.status&=~b2Pair.e_pairRemoved},IsRemoved:function(){return(this.status&b2Pair.e_pairRemoved)==b2Pair.e_pairRemoved},SetFinal:function(){this.status|=b2Pair.e_pairFinal},IsFinal:function(){return(this.status&b2Pair.e_pairFinal)==b2Pair.e_pairFinal},userData:null,proxyId1:0,proxyId2:0,next:0,status:0,initialize:function(){}},b2Pair.b2_nullPair=b2Settings.USHRT_MAX,b2Pair.b2_nullProxy=b2Settings.USHRT_MAX,b2Pair.b2_tableCapacity=b2Settings.b2_maxPairs,b2Pair.b2_tableMask=b2Pair.b2_tableCapacity-1,b2Pair.e_pairBuffered=1,b2Pair.e_pairRemoved=2,b2Pair.e_pairFinal=4;var b2PairCallback=Class.create();b2PairCallback.prototype={PairAdded:function(proxyUserData1,proxyUserData2){return null},PairRemoved:function(proxyUserData1,proxyUserData2,pairUserData){},initialize:function(){}};var b2BufferedPair=Class.create();b2BufferedPair.prototype={proxyId1:0,proxyId2:0,initialize:function(){}};var b2PairManager=Class.create();b2PairManager.prototype={initialize:function(){var i=0;for(this.m_hashTable=new Array(b2Pair.b2_tableCapacity),i=0;iproxyId2){var temp=proxyId1;proxyId1=proxyId2,proxyId2=temp}var hash=b2PairManager.Hash(proxyId1,proxyId2)&b2Pair.b2_tableMask,pair=pair=this.FindHash(proxyId1,proxyId2,hash);if(null!=pair)return pair;var pIndex=this.m_freePair;return pair=this.m_pairs[pIndex],this.m_freePair=pair.next,pair.proxyId1=proxyId1,pair.proxyId2=proxyId2,pair.status=0,pair.userData=null,pair.next=this.m_hashTable[hash],this.m_hashTable[hash]=pIndex,++this.m_pairCount,pair},RemovePair:function(proxyId1,proxyId2){if(proxyId1>proxyId2){var temp=proxyId1;proxyId1=proxyId2,proxyId2=temp}for(var hash=b2PairManager.Hash(proxyId1,proxyId2)&b2Pair.b2_tableMask,node=this.m_hashTable[hash],pNode=null;node!=b2Pair.b2_nullPair;){if(b2PairManager.Equals(this.m_pairs[node],proxyId1,proxyId2)){var index=node;pNode?pNode.next=this.m_pairs[node].next:this.m_hashTable[hash]=this.m_pairs[node].next;var pair=this.m_pairs[index],userData=pair.userData;return pair.next=this.m_freePair,pair.proxyId1=b2Pair.b2_nullProxy,pair.proxyId2=b2Pair.b2_nullProxy,pair.userData=null,pair.status=0,this.m_freePair=index,--this.m_pairCount,userData}node=(pNode=this.m_pairs[node]).next}return null},Find:function(proxyId1,proxyId2){if(proxyId1>proxyId2){var temp=proxyId1;proxyId1=proxyId2,proxyId2=temp}var hash=b2PairManager.Hash(proxyId1,proxyId2)&b2Pair.b2_tableMask;return this.FindHash(proxyId1,proxyId2,hash)},FindHash:function(proxyId1,proxyId2,hash){for(var index=this.m_hashTable[hash];index!=b2Pair.b2_nullPair&&0==b2PairManager.Equals(this.m_pairs[index],proxyId1,proxyId2);)index=this.m_pairs[index].next;return index==b2Pair.b2_nullPair?null:this.m_pairs[index]},ValidateBuffer:function(){},ValidateTable:function(){},m_broadPhase:null,m_callback:null,m_pairs:null,m_freePair:0,m_pairCount:0,m_pairBuffer:null,m_pairBufferCount:0,m_hashTable:null},b2PairManager.Hash=function(proxyId1,proxyId2){var key=proxyId2<<16&4294901760|proxyId1;return key=~key+(key<<15&4294934528),key^=key>>12&1048575,key+=key<<2&4294967292,key^=key>>4&268435455,key*=2057,key^=key>>16&65535},b2PairManager.Equals=function(pair,proxyId1,proxyId2){return pair.proxyId1==proxyId1&&pair.proxyId2==proxyId2},b2PairManager.EqualsPair=function(pair1,pair2){return pair1.proxyId1==pair2.proxyId1&&pair1.proxyId2==pair2.proxyId2};var b2BroadPhase=Class.create();b2BroadPhase.prototype={initialize:function(worldAABB,callback){this.m_pairManager=new b2PairManager,this.m_proxyPool=new Array(b2Settings.b2_maxPairs),this.m_bounds=new Array(2*b2Settings.b2_maxProxies),this.m_queryResults=new Array(b2Settings.b2_maxProxies),this.m_quantizationFactor=new b2Vec2;var i=0;for(this.m_pairManager.Initialize(this,callback),this.m_worldAABB=worldAABB,this.m_proxyCount=0,i=0;i0&&lowerValue0)for(index=upperIndex;index0)for(index=lowerIndex;index0&&upperValuebounds[p2.upperBounds[axis]].value)return!1;if(bounds[p1.upperBounds[axis]].valuebounds[p.upperBounds[axis]].value)return!1;if(b.upperValues[axis]0)for(var i=lowerQuery-1,s=bounds[i].stabbingCount;s;){if(bounds[i].IsLower())lowerQuery<=this.m_proxyPool[bounds[i].proxyId].upperBounds[axis]&&(this.IncrementOverlapCount(bounds[i].proxyId),--s);--i}lowerQueryOut[0]=lowerQuery,upperQueryOut[0]=upperQuery},IncrementOverlapCount:function(proxyId){var proxy=this.m_proxyPool[proxyId];proxy.timeStampvalue)high=mid-1;else{if(!(bounds[mid].value0?vIn[0].id:vIn[1].id,++numOut}return numOut},b2Collision.EdgeSeparation=function(poly1,edge1,poly2){var vert1s=poly1.m_vertices,count2=poly2.m_vertexCount,vert2s=poly2.m_vertices,normalX=poly1.m_normals[edge1].x,normalY=poly1.m_normals[edge1].y,tX=normalX,tMat=poly1.m_R,normalLocal2X=normalX=tMat.col1.x*tX+tMat.col2.x*normalY,normalLocal2Y=normalY=tMat.col1.y*tX+tMat.col2.y*normalY;tX=normalLocal2X*(tMat=poly2.m_R).col1.x+normalLocal2Y*tMat.col1.y,normalLocal2Y=normalLocal2X*tMat.col2.x+normalLocal2Y*tMat.col2.y,normalLocal2X=tX;for(var vertexIndex2=0,minDot=Number.MAX_VALUE,i=0;imaxDot&&(maxDot=dot,edge=i)}var s=b2Collision.EdgeSeparation(poly1,edge,poly2);if(s>0&&0==conservative)return s;var prevEdge=edge-1>=0?edge-1:count1-1,sPrev=b2Collision.EdgeSeparation(poly1,prevEdge,poly2);if(sPrev>0&&0==conservative)return sPrev;var nextEdge=edge+10&&0==conservative)return sNext;var bestSeparation,bestEdge=0,increment=0;if(sPrev>s&&sPrev>sNext)increment=-1,bestEdge=prevEdge,bestSeparation=sPrev;else{if(!(sNext>s))return edgeIndex[0]=edge,s;increment=1,bestEdge=nextEdge,bestSeparation=sNext}for(;;){if(edge=-1==increment?bestEdge-1>=0?bestEdge-1:count1-1:bestEdge+10&&0==conservative)return s;if(!(s>bestSeparation))break;bestEdge=edge,bestSeparation=s}return edgeIndex[0]=bestEdge,bestSeparation},b2Collision.FindIncidentEdge=function(c,poly1,edge1,poly2){var count1=poly1.m_vertexCount,vert1s=poly1.m_vertices,count2=poly2.m_vertexCount,vert2s=poly2.m_vertices,vertex11=edge1,tVec=vert1s[edge1+1==count1?0:edge1+1],normal1Local1X=tVec.x,normal1Local1Y=tVec.y,tX=normal1Local1X-=(tVec=vert1s[vertex11]).x;normal1Local1X=normal1Local1Y-=tVec.y,normal1Local1Y=-tX;var invLength=1/Math.sqrt(normal1Local1X*normal1Local1X+normal1Local1Y*normal1Local1Y),normal1X=normal1Local1X*=invLength,normal1Y=normal1Local1Y*=invLength;tX=normal1X;var tMat=poly1.m_R,normal1Local2X=normal1X=tMat.col1.x*tX+tMat.col2.x*normal1Y,normal1Local2Y=normal1Y=tMat.col1.y*tX+tMat.col2.y*normal1Y;tX=normal1Local2X*(tMat=poly2.m_R).col1.x+normal1Local2Y*tMat.col1.y,normal1Local2Y=normal1Local2X*tMat.col2.x+normal1Local2Y*tMat.col2.y,normal1Local2X=tX;for(var tClip,vertex21=0,vertex22=0,minDot=Number.MAX_VALUE,i=0;i0&&0==conservative)){var edgeB=0,edgeBOut=[edgeB],separationB=b2Collision.FindMaxSeparation(edgeBOut,polyB,polyA,conservative);if(edgeB=edgeBOut[0],!(separationB>0&&0==conservative)){var poly1,poly2,edge1=0,flip=0;separationB>.98*separationA+.001?(poly1=polyB,poly2=polyA,edge1=edgeB,flip=1):(poly1=polyA,poly2=polyB,edge1=edgeA,flip=0);var incidentEdge=[new ClipVertex,new ClipVertex];b2Collision.FindIncidentEdge(incidentEdge,poly1,edge1,poly2);var count1=poly1.m_vertexCount,vert1s=poly1.m_vertices,v11=vert1s[edge1],v12=edge1+1radiusSum*radiusSum&&0==conservative)){var separation;if(distSqrradius)return;s>separation&&(separation=s,normalIndex=i)}if(separationradius)return;return manifold.pointCount=1,manifold.normal.Set(tMat.col1.x*dX+tMat.col2.x*dY,tMat.col1.y*dX+tMat.col2.y*dY),(tPoint=manifold.points[0]).id.features.incidentEdge=b2Collision.b2_nullFeature,tPoint.id.features.incidentVertex=vertIndex1,tPoint.id.features.referenceFace=b2Collision.b2_nullFeature,tPoint.id.features.flip=0,tPoint.position.x=circle.m_position.x-radius*manifold.normal.x,tPoint.position.y=circle.m_position.y-radius*manifold.normal.y,void(tPoint.separation=dist-radius)}var pX,pY,u=(xLocalX-poly.m_vertices[vertIndex1].x)*eX+(xLocalY-poly.m_vertices[vertIndex1].y)*eY;(tPoint=manifold.points[0]).id.features.incidentEdge=b2Collision.b2_nullFeature,tPoint.id.features.incidentVertex=b2Collision.b2_nullFeature,tPoint.id.features.referenceFace=b2Collision.b2_nullFeature,tPoint.id.features.flip=0,u<=0?(pX=poly.m_vertices[vertIndex1].x,pY=poly.m_vertices[vertIndex1].y,tPoint.id.features.incidentVertex=vertIndex1):u>=length?(pX=poly.m_vertices[vertIndex2].x,pY=poly.m_vertices[vertIndex2].y,tPoint.id.features.incidentVertex=vertIndex2):(pX=eX*u+poly.m_vertices[vertIndex1].x,pY=eY*u+poly.m_vertices[vertIndex1].y,tPoint.id.features.incidentEdge=vertIndex1),dX=xLocalX-pX,dY=xLocalY-pY,dX/=dist=Math.sqrt(dX*dX+dY*dY),dY/=dist,dist>radius||(manifold.pointCount=1,manifold.normal.Set(tMat.col1.x*dX+tMat.col2.x*dY,tMat.col1.y*dX+tMat.col2.y*dY),tPoint.position.x=circle.m_position.x-radius*manifold.normal.x,tPoint.position.y=circle.m_position.y-radius*manifold.normal.y,tPoint.separation=dist-radius)},b2Collision.b2TestOverlap=function(a,b){var t1=b.minVertex,t2=a.maxVertex,d1X=t1.x-t2.x,d1Y=t1.y-t2.y;t1=a.minVertex,t2=b.maxVertex;var d2X=t1.x-t2.x,d2Y=t1.y-t2.y;return!(d1X>0||d1Y>0)&&!(d2X>0||d2Y>0)};var Features=Class.create();Features.prototype={set_referenceFace:function(value){this._referenceFace=value,this._m_id._key=4294967040&this._m_id._key|255&this._referenceFace},get_referenceFace:function(){return this._referenceFace},_referenceFace:0,set_incidentEdge:function(value){this._incidentEdge=value,this._m_id._key=4294902015&this._m_id._key|this._incidentEdge<<8&65280},get_incidentEdge:function(){return this._incidentEdge},_incidentEdge:0,set_incidentVertex:function(value){this._incidentVertex=value,this._m_id._key=4278255615&this._m_id._key|this._incidentVertex<<16&16711680},get_incidentVertex:function(){return this._incidentVertex},_incidentVertex:0,set_flip:function(value){this._flip=value,this._m_id._key=16777215&this._m_id._key|this._flip<<24&4278190080},get_flip:function(){return this._flip},_flip:0,_m_id:null,initialize:function(){}};var b2ContactID=Class.create();b2ContactID.prototype={initialize:function(){this.features=new Features,this.features._m_id=this},Set:function(id){this.set_key(id._key)},Copy:function(){var id=new b2ContactID;return id.set_key(this._key),id},get_key:function(){return this._key},set_key:function(value){this._key=value,this.features._referenceFace=255&this._key,this.features._incidentEdge=(65280&this._key)>>8&255,this.features._incidentVertex=(16711680&this._key)>>16&255,this.features._flip=(4278190080&this._key)>>24&255},features:new Features,_key:0};var b2ContactPoint=Class.create();b2ContactPoint.prototype={position:new b2Vec2,separation:null,normalImpulse:null,tangentImpulse:null,id:new b2ContactID,initialize:function(){this.position=new b2Vec2,this.id=new b2ContactID}};var b2Distance=Class.create();b2Distance.prototype={initialize:function(){}},b2Distance.ProcessTwo=function(p1Out,p2Out,p1s,p2s,points){var rX=-points[1].x,rY=-points[1].y,dX=points[0].x-points[1].x,dY=points[0].y-points[1].y,length=Math.sqrt(dX*dX+dY*dY),lambda=rX*(dX/=length)+rY*(dY/=length);return lambda<=0||length=0&&ud>=0){var lambda=un/(un+ud);return p1Out.x=p1s[1].x+lambda*(p1s[2].x-p1s[1].x),p1Out.y=p1s[1].y+lambda*(p1s[2].y-p1s[1].y),p2Out.x=p2s[1].x+lambda*(p2s[2].x-p2s[1].x),p2Out.y=p2s[1].y+lambda*(p2s[2].y-p2s[1].y),p1s[0].SetV(p1s[2]),p2s[0].SetV(p2s[2]),points[0].SetV(points[2]),2}var vb=n*(cX*aY-cY*aX);if(vb<=0&&tn>=0&&td>=0){lambda=tn/(tn+td);return p1Out.x=p1s[0].x+lambda*(p1s[2].x-p1s[0].x),p1Out.y=p1s[0].y+lambda*(p1s[2].y-p1s[0].y),p2Out.x=p2s[0].x+lambda*(p2s[2].x-p2s[0].x),p2Out.y=p2s[0].y+lambda*(p2s[2].y-p2s[0].y),p1s[1].SetV(p1s[2]),p2s[1].SetV(p2s[2]),points[1].SetV(points[2]),2}var denom=va+vb+vc,u=va*(denom=1/denom),v=vb*denom,w=1-u-v;return p1Out.x=u*p1s[0].x+v*p1s[1].x+w*p1s[2].x,p1Out.y=u*p1s[0].y+v*p1s[1].y+w*p1s[2].y,p2Out.x=u*p2s[0].x+v*p2s[1].x+w*p2s[2].x,p2Out.y=u*p2s[0].y+v*p2s[1].y+w*p2s[2].y,3},b2Distance.InPoinsts=function(w,points,pointCount){for(var i=0;i0)return!1}return!0},initialize:function(def,body,newOrigin){this.m_R=new b2Mat22,this.m_position=new b2Vec2,this.m_userData=def.userData,this.m_friction=def.friction,this.m_restitution=def.restitution,this.m_body=body,this.m_proxyId=b2Pair.b2_nullProxy,this.m_maxRadius=0,this.m_categoryBits=def.categoryBits,this.m_maskBits=def.maskBits,this.m_groupIndex=def.groupIndex,this.syncAABB=new b2AABB,this.syncMat=new b2Mat22,this.m_localCentroid=new b2Vec2,this.m_localOBB=new b2OBB;var hX,hY,tVec,i=0,aabb=new b2AABB;this.m_vertices=new Array(b2Settings.b2_maxPolyVertices),this.m_coreVertices=new Array(b2Settings.b2_maxPolyVertices),this.m_normals=new Array(b2Settings.b2_maxPolyVertices),this.m_type=b2Shape.e_polyShape;var localR=new b2Mat22(def.localRotation);if(def.type==b2Shape.e_boxShape){this.m_localCentroid.x=def.localPosition.x-newOrigin.x,this.m_localCentroid.y=def.localPosition.y-newOrigin.y;var box=def;this.m_vertexCount=4,hX=box.extents.x,hY=box.extents.y;var hcX=Math.max(0,hX-2*b2Settings.b2_linearSlop),hcY=Math.max(0,hY-2*b2Settings.b2_linearSlop);(tVec=this.m_vertices[0]=new b2Vec2).x=localR.col1.x*hX+localR.col2.x*hY,tVec.y=localR.col1.y*hX+localR.col2.y*hY,(tVec=this.m_vertices[1]=new b2Vec2).x=localR.col1.x*-hX+localR.col2.x*hY,tVec.y=localR.col1.y*-hX+localR.col2.y*hY,(tVec=this.m_vertices[2]=new b2Vec2).x=localR.col1.x*-hX+localR.col2.x*-hY,tVec.y=localR.col1.y*-hX+localR.col2.y*-hY,(tVec=this.m_vertices[3]=new b2Vec2).x=localR.col1.x*hX+localR.col2.x*-hY,tVec.y=localR.col1.y*hX+localR.col2.y*-hY,(tVec=this.m_coreVertices[0]=new b2Vec2).x=localR.col1.x*hcX+localR.col2.x*hcY,tVec.y=localR.col1.y*hcX+localR.col2.y*hcY,(tVec=this.m_coreVertices[1]=new b2Vec2).x=localR.col1.x*-hcX+localR.col2.x*hcY,tVec.y=localR.col1.y*-hcX+localR.col2.y*hcY,(tVec=this.m_coreVertices[2]=new b2Vec2).x=localR.col1.x*-hcX+localR.col2.x*-hcY,tVec.y=localR.col1.y*-hcX+localR.col2.y*-hcY,(tVec=this.m_coreVertices[3]=new b2Vec2).x=localR.col1.x*hcX+localR.col2.x*-hcY,tVec.y=localR.col1.y*hcX+localR.col2.y*-hcY}else{var poly=def;this.m_vertexCount=poly.vertexCount,b2Shape.PolyCentroid(poly.vertices,poly.vertexCount,b2PolyShape.tempVec);var centroidX=b2PolyShape.tempVec.x,centroidY=b2PolyShape.tempVec.y;for(this.m_localCentroid.x=def.localPosition.x+(localR.col1.x*centroidX+localR.col2.x*centroidY)-newOrigin.x,this.m_localCentroid.y=def.localPosition.y+(localR.col1.y*centroidX+localR.col2.y*centroidY)-newOrigin.y,i=0;iNumber.MIN_VALUE&&(uX*=1/length,uY*=1/length),this.m_coreVertices[i].x=this.m_vertices[i].x-2*b2Settings.b2_linearSlop*uX,this.m_coreVertices[i].y=this.m_vertices[i].y-2*b2Settings.b2_linearSlop*uY}}var minVertexX=Number.MAX_VALUE,minVertexY=Number.MAX_VALUE,maxVertexX=-Number.MAX_VALUE,maxVertexY=-Number.MAX_VALUE;for(this.m_maxRadius=0,i=0;ibestValue&&(bestIndex=i,bestValue=value)}out.Set(this.m_position.x+(this.m_R.col1.x*this.m_coreVertices[bestIndex].x+this.m_R.col2.x*this.m_coreVertices[bestIndex].y),this.m_position.y+(this.m_R.col1.y*this.m_coreVertices[bestIndex].x+this.m_R.col2.y*this.m_coreVertices[bestIndex].y))},m_localCentroid:new b2Vec2,m_localOBB:new b2OBB,m_vertices:null,m_coreVertices:null,m_vertexCount:0,m_normals:null}),b2PolyShape.tempVec=new b2Vec2,b2PolyShape.tAbsR=new b2Mat22;var b2Body=Class.create();b2Body.prototype={SetOriginPosition:function(position,rotation){if(!this.IsFrozen()){this.m_rotation=rotation,this.m_R.Set(this.m_rotation),this.m_position=b2Math.AddVV(position,b2Math.b2MulMV(this.m_R,this.m_center)),this.m_position0.SetV(this.m_position),this.m_rotation0=this.m_rotation;for(var s=this.m_shapeList;null!=s;s=s.m_next)s.Synchronize(this.m_position,this.m_R,this.m_position,this.m_R);this.m_world.m_broadPhase.Commit()}},GetOriginPosition:function(){return b2Math.SubtractVV(this.m_position,b2Math.b2MulMV(this.m_R,this.m_center))},SetCenterPosition:function(position,rotation){if(!this.IsFrozen()){this.m_rotation=rotation,this.m_R.Set(this.m_rotation),this.m_position.SetV(position),this.m_position0.SetV(this.m_position),this.m_rotation0=this.m_rotation;for(var s=this.m_shapeList;null!=s;s=s.m_next)s.Synchronize(this.m_position,this.m_R,this.m_position,this.m_R);this.m_world.m_broadPhase.Commit()}},GetCenterPosition:function(){return this.m_position},GetRotation:function(){return this.m_rotation},GetRotationMatrix:function(){return this.m_R},SetLinearVelocity:function(v){this.m_linearVelocity.SetV(v)},GetLinearVelocity:function(){return this.m_linearVelocity},SetAngularVelocity:function(w){this.m_angularVelocity=w},GetAngularVelocity:function(){return this.m_angularVelocity},ApplyForce:function(force,point){0==this.IsSleeping()&&(this.m_force.Add(force),this.m_torque+=b2Math.b2CrossVV(b2Math.SubtractVV(point,this.m_position),force))},ApplyTorque:function(torque){0==this.IsSleeping()&&(this.m_torque+=torque)},ApplyImpulse:function(impulse,point){0==this.IsSleeping()&&(this.m_linearVelocity.Add(b2Math.MulFV(this.m_invMass,impulse)),this.m_angularVelocity+=this.m_invI*b2Math.b2CrossVV(b2Math.SubtractVV(point,this.m_position),impulse))},GetMass:function(){return this.m_mass},GetInertia:function(){return this.m_I},GetWorldPoint:function(localPoint){return b2Math.AddVV(this.m_position,b2Math.b2MulMV(this.m_R,localPoint))},GetWorldVector:function(localVector){return b2Math.b2MulMV(this.m_R,localVector)},GetLocalPoint:function(worldPoint){return b2Math.b2MulTMV(this.m_R,b2Math.SubtractVV(worldPoint,this.m_position))},GetLocalVector:function(worldVector){return b2Math.b2MulTMV(this.m_R,worldVector)},IsStatic:function(){return(this.m_flags&b2Body.e_staticFlag)==b2Body.e_staticFlag},IsFrozen:function(){return(this.m_flags&b2Body.e_frozenFlag)==b2Body.e_frozenFlag},IsSleeping:function(){return(this.m_flags&b2Body.e_sleepFlag)==b2Body.e_sleepFlag},AllowSleeping:function(flag){flag?this.m_flags|=b2Body.e_allowSleepFlag:(this.m_flags&=~b2Body.e_allowSleepFlag,this.WakeUp())},WakeUp:function(){this.m_flags&=~b2Body.e_sleepFlag,this.m_sleepTime=0},GetShapeList:function(){return this.m_shapeList},GetContactList:function(){return this.m_contactList},GetJointList:function(){return this.m_jointList},GetNext:function(){return this.m_next},GetUserData:function(){return this.m_userData},initialize:function(bd,world){this.sMat0=new b2Mat22,this.m_position=new b2Vec2,this.m_R=new b2Mat22(0),this.m_position0=new b2Vec2;var sd,massData,i=0;this.m_flags=0,this.m_position.SetV(bd.position),this.m_rotation=bd.rotation,this.m_R.Set(this.m_rotation),this.m_position0.SetV(this.m_position),this.m_rotation0=this.m_rotation,this.m_world=world,this.m_linearDamping=b2Math.b2Clamp(1-bd.linearDamping,0,1),this.m_angularDamping=b2Math.b2Clamp(1-bd.angularDamping,0,1),this.m_force=new b2Vec2(0,0),this.m_torque=0,this.m_mass=0;var massDatas=new Array(b2Settings.b2_maxShapesPerBody);for(i=0;i0?(this.m_center.Multiply(1/this.m_mass),this.m_position.Add(b2Math.b2MulMV(this.m_R,this.m_center))):this.m_flags|=b2Body.e_staticFlag,this.m_I=0,i=0;i0?this.m_invMass=1/this.m_mass:this.m_invMass=0,this.m_I>0&&0==bd.preventRotation?this.m_invI=1/this.m_I:(this.m_I=0,this.m_invI=0),this.m_linearVelocity=b2Math.AddVV(bd.linearVelocity,b2Math.b2CrossFV(bd.angularVelocity,this.m_center)),this.m_angularVelocity=bd.angularVelocity,this.m_jointList=null,this.m_contactList=null,this.m_prev=null,this.m_next=null,this.m_shapeList=null,i=0;i0:0!=(shape1.m_maskBits&shape2.m_categoryBits)&&0!=(shape1.m_categoryBits&shape2.m_maskBits)},initialize:function(){}},b2CollisionFilter.b2_defaultFilter=new b2CollisionFilter;var b2Island=Class.create();b2Island.prototype={initialize:function(bodyCapacity,contactCapacity,jointCapacity,allocator){var i=0;for(this.m_bodyCapacity=bodyCapacity,this.m_contactCapacity=contactCapacity,this.m_jointCapacity=jointCapacity,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_bodies=new Array(bodyCapacity),i=0;iangTolSqr||b2Math.b2Dot(b.m_linearVelocity,b.m_linearVelocity)>linTolSqr?(b.m_sleepTime=0,minSleepTime=0):(b.m_sleepTime+=dt,minSleepTime=b2Math.b2Min(minSleepTime,b.m_sleepTime)));if(minSleepTime>=b2Settings.b2_timeToSleep)for(i=0;i0&&(contact.m_shape1.m_body.WakeUp(),contact.m_shape2.m_body.WakeUp());var type1=contact.m_shape1.m_type,type2=contact.m_shape2.m_type;(0,b2Contact.s_registers[type1][type2].destroyFcn)(contact,allocator)},b2Contact.s_registers=null,b2Contact.s_initialized=!1;var b2ContactConstraint=Class.create();b2ContactConstraint.prototype={initialize:function(){this.normal=new b2Vec2,this.points=new Array(b2Settings.b2_maxManifoldPoints);for(var i=0;i0&&(ccp.velocityBias=-60*ccp.separation);var tX=v2X+-w2*r2Y-v1X- -w1*r1Y,tY=v2Y+w2*r2X-v1Y-w1*r1X,vRel=c.normal.x*tX+c.normal.y*tY;vRel<-b2Settings.b2_velocityThreshold&&(ccp.velocityBias+=-c.restitution*vRel)}++count}},PreSolve:function(){for(var tVec,tMat,i=0;i=-b2Settings.b2_linearSlop},PostSolve:function(){for(var i=0;i0?this.m_manifoldCount=1:this.m_manifoldCount=0},GetManifolds:function(){return this.m_manifold},m_manifold:[new b2Manifold]}),b2CircleContact.Create=function(shape1,shape2,allocator){return new b2CircleContact(shape1,shape2)},b2CircleContact.Destroy=function(contact,allocator){};var b2Conservative=Class.create();b2Conservative.prototype={initialize:function(){}},b2Conservative.R1=new b2Mat22,b2Conservative.R2=new b2Mat22,b2Conservative.x1=new b2Vec2,b2Conservative.x2=new b2Vec2,b2Conservative.Conservative=function(shape1,shape2){var body1=shape1.GetBody(),body2=shape2.GetBody(),v1X=body1.m_position.x-body1.m_position0.x,v1Y=body1.m_position.y-body1.m_position0.y,omega1=body1.m_rotation-body1.m_rotation0,v2X=body2.m_position.x-body2.m_position0.x,v2Y=body2.m_position.y-body2.m_position0.y,omega2=body2.m_rotation-body2.m_rotation0,r1=shape1.GetMaxRadius(),r2=shape2.GetMaxRadius(),p1StartX=body1.m_position0.x,p1StartY=body1.m_position0.y,a1Start=body1.m_rotation0,p2StartX=body2.m_position0.x,p2StartY=body2.m_position0.y,a2Start=body2.m_rotation0,p1X=p1StartX,p1Y=p1StartY,a1=a1Start,p2X=p2StartX,p2Y=p2StartY,a2=a2Start;b2Conservative.R1.Set(a1),b2Conservative.R2.Set(a2),shape1.QuickSync(p1,b2Conservative.R1),shape2.QuickSync(p2,b2Conservative.R2);for(var dX,dY,s1=0,invRelativeVelocity=0,hit=!0,iter=0;iter<10;++iter){var distance=b2Distance.Distance(b2Conservative.x1,b2Conservative.x2,shape1,shape2);if(distanceFLT_EPSILON&&(d*=b2_linearSlop/length),body1.IsStatic()?(body1.m_position.x=p1X,body1.m_position.y=p1Y):(body1.m_position.x=p1X-dX,body1.m_position.y=p1Y-dY),body1.m_rotation=a1,body1.m_R.Set(a1),body1.QuickSyncShapes(),body2.IsStatic()?(body2.m_position.x=p2X,body2.m_position.y=p2Y):(body2.m_position.x=p2X+dX,body2.m_position.y=p2Y+dY),body2.m_position.x=p2X+dX,body2.m_position.y=p2Y+dY,body2.m_rotation=a2,body2.m_R.Set(a2),body2.QuickSyncShapes(),!0}return shape1.QuickSync(body1.m_position,body1.m_R),shape2.QuickSync(body2.m_position,body2.m_R),!1};var b2NullContact=Class.create();Object.extend(b2NullContact.prototype,b2Contact.prototype),Object.extend(b2NullContact.prototype,{initialize:function(s1,s2){if(this.m_node1=new b2ContactNode,this.m_node2=new b2ContactNode,this.m_flags=0,!s1||!s2)return this.m_shape1=null,void(this.m_shape2=null);this.m_shape1=s1,this.m_shape2=s2,this.m_manifoldCount=0,this.m_friction=Math.sqrt(this.m_shape1.m_friction*this.m_shape2.m_friction),this.m_restitution=b2Math.b2Max(this.m_shape1.m_restitution,this.m_shape2.m_restitution),this.m_prev=null,this.m_next=null,this.m_node1.contact=null,this.m_node1.prev=null,this.m_node1.next=null,this.m_node1.other=null,this.m_node2.contact=null,this.m_node2.prev=null,this.m_node2.next=null,this.m_node2.other=null},Evaluate:function(){},GetManifolds:function(){return null}});var b2PolyAndCircleContact=Class.create();Object.extend(b2PolyAndCircleContact.prototype,b2Contact.prototype),Object.extend(b2PolyAndCircleContact.prototype,{initialize:function(s1,s2){if(this.m_node1=new b2ContactNode,this.m_node2=new b2ContactNode,this.m_flags=0,!s1||!s2)return this.m_shape1=null,void(this.m_shape2=null);this.m_shape1=s1,this.m_shape2=s2,this.m_manifoldCount=0,this.m_friction=Math.sqrt(this.m_shape1.m_friction*this.m_shape2.m_friction),this.m_restitution=b2Math.b2Max(this.m_shape1.m_restitution,this.m_shape2.m_restitution),this.m_prev=null,this.m_next=null,this.m_node1.contact=null,this.m_node1.prev=null,this.m_node1.next=null,this.m_node1.other=null,this.m_node2.contact=null,this.m_node2.prev=null,this.m_node2.next=null,this.m_node2.other=null,this.m_manifold=[new b2Manifold],b2Settings.b2Assert(this.m_shape1.m_type==b2Shape.e_polyShape),b2Settings.b2Assert(this.m_shape2.m_type==b2Shape.e_circleShape),this.m_manifold[0].pointCount=0,this.m_manifold[0].points[0].normalImpulse=0,this.m_manifold[0].points[0].tangentImpulse=0},Evaluate:function(){b2Collision.b2CollidePolyAndCircle(this.m_manifold[0],this.m_shape1,this.m_shape2,!1),this.m_manifold[0].pointCount>0?this.m_manifoldCount=1:this.m_manifoldCount=0},GetManifolds:function(){return this.m_manifold},m_manifold:[new b2Manifold]}),b2PolyAndCircleContact.Create=function(shape1,shape2,allocator){return new b2PolyAndCircleContact(shape1,shape2)},b2PolyAndCircleContact.Destroy=function(contact,allocator){};var b2PolyContact=Class.create();Object.extend(b2PolyContact.prototype,b2Contact.prototype),Object.extend(b2PolyContact.prototype,{initialize:function(s1,s2){if(this.m_node1=new b2ContactNode,this.m_node2=new b2ContactNode,this.m_flags=0,!s1||!s2)return this.m_shape1=null,void(this.m_shape2=null);this.m_shape1=s1,this.m_shape2=s2,this.m_manifoldCount=0,this.m_friction=Math.sqrt(this.m_shape1.m_friction*this.m_shape2.m_friction),this.m_restitution=b2Math.b2Max(this.m_shape1.m_restitution,this.m_shape2.m_restitution),this.m_prev=null,this.m_next=null,this.m_node1.contact=null,this.m_node1.prev=null,this.m_node1.next=null,this.m_node1.other=null,this.m_node2.contact=null,this.m_node2.prev=null,this.m_node2.next=null,this.m_node2.other=null,this.m0=new b2Manifold,this.m_manifold=[new b2Manifold],this.m_manifold[0].pointCount=0},m0:new b2Manifold,Evaluate:function(){for(var tMani=this.m_manifold[0],tPoints=this.m0.points,k=0;k0){for(var match=[!1,!1],i=0;i0){var body1=c.m_shape1.m_body,body2=c.m_shape2.m_body,node1=c.m_node1,node2=c.m_node2;body1.WakeUp(),body2.WakeUp(),node1.prev&&(node1.prev.next=node1.next),node1.next&&(node1.next.prev=node1.prev),node1==body1.m_contactList&&(body1.m_contactList=node1.next),node1.prev=null,node1.next=null,node2.prev&&(node2.prev.next=node2.next),node2.next&&(node2.next.prev=node2.prev),node2==body2.m_contactList&&(body2.m_contactList=node2.next),node2.prev=null,node2.next=null}b2Contact.Destroy(c,this.m_world.m_blockAllocator),--this.m_world.m_contactCount},CleanContactList:function(){for(var c=this.m_world.m_contactList;null!=c;){var c0=c;c=c.m_next,c0.m_flags&b2Contact.e_destroyFlag&&(this.DestroyContact(c0),c0=null)}},Collide:function(){for(var body1,body2,node1,node2,c=this.m_world.m_contactList;null!=c;c=c.m_next)if(!c.m_shape1.m_body.IsSleeping()||!c.m_shape2.m_body.IsSleeping()){var oldCount=c.GetManifoldCount();c.Evaluate();var newCount=c.GetManifoldCount();0==oldCount&&newCount>0?(body1=c.m_shape1.m_body,body2=c.m_shape2.m_body,node1=c.m_node1,node2=c.m_node2,node1.contact=c,node1.other=body2,node1.prev=null,node1.next=body1.m_contactList,null!=node1.next&&(node1.next.prev=c.m_node1),body1.m_contactList=c.m_node1,node2.contact=c,node2.other=body1,node2.prev=null,node2.next=body2.m_contactList,null!=node2.next&&(node2.next.prev=node2),body2.m_contactList=node2):oldCount>0&&0==newCount&&(body1=c.m_shape1.m_body,body2=c.m_shape2.m_body,node1=c.m_node1,node2=c.m_node2,node1.prev&&(node1.prev.next=node1.next),node1.next&&(node1.next.prev=node1.prev),node1==body1.m_contactList&&(body1.m_contactList=node1.next),node1.prev=null,node1.next=null,node2.prev&&(node2.prev.next=node2.next),node2.next&&(node2.next.prev=node2.prev),node2==body2.m_contactList&&(body2.m_contactList=node2.next),node2.prev=null,node2.next=null)}},m_world:null,m_nullContact:new b2NullContact,m_destroyImmediate:null});var b2World=Class.create();b2World.prototype={initialize:function(worldAABB,gravity,doSleep){this.step=new b2TimeStep,this.m_contactManager=new b2ContactManager,this.m_listener=null,this.m_filter=b2CollisionFilter.b2_defaultFilter,this.m_bodyList=null,this.m_contactList=null,this.m_jointList=null,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_bodyDestroyList=null,this.m_allowSleep=doSleep,this.m_gravity=gravity,this.m_contactManager.m_world=this,this.m_broadPhase=new b2BroadPhase(worldAABB,this.m_contactManager);var bd=new b2BodyDef;this.m_groundBody=this.CreateBody(bd)},SetListener:function(listener){this.m_listener=listener},SetFilter:function(filter){this.m_filter=filter},CreateBody:function(def){var b=new b2Body(def,this);return b.m_prev=null,b.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=b),this.m_bodyList=b,++this.m_bodyCount,b},DestroyBody:function(b){b.m_flags&b2Body.e_destroyFlag||(b.m_prev&&(b.m_prev.m_next=b.m_next),b.m_next&&(b.m_next.m_prev=b.m_prev),b==this.m_bodyList&&(this.m_bodyList=b.m_next),b.m_flags|=b2Body.e_destroyFlag,--this.m_bodyCount,b.m_prev=null,b.m_next=this.m_bodyDestroyList,this.m_bodyDestroyList=b)},CleanBodyList:function(){this.m_contactManager.m_destroyImmediate=!0;for(var b=this.m_bodyDestroyList;b;){var b0=b;b=b.m_next;for(var jn=b0.m_jointList;jn;){var jn0=jn;jn=jn.next,this.m_listener&&this.m_listener.NotifyJointDestroyed(jn0.joint),this.DestroyJoint(jn0.joint)}b0.Destroy()}this.m_bodyDestroyList=null,this.m_contactManager.m_destroyImmediate=!1},CreateJoint:function(def){var j=b2Joint.Create(def,this.m_blockAllocator);if(j.m_prev=null,j.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=j),this.m_jointList=j,++this.m_jointCount,j.m_node1.joint=j,j.m_node1.other=j.m_body2,j.m_node1.prev=null,j.m_node1.next=j.m_body1.m_jointList,j.m_body1.m_jointList&&(j.m_body1.m_jointList.prev=j.m_node1),j.m_body1.m_jointList=j.m_node1,j.m_node2.joint=j,j.m_node2.other=j.m_body1,j.m_node2.prev=null,j.m_node2.next=j.m_body2.m_jointList,j.m_body2.m_jointList&&(j.m_body2.m_jointList.prev=j.m_node2),j.m_body2.m_jointList=j.m_node2,0==def.collideConnected)for(var s=(def.body1.m_shapeCount0?1/dt:0,this.m_positionIterationCount=0,this.m_contactManager.CleanContactList(),this.CleanBodyList(),this.m_contactManager.Collide();var island=new b2Island(this.m_bodyCount,this.m_contactCount,this.m_jointCount,this.m_stackAllocator);for(b=this.m_bodyList;null!=b;b=b.m_next)b.m_flags&=~b2Body.e_islandFlag;for(var c=this.m_contactList;null!=c;c=c.m_next)c.m_flags&=~b2Contact.e_islandFlag;for(var j=this.m_jointList;null!=j;j=j.m_next)j.m_islandFlag=!1;this.m_bodyCount;for(var stack=new Array(this.m_bodyCount),k=0;k0;)if(b=stack[--stackCount],island.AddBody(b),b.m_flags&=~b2Body.e_sleepFlag,!(b.m_flags&b2Body.e_staticFlag)){for(var cn=b.m_contactList;null!=cn;cn=cn.next)cn.contact.m_flags&b2Contact.e_islandFlag||(island.AddContact(cn.contact),cn.contact.m_flags|=b2Contact.e_islandFlag,(other=cn.other).m_flags&b2Body.e_islandFlag||(stack[stackCount++]=other,other.m_flags|=b2Body.e_islandFlag));for(var jn=b.m_jointList;null!=jn;jn=jn.next)1!=jn.joint.m_islandFlag&&(island.AddJoint(jn.joint),jn.joint.m_islandFlag=!0,(other=jn.other).m_flags&b2Body.e_islandFlag||(stack[stackCount++]=other,other.m_flags|=b2Body.e_islandFlag))}island.Solve(this.step,this.m_gravity),this.m_positionIterationCount=b2Math.b2Max(this.m_positionIterationCount,b2Island.m_positionIterationCount),this.m_allowSleep&&island.UpdateSleep(dt);for(var i=0;ib2Settings.b2_linearSlop?this.m_u.Multiply(1/length):this.m_u.SetZero();var cr1u=r1X*this.m_u.y-r1Y*this.m_u.x,cr2u=r2X*this.m_u.y-r2Y*this.m_u.x;if(this.m_mass=this.m_body1.m_invMass+this.m_body1.m_invI*cr1u*cr1u+this.m_body2.m_invMass+this.m_body2.m_invI*cr2u*cr2u,this.m_mass=1/this.m_mass,b2World.s_enableWarmStarting){var PX=this.m_impulse*this.m_u.x,PY=this.m_impulse*this.m_u.y;this.m_body1.m_linearVelocity.x-=this.m_body1.m_invMass*PX,this.m_body1.m_linearVelocity.y-=this.m_body1.m_invMass*PY,this.m_body1.m_angularVelocity-=this.m_body1.m_invI*(r1X*PY-r1Y*PX),this.m_body2.m_linearVelocity.x+=this.m_body2.m_invMass*PX,this.m_body2.m_linearVelocity.y+=this.m_body2.m_invMass*PY,this.m_body2.m_angularVelocity+=this.m_body2.m_invI*(r2X*PY-r2Y*PX)}else this.m_impulse=0},SolveVelocityConstraints:function(step){var tMat,r1X=(tMat=this.m_body1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=this.m_body2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,v1X=this.m_body1.m_linearVelocity.x+-this.m_body1.m_angularVelocity*r1Y,v1Y=this.m_body1.m_linearVelocity.y+this.m_body1.m_angularVelocity*r1X,v2X=this.m_body2.m_linearVelocity.x+-this.m_body2.m_angularVelocity*r2Y,v2Y=this.m_body2.m_linearVelocity.y+this.m_body2.m_angularVelocity*r2X,Cdot=this.m_u.x*(v2X-v1X)+this.m_u.y*(v2Y-v1Y),impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var PX=impulse*this.m_u.x,PY=impulse*this.m_u.y;this.m_body1.m_linearVelocity.x-=this.m_body1.m_invMass*PX,this.m_body1.m_linearVelocity.y-=this.m_body1.m_invMass*PY,this.m_body1.m_angularVelocity-=this.m_body1.m_invI*(r1X*PY-r1Y*PX),this.m_body2.m_linearVelocity.x+=this.m_body2.m_invMass*PX,this.m_body2.m_linearVelocity.y+=this.m_body2.m_invMass*PY,this.m_body2.m_angularVelocity+=this.m_body2.m_invI*(r2X*PY-r2Y*PX)},SolvePositionConstraints:function(){var tMat,r1X=(tMat=this.m_body1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=this.m_body2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,dX=this.m_body2.m_position.x+r2X-this.m_body1.m_position.x-r1X,dY=this.m_body2.m_position.y+r2Y-this.m_body1.m_position.y-r1Y,length=Math.sqrt(dX*dX+dY*dY);dX/=length,dY/=length;var C=length-this.m_length;C=b2Math.b2Clamp(C,-b2Settings.b2_maxLinearCorrection,b2Settings.b2_maxLinearCorrection);var impulse=-this.m_mass*C;this.m_u.Set(dX,dY);var PX=impulse*this.m_u.x,PY=impulse*this.m_u.y;return this.m_body1.m_position.x-=this.m_body1.m_invMass*PX,this.m_body1.m_position.y-=this.m_body1.m_invMass*PY,this.m_body1.m_rotation-=this.m_body1.m_invI*(r1X*PY-r1Y*PX),this.m_body2.m_position.x+=this.m_body2.m_invMass*PX,this.m_body2.m_position.y+=this.m_body2.m_invMass*PY,this.m_body2.m_rotation+=this.m_body2.m_invI*(r2X*PY-r2Y*PX),this.m_body1.m_R.Set(this.m_body1.m_rotation),this.m_body2.m_R.Set(this.m_body2.m_rotation),b2Math.b2Abs(C)step.dt*this.m_maxForce&&this.m_impulse.Multiply(step.dt*this.m_maxForce/length),impulseX=this.m_impulse.x-oldImpulseX,impulseY=this.m_impulse.y-oldImpulseY,body.m_linearVelocity.x+=body.m_invMass*impulseX,body.m_linearVelocity.y+=body.m_invMass*impulseY,body.m_angularVelocity+=body.m_invI*(rX*impulseY-rY*impulseX)},SolvePositionConstraints:function(){return!0},m_localAnchor:new b2Vec2,m_target:new b2Vec2,m_impulse:new b2Vec2,m_ptpMass:new b2Mat22,m_C:new b2Vec2,m_maxForce:null,m_beta:null,m_gamma:null});var b2MouseJointDef=Class.create();Object.extend(b2MouseJointDef.prototype,b2JointDef.prototype),Object.extend(b2MouseJointDef.prototype,{initialize:function(){this.type=b2Joint.e_unknownJoint,this.userData=null,this.body1=null,this.body2=null,this.collideConnected=!1,this.target=new b2Vec2,this.type=b2Joint.e_mouseJoint,this.maxForce=0,this.frequencyHz=5,this.dampingRatio=.7,this.timeStep=1/60},target:new b2Vec2,maxForce:null,frequencyHz:null,dampingRatio:null,timeStep:null});var b2PrismaticJoint=Class.create();Object.extend(b2PrismaticJoint.prototype,b2Joint.prototype),Object.extend(b2PrismaticJoint.prototype,{GetAnchor1:function(){var b1=this.m_body1,tVec=new b2Vec2;return tVec.SetV(this.m_localAnchor1),tVec.MulM(b1.m_R),tVec.Add(b1.m_position),tVec},GetAnchor2:function(){var b2=this.m_body2,tVec=new b2Vec2;return tVec.SetV(this.m_localAnchor2),tVec.MulM(b2.m_R),tVec.Add(b2.m_position),tVec},GetJointTranslation:function(){var tMat,b1=this.m_body1,b2=this.m_body2,r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,p1X=b1.m_position.x+r1X,p1Y=b1.m_position.y+r1Y,dX=b2.m_position.x+r2X-p1X,dY=b2.m_position.y+r2Y-p1Y;return((tMat=b1.m_R).col1.x*this.m_localXAxis1.x+tMat.col2.x*this.m_localXAxis1.y)*dX+(tMat.col1.y*this.m_localXAxis1.x+tMat.col2.y*this.m_localXAxis1.y)*dY},GetJointSpeed:function(){var tMat,b1=this.m_body1,b2=this.m_body2,r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,p1X=b1.m_position.x+r1X,p1Y=b1.m_position.y+r1Y,dX=b2.m_position.x+r2X-p1X,dY=b2.m_position.y+r2Y-p1Y,ax1X=(tMat=b1.m_R).col1.x*this.m_localXAxis1.x+tMat.col2.x*this.m_localXAxis1.y,ax1Y=tMat.col1.y*this.m_localXAxis1.x+tMat.col2.y*this.m_localXAxis1.y,v1=b1.m_linearVelocity,v2=b2.m_linearVelocity,w1=b1.m_angularVelocity,w2=b2.m_angularVelocity;return dX*(-w1*ax1Y)+dY*(w1*ax1X)+(ax1X*(v2.x+-w2*r2Y-v1.x- -w1*r1Y)+ax1Y*(v2.y+w2*r2X-v1.y-w1*r1X))},GetMotorForce:function(invTimeStep){return invTimeStep*this.m_motorImpulse},SetMotorSpeed:function(speed){this.m_motorSpeed=speed},SetMotorForce:function(force){this.m_maxMotorForce=force},GetReactionForce:function(invTimeStep){var tMat,tImp=invTimeStep*this.m_limitImpulse,ax1X=tImp*((tMat=this.m_body1.m_R).col1.x*this.m_localXAxis1.x+tMat.col2.x*this.m_localXAxis1.y),ax1Y=tImp*(tMat.col1.y*this.m_localXAxis1.x+tMat.col2.y*this.m_localXAxis1.y),ay1X=tImp*(tMat.col1.x*this.m_localYAxis1.x+tMat.col2.x*this.m_localYAxis1.y),ay1Y=tImp*(tMat.col1.y*this.m_localYAxis1.x+tMat.col2.y*this.m_localYAxis1.y);return new b2Vec2(ax1X+ay1X,ax1Y+ay1Y)},GetReactionTorque:function(invTimeStep){return invTimeStep*this.m_angularImpulse},initialize:function(def){var tMat,tX,tY;this.m_node1=new b2JointNode,this.m_node2=new b2JointNode,this.m_type=def.type,this.m_prev=null,this.m_next=null,this.m_body1=def.body1,this.m_body2=def.body2,this.m_collideConnected=def.collideConnected,this.m_islandFlag=!1,this.m_userData=def.userData,this.m_localAnchor1=new b2Vec2,this.m_localAnchor2=new b2Vec2,this.m_localXAxis1=new b2Vec2,this.m_localYAxis1=new b2Vec2,this.m_linearJacobian=new b2Jacobian,this.m_motorJacobian=new b2Jacobian,tMat=this.m_body1.m_R,tX=def.anchorPoint.x-this.m_body1.m_position.x,tY=def.anchorPoint.y-this.m_body1.m_position.y,this.m_localAnchor1.Set(tX*tMat.col1.x+tY*tMat.col1.y,tX*tMat.col2.x+tY*tMat.col2.y),tMat=this.m_body2.m_R,tX=def.anchorPoint.x-this.m_body2.m_position.x,tY=def.anchorPoint.y-this.m_body2.m_position.y,this.m_localAnchor2.Set(tX*tMat.col1.x+tY*tMat.col1.y,tX*tMat.col2.x+tY*tMat.col2.y),tMat=this.m_body1.m_R,tX=def.axis.x,tY=def.axis.y,this.m_localXAxis1.Set(tX*tMat.col1.x+tY*tMat.col1.y,tX*tMat.col2.x+tY*tMat.col2.y),this.m_localYAxis1.x=-this.m_localXAxis1.y,this.m_localYAxis1.y=this.m_localXAxis1.x,this.m_initialAngle=this.m_body2.m_rotation-this.m_body1.m_rotation,this.m_linearJacobian.SetZero(),this.m_linearMass=0,this.m_linearImpulse=0,this.m_angularMass=0,this.m_angularImpulse=0,this.m_motorJacobian.SetZero(),this.m_motorMass=0,this.m_motorImpulse=0,this.m_limitImpulse=0,this.m_limitPositionImpulse=0,this.m_lowerTranslation=def.lowerTranslation,this.m_upperTranslation=def.upperTranslation,this.m_maxMotorForce=def.motorForce,this.m_motorSpeed=def.motorSpeed,this.m_enableLimit=def.enableLimit,this.m_enableMotor=def.enableMotor},PrepareVelocitySolver:function(){var tMat,b1=this.m_body1,b2=this.m_body2,r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,invMass1=b1.m_invMass,invMass2=b2.m_invMass,invI1=b1.m_invI,invI2=b2.m_invI,ay1X=(tMat=b1.m_R).col1.x*this.m_localYAxis1.x+tMat.col2.x*this.m_localYAxis1.y,ay1Y=tMat.col1.y*this.m_localYAxis1.x+tMat.col2.y*this.m_localYAxis1.y,eX=b2.m_position.x+r2X-b1.m_position.x,eY=b2.m_position.y+r2Y-b1.m_position.y;if(this.m_linearJacobian.linear1.x=-ay1X,this.m_linearJacobian.linear1.y=-ay1Y,this.m_linearJacobian.linear2.x=ay1X,this.m_linearJacobian.linear2.y=ay1Y,this.m_linearJacobian.angular1=-(eX*ay1Y-eY*ay1X),this.m_linearJacobian.angular2=r2X*ay1Y-r2Y*ay1X,this.m_linearMass=invMass1+invI1*this.m_linearJacobian.angular1*this.m_linearJacobian.angular1+invMass2+invI2*this.m_linearJacobian.angular2*this.m_linearJacobian.angular2,this.m_linearMass=1/this.m_linearMass,this.m_angularMass=1/(invI1+invI2),this.m_enableLimit||this.m_enableMotor){var ax1X=(tMat=b1.m_R).col1.x*this.m_localXAxis1.x+tMat.col2.x*this.m_localXAxis1.y,ax1Y=tMat.col1.y*this.m_localXAxis1.x+tMat.col2.y*this.m_localXAxis1.y;if(this.m_motorJacobian.linear1.x=-ax1X,this.m_motorJacobian.linear1.y=-ax1Y,this.m_motorJacobian.linear2.x=ax1X,this.m_motorJacobian.linear2.y=ax1Y,this.m_motorJacobian.angular1=-(eX*ax1Y-eY*ax1X),this.m_motorJacobian.angular2=r2X*ax1Y-r2Y*ax1X,this.m_motorMass=invMass1+invI1*this.m_motorJacobian.angular1*this.m_motorJacobian.angular1+invMass2+invI2*this.m_motorJacobian.angular2*this.m_motorJacobian.angular2,this.m_motorMass=1/this.m_motorMass,this.m_enableLimit){var jointTranslation=ax1X*(eX-r1X)+ax1Y*(eY-r1Y);b2Math.b2Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*b2Settings.b2_linearSlop?this.m_limitState=b2Joint.e_equalLimits:jointTranslation<=this.m_lowerTranslation?(this.m_limitState!=b2Joint.e_atLowerLimit&&(this.m_limitImpulse=0),this.m_limitState=b2Joint.e_atLowerLimit):jointTranslation>=this.m_upperTranslation?(this.m_limitState!=b2Joint.e_atUpperLimit&&(this.m_limitImpulse=0),this.m_limitState=b2Joint.e_atUpperLimit):(this.m_limitState=b2Joint.e_inactiveLimit,this.m_limitImpulse=0)}}if(0==this.m_enableMotor&&(this.m_motorImpulse=0),0==this.m_enableLimit&&(this.m_limitImpulse=0),b2World.s_enableWarmStarting){var P1X=this.m_linearImpulse*this.m_linearJacobian.linear1.x+(this.m_motorImpulse+this.m_limitImpulse)*this.m_motorJacobian.linear1.x,P1Y=this.m_linearImpulse*this.m_linearJacobian.linear1.y+(this.m_motorImpulse+this.m_limitImpulse)*this.m_motorJacobian.linear1.y,P2X=this.m_linearImpulse*this.m_linearJacobian.linear2.x+(this.m_motorImpulse+this.m_limitImpulse)*this.m_motorJacobian.linear2.x,P2Y=this.m_linearImpulse*this.m_linearJacobian.linear2.y+(this.m_motorImpulse+this.m_limitImpulse)*this.m_motorJacobian.linear2.y,L1=this.m_linearImpulse*this.m_linearJacobian.angular1-this.m_angularImpulse+(this.m_motorImpulse+this.m_limitImpulse)*this.m_motorJacobian.angular1,L2=this.m_linearImpulse*this.m_linearJacobian.angular2+this.m_angularImpulse+(this.m_motorImpulse+this.m_limitImpulse)*this.m_motorJacobian.angular2;b1.m_linearVelocity.x+=invMass1*P1X,b1.m_linearVelocity.y+=invMass1*P1Y,b1.m_angularVelocity+=invI1*L1,b2.m_linearVelocity.x+=invMass2*P2X,b2.m_linearVelocity.y+=invMass2*P2Y,b2.m_angularVelocity+=invI2*L2}else this.m_linearImpulse=0,this.m_angularImpulse=0,this.m_limitImpulse=0,this.m_motorImpulse=0;this.m_limitPositionImpulse=0},SolveVelocityConstraints:function(step){var oldLimitImpulse,b1=this.m_body1,b2=this.m_body2,invMass1=b1.m_invMass,invMass2=b2.m_invMass,invI1=b1.m_invI,invI2=b2.m_invI,linearCdot=this.m_linearJacobian.Compute(b1.m_linearVelocity,b1.m_angularVelocity,b2.m_linearVelocity,b2.m_angularVelocity),linearImpulse=-this.m_linearMass*linearCdot;this.m_linearImpulse+=linearImpulse,b1.m_linearVelocity.x+=invMass1*linearImpulse*this.m_linearJacobian.linear1.x,b1.m_linearVelocity.y+=invMass1*linearImpulse*this.m_linearJacobian.linear1.y,b1.m_angularVelocity+=invI1*linearImpulse*this.m_linearJacobian.angular1,b2.m_linearVelocity.x+=invMass2*linearImpulse*this.m_linearJacobian.linear2.x,b2.m_linearVelocity.y+=invMass2*linearImpulse*this.m_linearJacobian.linear2.y,b2.m_angularVelocity+=invI2*linearImpulse*this.m_linearJacobian.angular2;var angularCdot=b2.m_angularVelocity-b1.m_angularVelocity,angularImpulse=-this.m_angularMass*angularCdot;if(this.m_angularImpulse+=angularImpulse,b1.m_angularVelocity-=invI1*angularImpulse,b2.m_angularVelocity+=invI2*angularImpulse,this.m_enableMotor&&this.m_limitState!=b2Joint.e_equalLimits){var motorCdot=this.m_motorJacobian.Compute(b1.m_linearVelocity,b1.m_angularVelocity,b2.m_linearVelocity,b2.m_angularVelocity)-this.m_motorSpeed,motorImpulse=-this.m_motorMass*motorCdot,oldMotorImpulse=this.m_motorImpulse;this.m_motorImpulse=b2Math.b2Clamp(this.m_motorImpulse+motorImpulse,-step.dt*this.m_maxMotorForce,step.dt*this.m_maxMotorForce),motorImpulse=this.m_motorImpulse-oldMotorImpulse,b1.m_linearVelocity.x+=invMass1*motorImpulse*this.m_motorJacobian.linear1.x,b1.m_linearVelocity.y+=invMass1*motorImpulse*this.m_motorJacobian.linear1.y,b1.m_angularVelocity+=invI1*motorImpulse*this.m_motorJacobian.angular1,b2.m_linearVelocity.x+=invMass2*motorImpulse*this.m_motorJacobian.linear2.x,b2.m_linearVelocity.y+=invMass2*motorImpulse*this.m_motorJacobian.linear2.y,b2.m_angularVelocity+=invI2*motorImpulse*this.m_motorJacobian.angular2}if(this.m_enableLimit&&this.m_limitState!=b2Joint.e_inactiveLimit){var limitCdot=this.m_motorJacobian.Compute(b1.m_linearVelocity,b1.m_angularVelocity,b2.m_linearVelocity,b2.m_angularVelocity),limitImpulse=-this.m_motorMass*limitCdot;this.m_limitState==b2Joint.e_equalLimits?this.m_limitImpulse+=limitImpulse:this.m_limitState==b2Joint.e_atLowerLimit?(oldLimitImpulse=this.m_limitImpulse,this.m_limitImpulse=b2Math.b2Max(this.m_limitImpulse+limitImpulse,0),limitImpulse=this.m_limitImpulse-oldLimitImpulse):this.m_limitState==b2Joint.e_atUpperLimit&&(oldLimitImpulse=this.m_limitImpulse,this.m_limitImpulse=b2Math.b2Min(this.m_limitImpulse+limitImpulse,0),limitImpulse=this.m_limitImpulse-oldLimitImpulse),b1.m_linearVelocity.x+=invMass1*limitImpulse*this.m_motorJacobian.linear1.x,b1.m_linearVelocity.y+=invMass1*limitImpulse*this.m_motorJacobian.linear1.y,b1.m_angularVelocity+=invI1*limitImpulse*this.m_motorJacobian.angular1,b2.m_linearVelocity.x+=invMass2*limitImpulse*this.m_motorJacobian.linear2.x,b2.m_linearVelocity.y+=invMass2*limitImpulse*this.m_motorJacobian.linear2.y,b2.m_angularVelocity+=invI2*limitImpulse*this.m_motorJacobian.angular2}},SolvePositionConstraints:function(){var limitC,oldLimitImpulse,tMat,b1=this.m_body1,b2=this.m_body2,invMass1=b1.m_invMass,invMass2=b2.m_invMass,invI1=b1.m_invI,invI2=b2.m_invI,r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,p1X=b1.m_position.x+r1X,p1Y=b1.m_position.y+r1Y,p2X=b2.m_position.x+r2X,p2Y=b2.m_position.y+r2Y,dX=p2X-p1X,dY=p2Y-p1Y,linearC=((tMat=b1.m_R).col1.x*this.m_localYAxis1.x+tMat.col2.x*this.m_localYAxis1.y)*dX+(tMat.col1.y*this.m_localYAxis1.x+tMat.col2.y*this.m_localYAxis1.y)*dY;linearC=b2Math.b2Clamp(linearC,-b2Settings.b2_maxLinearCorrection,b2Settings.b2_maxLinearCorrection);var linearImpulse=-this.m_linearMass*linearC;b1.m_position.x+=invMass1*linearImpulse*this.m_linearJacobian.linear1.x,b1.m_position.y+=invMass1*linearImpulse*this.m_linearJacobian.linear1.y,b1.m_rotation+=invI1*linearImpulse*this.m_linearJacobian.angular1,b2.m_position.x+=invMass2*linearImpulse*this.m_linearJacobian.linear2.x,b2.m_position.y+=invMass2*linearImpulse*this.m_linearJacobian.linear2.y,b2.m_rotation+=invI2*linearImpulse*this.m_linearJacobian.angular2;var positionError=b2Math.b2Abs(linearC),angularC=b2.m_rotation-b1.m_rotation-this.m_initialAngle;angularC=b2Math.b2Clamp(angularC,-b2Settings.b2_maxAngularCorrection,b2Settings.b2_maxAngularCorrection);var angularImpulse=-this.m_angularMass*angularC;b1.m_rotation-=b1.m_invI*angularImpulse,b1.m_R.Set(b1.m_rotation),b2.m_rotation+=b2.m_invI*angularImpulse,b2.m_R.Set(b2.m_rotation);var angularError=b2Math.b2Abs(angularC);if(this.m_enableLimit&&this.m_limitState!=b2Joint.e_inactiveLimit){r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,p1X=b1.m_position.x+r1X,p1Y=b1.m_position.y+r1Y,dX=(p2X=b2.m_position.x+r2X)-p1X,dY=(p2Y=b2.m_position.y+r2Y)-p1Y;var translation=((tMat=b1.m_R).col1.x*this.m_localXAxis1.x+tMat.col2.x*this.m_localXAxis1.y)*dX+(tMat.col1.y*this.m_localXAxis1.x+tMat.col2.y*this.m_localXAxis1.y)*dY,limitImpulse=0;this.m_limitState==b2Joint.e_equalLimits?(limitC=b2Math.b2Clamp(translation,-b2Settings.b2_maxLinearCorrection,b2Settings.b2_maxLinearCorrection),limitImpulse=-this.m_motorMass*limitC,positionError=b2Math.b2Max(positionError,b2Math.b2Abs(angularC))):this.m_limitState==b2Joint.e_atLowerLimit?(limitC=translation-this.m_lowerTranslation,positionError=b2Math.b2Max(positionError,-limitC),limitC=b2Math.b2Clamp(limitC+b2Settings.b2_linearSlop,-b2Settings.b2_maxLinearCorrection,0),limitImpulse=-this.m_motorMass*limitC,oldLimitImpulse=this.m_limitPositionImpulse,this.m_limitPositionImpulse=b2Math.b2Max(this.m_limitPositionImpulse+limitImpulse,0),limitImpulse=this.m_limitPositionImpulse-oldLimitImpulse):this.m_limitState==b2Joint.e_atUpperLimit&&(limitC=translation-this.m_upperTranslation,positionError=b2Math.b2Max(positionError,limitC),limitC=b2Math.b2Clamp(limitC-b2Settings.b2_linearSlop,0,b2Settings.b2_maxLinearCorrection),limitImpulse=-this.m_motorMass*limitC,oldLimitImpulse=this.m_limitPositionImpulse,this.m_limitPositionImpulse=b2Math.b2Min(this.m_limitPositionImpulse+limitImpulse,0),limitImpulse=this.m_limitPositionImpulse-oldLimitImpulse),b1.m_position.x+=invMass1*limitImpulse*this.m_motorJacobian.linear1.x,b1.m_position.y+=invMass1*limitImpulse*this.m_motorJacobian.linear1.y,b1.m_rotation+=invI1*limitImpulse*this.m_motorJacobian.angular1,b1.m_R.Set(b1.m_rotation),b2.m_position.x+=invMass2*limitImpulse*this.m_motorJacobian.linear2.x,b2.m_position.y+=invMass2*limitImpulse*this.m_motorJacobian.linear2.y,b2.m_rotation+=invI2*limitImpulse*this.m_motorJacobian.angular2,b2.m_R.Set(b2.m_rotation)}return positionError<=b2Settings.b2_linearSlop&&angularError<=b2Settings.b2_angularSlop},m_localAnchor1:new b2Vec2,m_localAnchor2:new b2Vec2,m_localXAxis1:new b2Vec2,m_localYAxis1:new b2Vec2,m_initialAngle:null,m_linearJacobian:new b2Jacobian,m_linearMass:null,m_linearImpulse:null,m_angularMass:null,m_angularImpulse:null,m_motorJacobian:new b2Jacobian,m_motorMass:null,m_motorImpulse:null,m_limitImpulse:null,m_limitPositionImpulse:null,m_lowerTranslation:null,m_upperTranslation:null,m_maxMotorForce:null,m_motorSpeed:null,m_enableLimit:null,m_enableMotor:null,m_limitState:0});var b2PrismaticJointDef=Class.create();Object.extend(b2PrismaticJointDef.prototype,b2JointDef.prototype),Object.extend(b2PrismaticJointDef.prototype,{initialize:function(){this.type=b2Joint.e_unknownJoint,this.userData=null,this.body1=null,this.body2=null,this.collideConnected=!1,this.type=b2Joint.e_prismaticJoint,this.anchorPoint=new b2Vec2(0,0),this.axis=new b2Vec2(0,0),this.lowerTranslation=0,this.upperTranslation=0,this.motorForce=0,this.motorSpeed=0,this.enableLimit=!1,this.enableMotor=!1},anchorPoint:null,axis:null,lowerTranslation:null,upperTranslation:null,motorForce:null,motorSpeed:null,enableLimit:null,enableMotor:null});var b2PulleyJoint=Class.create();Object.extend(b2PulleyJoint.prototype,b2Joint.prototype),Object.extend(b2PulleyJoint.prototype,{GetAnchor1:function(){var tMat=this.m_body1.m_R;return new b2Vec2(this.m_body1.m_position.x+(tMat.col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y),this.m_body1.m_position.y+(tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y))},GetAnchor2:function(){var tMat=this.m_body2.m_R;return new b2Vec2(this.m_body2.m_position.x+(tMat.col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y),this.m_body2.m_position.y+(tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y))},GetGroundPoint1:function(){return new b2Vec2(this.m_ground.m_position.x+this.m_groundAnchor1.x,this.m_ground.m_position.y+this.m_groundAnchor1.y)},GetGroundPoint2:function(){return new b2Vec2(this.m_ground.m_position.x+this.m_groundAnchor2.x,this.m_ground.m_position.y+this.m_groundAnchor2.y)},GetReactionForce:function(invTimeStep){return new b2Vec2},GetReactionTorque:function(invTimeStep){return 0},GetLength1:function(){var tMat;tMat=this.m_body1.m_R;var pX=this.m_body1.m_position.x+(tMat.col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y),pY=this.m_body1.m_position.y+(tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y),dX=pX-(this.m_ground.m_position.x+this.m_groundAnchor1.x),dY=pY-(this.m_ground.m_position.y+this.m_groundAnchor1.y);return Math.sqrt(dX*dX+dY*dY)},GetLength2:function(){var tMat;tMat=this.m_body2.m_R;var pX=this.m_body2.m_position.x+(tMat.col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y),pY=this.m_body2.m_position.y+(tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y),dX=pX-(this.m_ground.m_position.x+this.m_groundAnchor2.x),dY=pY-(this.m_ground.m_position.y+this.m_groundAnchor2.y);return Math.sqrt(dX*dX+dY*dY)},GetRatio:function(){return this.m_ratio},initialize:function(def){var tMat,tX,tY;this.m_node1=new b2JointNode,this.m_node2=new b2JointNode,this.m_type=def.type,this.m_prev=null,this.m_next=null,this.m_body1=def.body1,this.m_body2=def.body2,this.m_collideConnected=def.collideConnected,this.m_islandFlag=!1,this.m_userData=def.userData,this.m_groundAnchor1=new b2Vec2,this.m_groundAnchor2=new b2Vec2,this.m_localAnchor1=new b2Vec2,this.m_localAnchor2=new b2Vec2,this.m_u1=new b2Vec2,this.m_u2=new b2Vec2,this.m_ground=this.m_body1.m_world.m_groundBody,this.m_groundAnchor1.x=def.groundPoint1.x-this.m_ground.m_position.x,this.m_groundAnchor1.y=def.groundPoint1.y-this.m_ground.m_position.y,this.m_groundAnchor2.x=def.groundPoint2.x-this.m_ground.m_position.x,this.m_groundAnchor2.y=def.groundPoint2.y-this.m_ground.m_position.y,tMat=this.m_body1.m_R,tX=def.anchorPoint1.x-this.m_body1.m_position.x,tY=def.anchorPoint1.y-this.m_body1.m_position.y,this.m_localAnchor1.x=tX*tMat.col1.x+tY*tMat.col1.y,this.m_localAnchor1.y=tX*tMat.col2.x+tY*tMat.col2.y,tMat=this.m_body2.m_R,tX=def.anchorPoint2.x-this.m_body2.m_position.x,tY=def.anchorPoint2.y-this.m_body2.m_position.y,this.m_localAnchor2.x=tX*tMat.col1.x+tY*tMat.col1.y,this.m_localAnchor2.y=tX*tMat.col2.x+tY*tMat.col2.y,this.m_ratio=def.ratio,tX=def.groundPoint1.x-def.anchorPoint1.x,tY=def.groundPoint1.y-def.anchorPoint1.y;var d1Len=Math.sqrt(tX*tX+tY*tY);tX=def.groundPoint2.x-def.anchorPoint2.x,tY=def.groundPoint2.y-def.anchorPoint2.y;var d2Len=Math.sqrt(tX*tX+tY*tY),length1=b2Math.b2Max(.5*b2PulleyJoint.b2_minPulleyLength,d1Len),length2=b2Math.b2Max(.5*b2PulleyJoint.b2_minPulleyLength,d2Len);this.m_constant=length1+this.m_ratio*length2,this.m_maxLength1=b2Math.b2Clamp(def.maxLength1,length1,this.m_constant-this.m_ratio*b2PulleyJoint.b2_minPulleyLength),this.m_maxLength2=b2Math.b2Clamp(def.maxLength2,length2,(this.m_constant-b2PulleyJoint.b2_minPulleyLength)/this.m_ratio),this.m_pulleyImpulse=0,this.m_limitImpulse1=0,this.m_limitImpulse2=0},PrepareVelocitySolver:function(){var tMat,b1=this.m_body1,b2=this.m_body2,r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,p1X=b1.m_position.x+r1X,p1Y=b1.m_position.y+r1Y,p2X=b2.m_position.x+r2X,p2Y=b2.m_position.y+r2Y,s1X=this.m_ground.m_position.x+this.m_groundAnchor1.x,s1Y=this.m_ground.m_position.y+this.m_groundAnchor1.y,s2X=this.m_ground.m_position.x+this.m_groundAnchor2.x,s2Y=this.m_ground.m_position.y+this.m_groundAnchor2.y;this.m_u1.Set(p1X-s1X,p1Y-s1Y),this.m_u2.Set(p2X-s2X,p2Y-s2Y);var length1=this.m_u1.Length(),length2=this.m_u2.Length();length1>b2Settings.b2_linearSlop?this.m_u1.Multiply(1/length1):this.m_u1.SetZero(),length2>b2Settings.b2_linearSlop?this.m_u2.Multiply(1/length2):this.m_u2.SetZero(),length1b2Settings.b2_linearSlop?this.m_u1.Multiply(1/length1):this.m_u1.SetZero(),length2>b2Settings.b2_linearSlop?this.m_u2.Multiply(1/length2):this.m_u2.SetZero(),C=this.m_constant-length1-this.m_ratio*length2,linearError=b2Math.b2Max(linearError,Math.abs(C)),C=b2Math.b2Clamp(C,-b2Settings.b2_maxLinearCorrection,b2Settings.b2_maxLinearCorrection),p1X=-(impulse=-this.m_pulleyMass*C)*this.m_u1.x,p1Y=-impulse*this.m_u1.y,p2X=-this.m_ratio*impulse*this.m_u2.x,p2Y=-this.m_ratio*impulse*this.m_u2.y,b1.m_position.x+=b1.m_invMass*p1X,b1.m_position.y+=b1.m_invMass*p1Y,b1.m_rotation+=b1.m_invI*(r1X*p1Y-r1Y*p1X),b2.m_position.x+=b2.m_invMass*p2X,b2.m_position.y+=b2.m_invMass*p2Y,b2.m_rotation+=b2.m_invI*(r2X*p2Y-r2Y*p2X),b1.m_R.Set(b1.m_rotation),b2.m_R.Set(b2.m_rotation),this.m_limitState1==b2Joint.e_atUpperLimit&&(r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,p1X=b1.m_position.x+r1X,p1Y=b1.m_position.y+r1Y,this.m_u1.Set(p1X-s1X,p1Y-s1Y),(length1=this.m_u1.Length())>b2Settings.b2_linearSlop?(this.m_u1.x*=1/length1,this.m_u1.y*=1/length1):this.m_u1.SetZero(),C=this.m_maxLength1-length1,linearError=b2Math.b2Max(linearError,-C),C=b2Math.b2Clamp(C+b2Settings.b2_linearSlop,-b2Settings.b2_maxLinearCorrection,0),impulse=-this.m_limitMass1*C,oldLimitPositionImpulse=this.m_limitPositionImpulse1,this.m_limitPositionImpulse1=b2Math.b2Max(0,this.m_limitPositionImpulse1+impulse),p1X=-(impulse=this.m_limitPositionImpulse1-oldLimitPositionImpulse)*this.m_u1.x,p1Y=-impulse*this.m_u1.y,b1.m_position.x+=b1.m_invMass*p1X,b1.m_position.y+=b1.m_invMass*p1Y,b1.m_rotation+=b1.m_invI*(r1X*p1Y-r1Y*p1X),b1.m_R.Set(b1.m_rotation)),this.m_limitState2==b2Joint.e_atUpperLimit&&(r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,p2X=b2.m_position.x+r2X,p2Y=b2.m_position.y+r2Y,this.m_u2.Set(p2X-s2X,p2Y-s2Y),(length2=this.m_u2.Length())>b2Settings.b2_linearSlop?(this.m_u2.x*=1/length2,this.m_u2.y*=1/length2):this.m_u2.SetZero(),C=this.m_maxLength2-length2,linearError=b2Math.b2Max(linearError,-C),C=b2Math.b2Clamp(C+b2Settings.b2_linearSlop,-b2Settings.b2_maxLinearCorrection,0),impulse=-this.m_limitMass2*C,oldLimitPositionImpulse=this.m_limitPositionImpulse2,this.m_limitPositionImpulse2=b2Math.b2Max(0,this.m_limitPositionImpulse2+impulse),p2X=-(impulse=this.m_limitPositionImpulse2-oldLimitPositionImpulse)*this.m_u2.x,p2Y=-impulse*this.m_u2.y,b2.m_position.x+=b2.m_invMass*p2X,b2.m_position.y+=b2.m_invMass*p2Y,b2.m_rotation+=b2.m_invI*(r2X*p2Y-r2Y*p2X),b2.m_R.Set(b2.m_rotation)),linearError=this.m_upperAngle?(this.m_limitState!=b2Joint.e_atUpperLimit&&(this.m_limitImpulse=0),this.m_limitState=b2Joint.e_atUpperLimit):(this.m_limitState=b2Joint.e_inactiveLimit,this.m_limitImpulse=0)}else this.m_limitImpulse=0;b2World.s_enableWarmStarting?(b1.m_linearVelocity.x-=invMass1*this.m_ptpImpulse.x,b1.m_linearVelocity.y-=invMass1*this.m_ptpImpulse.y,b1.m_angularVelocity-=invI1*(r1X*this.m_ptpImpulse.y-r1Y*this.m_ptpImpulse.x+this.m_motorImpulse+this.m_limitImpulse),b2.m_linearVelocity.x+=invMass2*this.m_ptpImpulse.x,b2.m_linearVelocity.y+=invMass2*this.m_ptpImpulse.y,b2.m_angularVelocity+=invI2*(r2X*this.m_ptpImpulse.y-r2Y*this.m_ptpImpulse.x+this.m_motorImpulse+this.m_limitImpulse)):(this.m_ptpImpulse.SetZero(),this.m_motorImpulse=0,this.m_limitImpulse=0),this.m_limitPositionImpulse=0},SolveVelocityConstraints:function(step){var tMat,oldLimitImpulse,b1=this.m_body1,b2=this.m_body2,r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,ptpCdotX=b2.m_linearVelocity.x+-b2.m_angularVelocity*r2Y-b1.m_linearVelocity.x- -b1.m_angularVelocity*r1Y,ptpCdotY=b2.m_linearVelocity.y+b2.m_angularVelocity*r2X-b1.m_linearVelocity.y-b1.m_angularVelocity*r1X,ptpImpulseX=-(this.m_ptpMass.col1.x*ptpCdotX+this.m_ptpMass.col2.x*ptpCdotY),ptpImpulseY=-(this.m_ptpMass.col1.y*ptpCdotX+this.m_ptpMass.col2.y*ptpCdotY);if(this.m_ptpImpulse.x+=ptpImpulseX,this.m_ptpImpulse.y+=ptpImpulseY,b1.m_linearVelocity.x-=b1.m_invMass*ptpImpulseX,b1.m_linearVelocity.y-=b1.m_invMass*ptpImpulseY,b1.m_angularVelocity-=b1.m_invI*(r1X*ptpImpulseY-r1Y*ptpImpulseX),b2.m_linearVelocity.x+=b2.m_invMass*ptpImpulseX,b2.m_linearVelocity.y+=b2.m_invMass*ptpImpulseY,b2.m_angularVelocity+=b2.m_invI*(r2X*ptpImpulseY-r2Y*ptpImpulseX),this.m_enableMotor&&this.m_limitState!=b2Joint.e_equalLimits){var motorCdot=b2.m_angularVelocity-b1.m_angularVelocity-this.m_motorSpeed,motorImpulse=-this.m_motorMass*motorCdot,oldMotorImpulse=this.m_motorImpulse;this.m_motorImpulse=b2Math.b2Clamp(this.m_motorImpulse+motorImpulse,-step.dt*this.m_maxMotorTorque,step.dt*this.m_maxMotorTorque),motorImpulse=this.m_motorImpulse-oldMotorImpulse,b1.m_angularVelocity-=b1.m_invI*motorImpulse,b2.m_angularVelocity+=b2.m_invI*motorImpulse}if(this.m_enableLimit&&this.m_limitState!=b2Joint.e_inactiveLimit){var limitCdot=b2.m_angularVelocity-b1.m_angularVelocity,limitImpulse=-this.m_motorMass*limitCdot;this.m_limitState==b2Joint.e_equalLimits?this.m_limitImpulse+=limitImpulse:this.m_limitState==b2Joint.e_atLowerLimit?(oldLimitImpulse=this.m_limitImpulse,this.m_limitImpulse=b2Math.b2Max(this.m_limitImpulse+limitImpulse,0),limitImpulse=this.m_limitImpulse-oldLimitImpulse):this.m_limitState==b2Joint.e_atUpperLimit&&(oldLimitImpulse=this.m_limitImpulse,this.m_limitImpulse=b2Math.b2Min(this.m_limitImpulse+limitImpulse,0),limitImpulse=this.m_limitImpulse-oldLimitImpulse),b1.m_angularVelocity-=b1.m_invI*limitImpulse,b2.m_angularVelocity+=b2.m_invI*limitImpulse}},SolvePositionConstraints:function(){var oldLimitImpulse,limitC,positionError,tMat,b1=this.m_body1,b2=this.m_body2,r1X=(tMat=b1.m_R).col1.x*this.m_localAnchor1.x+tMat.col2.x*this.m_localAnchor1.y,r1Y=tMat.col1.y*this.m_localAnchor1.x+tMat.col2.y*this.m_localAnchor1.y,r2X=(tMat=b2.m_R).col1.x*this.m_localAnchor2.x+tMat.col2.x*this.m_localAnchor2.y,r2Y=tMat.col1.y*this.m_localAnchor2.x+tMat.col2.y*this.m_localAnchor2.y,p1X=b1.m_position.x+r1X,p1Y=b1.m_position.y+r1Y,ptpCX=b2.m_position.x+r2X-p1X,ptpCY=b2.m_position.y+r2Y-p1Y;positionError=Math.sqrt(ptpCX*ptpCX+ptpCY*ptpCY);var invMass1=b1.m_invMass,invMass2=b2.m_invMass,invI1=b1.m_invI,invI2=b2.m_invI;this.K1.col1.x=invMass1+invMass2,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=invMass1+invMass2,this.K2.col1.x=invI1*r1Y*r1Y,this.K2.col2.x=-invI1*r1X*r1Y,this.K2.col1.y=-invI1*r1X*r1Y,this.K2.col2.y=invI1*r1X*r1X,this.K3.col1.x=invI2*r2Y*r2Y,this.K3.col2.x=-invI2*r2X*r2Y,this.K3.col1.y=-invI2*r2X*r2Y,this.K3.col2.y=invI2*r2X*r2X,this.K.SetM(this.K1),this.K.AddM(this.K2),this.K.AddM(this.K3),this.K.Solve(b2RevoluteJoint.tImpulse,-ptpCX,-ptpCY);var impulseX=b2RevoluteJoint.tImpulse.x,impulseY=b2RevoluteJoint.tImpulse.y;b1.m_position.x-=b1.m_invMass*impulseX,b1.m_position.y-=b1.m_invMass*impulseY,b1.m_rotation-=b1.m_invI*(r1X*impulseY-r1Y*impulseX),b1.m_R.Set(b1.m_rotation),b2.m_position.x+=b2.m_invMass*impulseX,b2.m_position.y+=b2.m_invMass*impulseY,b2.m_rotation+=b2.m_invI*(r2X*impulseY-r2Y*impulseX),b2.m_R.Set(b2.m_rotation);var angularError=0;if(this.m_enableLimit&&this.m_limitState!=b2Joint.e_inactiveLimit){var angle=b2.m_rotation-b1.m_rotation-this.m_intialAngle,limitImpulse=0;this.m_limitState==b2Joint.e_equalLimits?(limitC=b2Math.b2Clamp(angle,-b2Settings.b2_maxAngularCorrection,b2Settings.b2_maxAngularCorrection),limitImpulse=-this.m_motorMass*limitC,angularError=b2Math.b2Abs(limitC)):this.m_limitState==b2Joint.e_atLowerLimit?(limitC=angle-this.m_lowerAngle,angularError=b2Math.b2Max(0,-limitC),limitC=b2Math.b2Clamp(limitC+b2Settings.b2_angularSlop,-b2Settings.b2_maxAngularCorrection,0),limitImpulse=-this.m_motorMass*limitC,oldLimitImpulse=this.m_limitPositionImpulse,this.m_limitPositionImpulse=b2Math.b2Max(this.m_limitPositionImpulse+limitImpulse,0),limitImpulse=this.m_limitPositionImpulse-oldLimitImpulse):this.m_limitState==b2Joint.e_atUpperLimit&&(limitC=angle-this.m_upperAngle,angularError=b2Math.b2Max(0,limitC),limitC=b2Math.b2Clamp(limitC-b2Settings.b2_angularSlop,0,b2Settings.b2_maxAngularCorrection),limitImpulse=-this.m_motorMass*limitC,oldLimitImpulse=this.m_limitPositionImpulse,this.m_limitPositionImpulse=b2Math.b2Min(this.m_limitPositionImpulse+limitImpulse,0),limitImpulse=this.m_limitPositionImpulse-oldLimitImpulse),b1.m_rotation-=b1.m_invI*limitImpulse,b1.m_R.Set(b1.m_rotation),b2.m_rotation+=b2.m_invI*limitImpulse,b2.m_R.Set(b2.m_rotation)}return positionError<=b2Settings.b2_linearSlop&&angularError<=b2Settings.b2_angularSlop},m_localAnchor1:new b2Vec2,m_localAnchor2:new b2Vec2,m_ptpImpulse:new b2Vec2,m_motorImpulse:null,m_limitImpulse:null,m_limitPositionImpulse:null,m_ptpMass:new b2Mat22,m_motorMass:null,m_intialAngle:null,m_lowerAngle:null,m_upperAngle:null,m_maxMotorTorque:null,m_motorSpeed:null,m_enableLimit:null,m_enableMotor:null,m_limitState:0}),b2RevoluteJoint.tImpulse=new b2Vec2;var b2RevoluteJointDef=Class.create();Object.extend(b2RevoluteJointDef.prototype,b2JointDef.prototype),Object.extend(b2RevoluteJointDef.prototype,{initialize:function(){this.type=b2Joint.e_unknownJoint,this.userData=null,this.body1=null,this.body2=null,this.collideConnected=!1,this.type=b2Joint.e_revoluteJoint,this.anchorPoint=new b2Vec2(0,0),this.lowerAngle=0,this.upperAngle=0,this.motorTorque=0,this.motorSpeed=0,this.enableLimit=!1,this.enableMotor=!1},anchorPoint:null,lowerAngle:null,upperAngle:null,motorTorque:null,motorSpeed:null,enableLimit:null,enableMotor:null});