コード例 #1
0
def test_child_normal():
    g1 = Group()
    g1.set_transform(RotationY(math.pi / 2))
    g2 = Group()
    g2.set_transform(Scaling(1, 2, 3))
    g1.add_child(g2)
    s = Sphere()
    s.set_transform(Translation(5, 0, 0))
    g2.add_child(s)
    n = s.normal_at(Point(1.7321, 1.1547, -5.5774))
    assert n == Vector(0.2857, 0.4286, -0.8571)
コード例 #2
0
def test_normal_is_normal():
    s = Sphere()
    num = math.sqrt(3) / 3
    n = s.normal_at(Point(num, num, num))
    assert n == n.normalize()
コード例 #3
0
def test_sphere_z_normal():
    s = Sphere()
    n = s.normal_at(Point(0, 0, 1))
    assert n == Vector(0, 0, 1)
コード例 #4
0
def test_sphere_nonaxial_normal():
    s = Sphere()
    num = math.sqrt(3) / 3
    n = s.normal_at(Point(num, num, num))
    assert n == Vector(num, num, num)
コード例 #5
0
def test_sphere_y_normal():
    s = Sphere()
    n = s.normal_at(Point(1, 0, 0))
    assert n == Vector(1, 0, 0)