Exemplo n.º 1
0
 def test_ray_intersect_sphere_two_solutions_2(self):
     r = ray.create([2.48, 1.45, 1.78], [-3.1, 0.48, -3.2])
     s = sphere.create([1, 1, 0], 1)
     intersections = ray_intersect_sphere(r, s)
     self.assertEqual(len(intersections), 2)
     np.testing.assert_array_almost_equal(intersections[0], np.array([0.44, 1.77, -0.32]), decimal=2)
     np.testing.assert_array_almost_equal(intersections[1], np.array([1.41, 1.62, 0.67]), decimal=2)
Exemplo n.º 2
0
 def test_ray_intersect_sphere_two_solutions_1(self):
     r = ray.create([-2, 0, 0], [1, 0, 0])
     s = sphere.create([0, 0, 0], 1)
     intersections = ray_intersect_sphere(r, s)
     self.assertEqual(len(intersections), 2)
     np.testing.assert_array_almost_equal(intersections[0], np.array([1, 0, 0]), decimal=2)
     np.testing.assert_array_almost_equal(intersections[1], np.array([-1, 0, 0]), decimal=2)
Exemplo n.º 3
0
 def test_sphere_penetration_sphere_4(self):
     s1 = sphere.create()
     s2 = sphere.create([3.,0.,0.], 1.0)
     self.assertEqual(gt.sphere_penetration_sphere(s1, s2), 0.0)
Exemplo n.º 4
0
 def test_sphere_penetration_sphere_1(self):
     s1 = sphere.create()
     s2 = sphere.create()
     self.assertEqual(gt.sphere_penetration_sphere(s1, s2), 2.0)
Exemplo n.º 5
0
 def test_sphere_does_intersect_sphere_4(self):
     s1 = sphere.create()
     s2 = sphere.create([2.,0.,0.], 0.5)
     self.assertTrue(False == gt.sphere_does_intersect_sphere(s1, s2))
Exemplo n.º 6
0
 def test_sphere_does_intersect_sphere_3(self):
     s1 = sphere.create()
     s2 = sphere.create([2.,0.,0.], 1.0)
     self.assertTrue(gt.sphere_does_intersect_sphere(s1, s2))
Exemplo n.º 7
0
 def test_sphere_does_intersect_sphere_1(self):
     s1 = sphere.create()
     s2 = sphere.create()
     self.assertTrue(gt.sphere_does_intersect_sphere(s1, s2))
Exemplo n.º 8
0
 def test_sphere_penetration_sphere_4(self):
     s1 = sphere.create()
     s2 = sphere.create([3.,0.,0.], 1.0)
     self.assertEqual(gt.sphere_penetration_sphere(s1, s2), 0.0)
Exemplo n.º 9
0
 def test_sphere_penetration_sphere_1(self):
     s1 = sphere.create()
     s2 = sphere.create()
     self.assertEqual(gt.sphere_penetration_sphere(s1, s2), 2.0)
Exemplo n.º 10
0
 def test_sphere_does_intersect_sphere_4(self):
     s1 = sphere.create()
     s2 = sphere.create([2.,0.,0.], 0.5)
     self.assertTrue(False == gt.sphere_does_intersect_sphere(s1, s2))
Exemplo n.º 11
0
 def test_sphere_does_intersect_sphere_3(self):
     s1 = sphere.create()
     s2 = sphere.create([2.,0.,0.], 1.0)
     self.assertTrue(gt.sphere_does_intersect_sphere(s1, s2))
Exemplo n.º 12
0
 def test_sphere_does_intersect_sphere_1(self):
     s1 = sphere.create()
     s2 = sphere.create()
     self.assertTrue(gt.sphere_does_intersect_sphere(s1, s2))
Exemplo n.º 13
0
 def test_ray_intersect_sphere_no_solution_2(self):
     r = ray.create([0, 0, 0], [1, 0, 0])
     s = sphere.create([0, 2, 0], 1)
     intersections = ray_intersect_sphere(r, s)
     self.assertEqual(len(intersections), 0)