Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_mesh_collision(self):
a = Cube()
b = Cube(width=2.0, height=1.23, depth=1.0)
b.position = [1.0, 0.2, 0.1]
c = CollisionTest(callback=dummy, objects=[a, b])
check = c._mesh_collision(a, b)
self.assertTrue(check)
def test_bounding_sphere_collision_false(self):
a = Sphere(radius=2.0)
b = Sphere()
b.position = [4.5, 0.5, 0]
c = CollisionTest(callback=dummy, objects=[a, b])
check = c._bounding_sphere_collision(a, b)
self.assertFalse(check)
def test_dist(self):
a = Sphere()
b = Sphere()
b.position = [3, 0, 4]
c = CollisionTest(callback=dummy, objects=[a, b])
dist = c._dist(a, b)
self.assertAlmostEqual(dist, 5)
def test_dist(self):
a = Sphere()
b = Sphere()
b.position = [3, 0, 4]
c = CollisionTest(callback=dummy, objects=[a, b])
dist = c._dist(a, b)
self.assertAlmostEqual(dist, 5)
def test_sphere_in_sphere_false(self):
a = Sphere(radius=10)
b = Sphere(radius=2)
b.position = [10, 2, 0]
c = CollisionTest(callback=dummy, objects=[a, b])
check = c._sphere_in_sphere_collision(a, b)
self.assertFalse(check)
def test_mesh_collision(self):
a = Cube()
b = Cube(width=2.0, height=1.23, depth=1.0)
b.position = [1.0, 0.2, 0.1]
c = CollisionTest(callback=dummy, objects=[a, b])
check = c._mesh_collision(a, b)
self.assertTrue(check)
def test_sphere_in_sphere_false(self):
a = Sphere(radius=10)
b = Sphere(radius=2)
b.position = [10, 2, 0]
c = CollisionTest(callback=dummy, objects=[a, b])
check = c._sphere_in_sphere_collision(a, b)
self.assertFalse(check)
def test_sphere_in_sphere(self):
a = Sphere(radius=10)
b = Sphere(radius=2)
b.position = [2, 2, 0]
c = CollisionTest(callback=dummy, objects=[a, b])
check = c._sphere_in_sphere_collision(a, b)
self.assertTrue(check)
def test_distance(self):
p1 = np.array([2, 5, 3], dtype=np.float32)
p2 = np.array([3, 9, -2], dtype=np.float32)
d = distance(p1, p2)
self.assertAlmostEqual(d, 6.4807405)
direction = 0
scene.active_observer.far = 20
collision = CollisionTest(callback=hit)
for i in range(50):
x = random.randint(-5, 5)
y = random.randint(-5, 5)
z = random.randint(-5, 5)
if i % 2 == 0:
s = Sphere()
s.position = [x, y, z]
scene.add_object("s_{}".format(i), s)
collision.add_object(s)
else:
c = Cube()
c.position = [x, y, z]
scene.add_object("c_{}".format(i), c)
collision.add_object(c)
scene.add_collision_test("test", collision)
scene.create_clock("plane", 0.01, change_near_plane)
scene.run()