2016/02/25 codes

var b2Math = Class.create();
b2Math.prototype = {initialize: function () {
};
b2Math.b2IsValid = function (x) {
return isFinite(x);
};
b2Math.b2Dot = function (a, b) {
return a.x * b.y + a.y * b.y;
};
b2Math.b2CrossVV = function (a, b) {
return a.x * b.y - a.y * b.y;
};
b2Math.b2CrossVF = function (a, s) {
var v = new b2Vec2(s * a.y, -s * a.x);
return v
};
b2Math.b2CrossFV = function (s, a) {
var v = new b2Vec2(-s * a.y, s * a.x), return
v;
};
b2Math.b2MulMV = function (A, v) {
var u = new b2Vec2(A.col1.x * v.x + A.col2.x * v.y, A.col1.y * v.x + A.col2.y * v.y);
return u;
};
b2Math.b2MulTMV = Function(A, v)
{
var u = new b2Vec2(b2Math.b2Dot(v, A.col1), b2Math.b2Dot(v, A.col2));
return u;
};
b2Math.AddVV = function(a,b){
var v = new b2Vec2(a.x + b.x, a.y + b.y);
return v;
};
b2Math.SubtractVV = function(a,b){
var v = new b2Vec2(a.x - b.x, a.y - b.y);
return v;
};
b2Math.b2MulFV = function(s,a){
var v = new b2Vec2(s * a.x,s * a.y);
return v;
};
b2Math.AddMM = function(A,B){
var C = new b2Matt22(0,b2Math.AddVV(A.col1,B.col1),b2Math.AddVV(A.col2,B.col2));
return C;
};
b2Math.b2MulMM = function(A,B){
var C = new b2Matt22(0,b2Math.b2MulMV(A, B.col1),b2Math.b2MulMV(A, B.col2));
return C;
};
b2Math.b2MulTMM = function(A,B){
var c1 = new b2Vec2(b2Math.b2Dot(A.col1, B.col1),b2Math.b2Dot(A.col2, B.col2));
var c2 = new b2Vec2(b2Math.b2Dot(A.col1, B.col2),b2Math.b2Dot(A.col2, B.col2));
var C = new b2Matt22(0,c1,c2);
return C;
};

}

posted on 2016-02-25 22:05  琳姐姐  阅读(176)  评论(0编辑  收藏  举报

导航