我想一旦碰撞被检测规范化距离(后碰撞) - JavaScript的
正常化两个球之间的距离,碰撞检测
do_shapes_collide: function(shape1,shape2)
{
var reach1 = shape1.radius + shape1.velocity() + vr.o.border_width;
var reach2 = shape2.radius + shape2.velocity() + vr.o.border_width;
var distance = vr.distance(shape1, shape2);
return distance < reach1 + reach2;
},
所以一旦我们确定这些球体相互碰撞,我需要重新设置彼此之间的距离......我用代表点/斜率公式等的代数类获得了闪回......
我已经得到了需要的距离,需要存在于他们和(我相信是的)之间碰撞角度。
我需要设置shape
x/y上的碰撞角度。
我应该从这里做的设置shape
的X和Y什么一片空白......
if (vr.do_shapes_collide(shape, next_shape))
{
var req_distance = shape.radius + next_shape.radius + (vr.o.border_width * 2);
var slope = (shape.y - next_shape.y)/(shape.x - next_shape.x);
shape.x =
shape.y =
}
你是一位圣人,不仅我有我的答案,但我真正理解它。 – jondavidjohn