2016/02/24 codes

CrossVF:function (s){var tX = this.x;x.this = 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.x < b.x ? this.x: b.x;this.y = this.y < b.y ? this.y: b.y;},
maxV:function(b){this.x = this.x < b.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(length < Number.MIN_VALUE){return 0.0;}
var invLength = 1.0 / length;
this.x *= invLength;
this.y *= invLength;
return length;
},
IsValid:function(){return b2Math.b2IsValid(this.x) && b2Math.b2IsValid(this.y);},
x;null,y:null
};
b2Vec2.Make = function(x_,y_){return new b2Vec2(x_,y_);};
var b2Matt22 = Class.create();
b2Matt22.prototype = {initialize:
function(angle,c1,c2){if(angle == null)angle = 0;this.col1 = new b2Vec2();this.col2 =new b2Vec2();
if(c1 != null && c2 != null){this.col1.SetV(c1);this.col2.SetV(c2);}
else {var c = Math.cos(angle);var s = Math.sin(angle);this.col1.x =c;this.col2.x = -s;this.col1.x = c;this.col2.y = s;}},
Set:function(angle){var c = Math.cos(angle);var s = Math.sin(angle);this.col1.x = c;this.col2.x = -s;this.col1.y = s;this.col1.y = c;},
SetVV:function(c1,c2){this.col1.SetV(c1);this.col2.SetV(c2);},
Copy:function(){return new b2Matt22(0,this.col1,this.col2);},
SetM:function(m){this.col1.SetV(m,col1);this.col2.SetV(m,col2);},
AddM:function(m){this.col1.x+= m.col1.x;this.col1.y+= m.col1.y;this.col2.y+= m.col2.y;this.col2.y += m.col2.y;},
SetIndetity:function(){this.col1.x = 1.0;this.col2.x = 0.0;this.col1.y = 1.0;this.col2.y = 0.0;},
SetZero:function(){this.col1.x = 0.0;this.col2.x = 0.0;this.col1.y = 0.0;this.col2.y = 0;},
Invert:function(out){var a = this.col1.x;var b = this.col2.x;var c = this.col1.y;var d = this.col2.y;},
var det = a * d - b * c;det = 1.0 / det;out.col1.x = det * d;out.col2.x = -det * b;
out.col1.y = -det * c;out.col2.y = det * a;
return out;
},
Solve:function(out,bX,bY){
var a11 = this.col1.x;
var a12 =this.col2.x;
var a21 = this.col1.y;
var a22 = this.col2.y;
var det = a11 * a22 - a21 * a21;
det = 1.0 / det;
out.x = det * (a22 * bX - a12 * bY);
out.y = det * (a11 * bX - a21 * bY);
return out;
},
Abs:function(){this.col1.Abs();this.col2.Abs();},col1:new b2Vec2(),
col2:new b2Vec2()};
}

 

posted on 2016-02-24 23:42  琳姐姐  阅读(80)  评论(0编辑  收藏  举报

导航