Ejemplo n.º 1
0
 def test_ray_when_camera_is_transformed(self):
     transform = RotationY(math.pi / 4) * Translation(0, -2, 5)
     c = Camera(201, 101, math.pi / 2, transform)
     r = c.ray_for_pixel(100, 50)
     self.assertEqual(r.origin, Point(0, 2, -5))
     self.assertEqual(r.direction,
                      Vector(math.sqrt(2) / 2, 0, -math.sqrt(2) / 2))
Ejemplo n.º 2
0
def test_camera_transform_ray():
    c = Camera(201, 101, math.pi / 2)
    c.transform = RotationY(math.pi / 4) * Translation(0, -2, 5)
    r = c.ray_for_pixel(100, 50)
    assert r.origin == Point(0, 2, -5)
    print(r.direction)
    assert r.direction == Vector(math.sqrt(2) / 2, 0, -math.sqrt(2) / 2)
 def test_construct_ray_when_camera_is_transformed(self):
     c = Camera(201, 101, pi / 2)
     c.transformation = rotation_y(pi / 4) * translation(0, -2, 5)
     r = c.ray_for_pixel(100, 50)
     assert r.origin == Point(0, 2, -5)
     assert r.direction == Vector(sqrt(2) / 2, 0, -sqrt(2) / 2)
 def test_construct_ray_through_corner_of_canvas(self):
     c = Camera(201, 101, pi / 2)
     r = c.ray_for_pixel(0, 0)
     assert r.origin == Point(0, 0, 0)
     assert r.direction == Vector(0.66519, 0.33259, -0.66851)
 def test_construct_ray_through_center_of_canvas(self):
     c = Camera(201, 101, pi / 2)
     r = c.ray_for_pixel(100, 50)
     assert r.origin == Point(0, 0, 0)
     assert r.direction == Vector(0, 0, -1)
Ejemplo n.º 6
0
 def test_ray_through_corner_of_canvas(self):
     c = Camera(201, 101, math.pi / 2)
     r = c.ray_for_pixel(0, 0)
     self.assertEqual(r.origin, Point(0, 0, 0))
     self.assertEqual(r.direction, Vector(0.66519, 0.33259, -0.66851))
Ejemplo n.º 7
0
 def test_ray_through_center_of_canvas(self):
     c = Camera(201, 101, math.pi / 2)
     r = c.ray_for_pixel(100, 50)
     self.assertEqual(r.origin, Point(0, 0, 0))
     self.assertEqual(r.direction, Vector(0, 0, -1))
Ejemplo n.º 8
0
def test_corner_canvas_ray():
    c = Camera(201, 101, math.pi / 2)
    r = c.ray_for_pixel(0, 0)
    assert r.origin == Point(0, 0, 0)
    assert r.direction == Vector(0.66519, 0.33259, -0.66851)
Ejemplo n.º 9
0
def test_center_canvas_ray():
    c = Camera(201, 101, math.pi / 2)
    r = c.ray_for_pixel(100, 50)
    assert r.origin == Point(0, 0, 0)
    assert r.direction == Vector(0, 0, -1)