示例#1
0
    def test_ray(self):
        r = Ray(Point(0, 0, 0), Vector(1, 2, 3))
        
        # test copy constructor
        r2 = Ray.from_ray(r)
        self.assertTrue(isinstance(r2, Ray))
        self.assertEqual(r2.d, r.d)

        # test constructor from parent ray
        r3 = Ray.from_ray_parent(r.o, r.d, r, r.mint)
        self.assertTrue(isinstance(r3, Ray))
        self.assertEqual(r3.depth, r.depth+1)

        # test operator()
        p = r(1.7)        
        self.assertEqual(p, Point(1.7, 3.4, 5.1))        
示例#2
0
    def test_ray(self):
        r = Ray(Point(0, 0, 0), Vector(1, 2, 3))

        # test copy constructor
        r2 = Ray.from_ray(r)
        self.assertTrue(isinstance(r2, Ray))
        self.assertEqual(r2.d, r.d)

        # test constructor from parent ray
        r3 = Ray.from_ray_parent(r.o, r.d, r, r.mint)
        self.assertTrue(isinstance(r3, Ray))
        self.assertEqual(r3.depth, r.depth + 1)

        # test operator()
        p = r(1.7)
        self.assertEqual(p, Point(1.7, 3.4, 5.1))