def teste_hit3(self): s = sphere() i1 = intersection(-1, s) i2 = intersection(-2, s) xs = intersections(i1, i2) i = hit(xs) self.assertIsNone(i, 'There should be no hit')
def teste_hit2(self): s = sphere() i1 = intersection(-1, s) i2 = intersection(1, s) xs = intersections(i1, i2) i = hit(xs) self.assertEqual(i, i2, 'The first hit is wrong')
def test_sphere_intersections(self): s = sphere() i1 = intersection(1, s) i2 = intersection(2, s) xs = intersections(i1, i2) self.assertEqual(len(xs), 2, 'There should be 2 intersections') self.assertEqual(xs[0].t, 1, 'The first intersection time should be 1') self.assertEqual(xs[1].t, 2, 'The second intersection time should be 2')
def teste_hit4(self): s = sphere() i1 = intersection(5, s) i2 = intersection(7, s) i3 = intersection(-3, s) i4 = intersection(2, s) xs = intersections(i1, i2, i3, i4) i = hit(xs) self.assertEqual(i, i4, 'The first hit is wrong')