首页 > 其他 > 详细

2016/02/25 codes

时间:2016-02-25 22:49:03      阅读:247      评论:0      收藏:0      [点我收藏+]

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;
};

}

2016/02/25 codes

原文:http://www.cnblogs.com/whatcanido/p/5218587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!