func TestGetVelocityInLocalPoint(t *testing.T) { b := newBody(NewSphere(1)).SetMaterial(0.5, 0.8).(*body) b.lvel.SetS(2, 2, 2) b.avel.SetS(3, 3, 3) v, p, want := lin.NewV3(), lin.NewV3S(1, 1, 1), "{2.0 2.0 2.0}" if b.getVelocityInLocalPoint(p, v); dumpV3(v) != want { t.Errorf("Expecting local velocity %s, got %s", dumpV3(v), want) } }
func TestCollideBoxBox1(t *testing.T) { slab := newBody(NewBox(50, 50, 50)).setMaterial(0, 0) slab.World().Loc.SetS(0, -50, 0) box := newBody(NewBox(1, 1, 1)).setMaterial(1, 0) box.World().Loc.SetS(-5.000000, 1.388000, -3.000000) box.World().Rot.SetS(0.182574, 0.365148, 0.547723, 0.730297) wantPoint, wantDepth := lin.NewV3S(-5.2, -0.1, -4.0), -0.108 _, _, cs := collideBoxBox(slab, box, newManifold()) if !lin.Aeq(cs[0].depth, wantDepth) || dumpV3(cs[0].point) != dumpV3(wantPoint) { t.Errorf("Got point %s wanted %s. Got depth %f wanted %f", dumpV3(cs[0].point), dumpV3(wantPoint), cs[0].depth, wantDepth) } }