예제 #1
0
def test_intersecting_a_translated_sphere_with_a_ray():
    sphere = Sphere(transformation=transformations.translation(5, 0, 0))
    ray = Ray(point(0, 0, -5), vector(0, 0, 1))

    xs = sphere.intersect(ray)

    assert(len(xs) == 0)
예제 #2
0
def test_intersecting_a_scaled_sphere_with_a_ray():
    sphere = Sphere(transformation=transformations.scaling(2, 2, 2))
    ray = Ray(point(0, 0, -5), vector(0, 0, 1))

    xs = sphere.intersect(ray)

    assert(xs[0].t == 3)
    assert(xs[1].t == 7)
def test_intersect_sets_the_object_on_the_intersection():
    r = Ray(point(0, 0, -5), vector(0, 0, 1))
    s = Sphere()

    xs = s.intersect(r)

    assert(len(xs) == 2)
    assert(xs[0].object is s)
    assert(xs[1].object is s)