2016/03/07 codes

Posted 琳姐姐

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2016/03/07 codes相关的知识,希望对你有一定的参考价值。

Features.prototype = {
set_referenceFace:function(value){
this._referenceFace = value;
this._m_id._key = (this._m_id._key & 0xffffff00) | (this._referenceFace & 0x000000ff)
},
get_referenceFace:function(){return this._referenceFace;},_referenceFace:0,
set_incidentEdge:function(value){
this._incidentEdge = value;
this._m_id._key = (this._m_id._key & 0x000000ff) | ((this._incidentEdge<<8) & 0xffffff00)
},
get_incidentEdge:function(){return this._incidentEdge;},_incidentEdge:0,
}
set_incidentVertex:function(value){
this._incidentVertex = value;
this._m_id._key = (this._m_id._key & 0x000000ff) | ((this._incidentEdge<<16) & 0x00ff0000)
},
get_incidentVertex = function(){return this._incidentVertex;},_incidentVertex = 0;
set_filp:function(value){ this.flip = value;this._m_id._key=(this._m_id._key&0x00ffffff)|((this._flip<<24)&0xff000000)},
get_flip:function(){return this._filp;},_filp = 0,_m_id = null,initialize:function(){}
};
var b2ContaceID = Class.create();
b2ContaceID.prototype = {
inizialize:function(){this.features = new Features();this.features._m_id = this;},
Set:function(id){this.set_key(id,_key)},
Copy:function(){var id = new b2ContactID();id.set_key(this._key);return id;},
get_key:function(){return this._key;},
set_key:function(value){this._key = value;
this.features._referenceFace = this._key & 0x000000ff;
this.features._incidentEdge = ((this._key & 0x0000ff00) >> 8) & 0x000000ff;
this.features._incidentVertex = ((this._key & 0x00ff0000) >> 16) & 0x000000ff;
this.features._flip = ((this._key & 0xff000000) >> 24) & 0x000000ff;
},
features:new Features(),_key:0
};
var b2ContactPoint = Class.create();
b2ContactPoint.prototype = {
position:new b2Vec2();
separation:null,normalImplus:null,tangeImplus:null,id:new b2ContaceID(),
initialize:function(){this.position = new b2Vec2();this.id = new b2ContaceID();}
};
var b2Distance = Class.create();
b2Distance.prototype = {
initialize:function(){}
};
b2Distance.processTwo = function(p1Out,p2Out,p1s,p2s,points){
var rX = -points[1].x; var rY = -points[1].y;
var dX = points[0].x - points[1].x; var dY = points[0].y - points[1].y;
var length = Math.sqrt(dX * dX + dY * dY);
dX /= length;dY /= length;
var lambda = rX * dX + rY * dY;
if(lambda <= 0.0 || length < Number.MIN_VALUE){
p1Out = SetV(p1s[1]);p2Out = SetV(p2s[1]);
p1s[0].SetV(p1s[1]);p2s[0].SetV(p2s[1]);
points[0].SetV(points[1]);
return 1;
}
lambda /= length;
p1Out.x = p1s[1].x + lambda * (p1s[0].x - p1s[1].x);
p1Out.y = p1s[1].y + lambda * (p1s[0].y - p1s[1].y);
p2Out.x = p2s[1].x + lambda * (p2s[0].x - p2s[1].x);
p2Out.y = p2s[1].y + lambda * (p2s[0].y - p2s[1].y);
return 2;
};
b2Distance.processThree = function(p1Out,p2Out,p1s,p2s,points){
var aX = points[0].x; var aY = points[0].y;
var bX = points[1].x; var bY = points[1].y;
var cX = points[2].x; var cY = points[2].y;
var abX = bX - aX; var abY = bY - aY;
var acX = cX - aX; var acY = cY - aY;
var bcX = cX - bX; var bcY = cY - bY;
var sn = -(aX * abX + aY * abY);
var sd = (bX * abX + bY * abY);
var tn = -(cX * acX + cY * acY);
var td = (cX * acX + cY * abY);
var un = -(bX * bcX + bY * bcY);
var ud = (bX * bcX + by * bcY);
if(td <= 0.0 && ud <= 0.0){
p1Out.SetV(p1s[2]);p2Out.SetV(p2s[2]);
p1s[0].SetV(p1s[2]);p2s[0].SetV(p2s[2]);
points[0].SetV(points[2]);
return 1;
}
var n = abX * acY - abY * acX;
var vc = n * (aX * bY - aY * bX);
var va = n * (bX * cY - bY * cX);
if(va <= 0.0 && un >= 0.0 && ud >= 0.0){
var lambda = un / (un + ud);
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[2].x);
p2Out.y = p2s[1].y + lambda * (p2s[2].y - p2s[2].y);
p1s[0].SetV(p1s[2]);p2s[0].SetV(p2s[2]);
points[0].SetV(points[2]);
return 2;
}
var vb = n * (cX * aY - aX * cY);
if(vb <= 0.0 && tn >= 0.0 && td >= 0.0){
var lambda = tn / (tn + td);
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(p1s[2]);
points[1].SetV(points[2]);
return 2;
}
var denom = va + vb + vc;
denom = 1.0/denom;
var u = va * denom;
var v = vb * denom;
var w = 1.0 - u - v;
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[2].y + w * p2s[2].y;
return 3;
};
b2Distance.InPoinsts = function(w,points,pointCount){
for(var i = 0;i < pointCount; ++i){if(w.x == points[i].x && w.y == points[i].y){return true;}}
return false;
};
b2Distance.Distance = function(p1Out,p2Out,shape1,shape2){
var p1s = new Array(3); var p2s = new Array(3); var points = new Array(3);
var pointCount = 0;
p1Out.SetV(shape1.m_position);
p2Out.SetV(shape2.m_position);
var vSqr = 0.0;
var maxInterations = 20;
for(var iter = 0;iter < maxInterations;++iter){
var vX = p2Out.x - p1Out.x;
var vY = p2Out.y - p2Out.y;
var w1 = shape1.support(vX,vY);
var w2 = shape2.support(-vX,-vY);
vSqr = (vX * vX + vY * vY);
var wX = w2.x - w1.x;
var wY = w2.y - w1.y;
var vw = (vX * wY + wX * vY);
if(vSqr - b2Dot(vX * wX + vY * wY)<= 0.1 * vSqr){
if(pointCount == 0){p1Out.SetV(w1);p2Out.SetV(w2)}
b2Distance.g_GJK_Iterations = iter;
return Math.sqrt(vSqr);
}
switch (pointCount){
case 0;p1s[0].SetV(w1);
p2s[0].SetV(w2); points[0] = w;
p1Out.SetV(p1s[0]);p2Out.SetV(p2s[0]);
++pointCount;
break:case 1:p1s[1].SetV(w1);
p2s.SetV(w2);
points[1].x = wX;points[1].y = wY;
pointCount = b2Distance.processTwo(p1Out,p2Out,p1s,p2s,points);
break:case 2:p1s[1].SetV(w1);
p2s[2].SetV(w2);
points[2].x = wX;points[2].y = wY;
pointCount = b2Distance.processThree(p1Out,p2Out,p1s,p2s,points);
break;
}
}
}
}

}

以上是关于2016/03/07 codes的主要内容,如果未能解决你的问题,请参考以下文章

2016/03/07 codes

2016 -03 -07 字符串是否包含字符串/字符

DB2 替代 EXISTS 函数

3月第2周网络安全报告:高危漏洞数量涨幅超126%

在时间戳上查询 mongo

请求 Azure 应用服务身份验证刷新令牌