def test_sphere_normal_at_scaled(): s = Sphere() s.set_transform(scaling(1, 0.5, 1)) n = s.normal_at(Point(0, sqrt(2) / 2, -sqrt(2) / 2)) assert n == Vector(0, 0.9701425001453319, -0.24253562503633297)
def test_sphere_normal_at_translate(): s = Sphere() s.set_transform(translation(0, 1, 0)) n = s.normal_at(Point(0, 1.70711, -0.70711)) assert n == Vector(0, 0.7071067811865475, -0.7071067811865476)
def test_sphere_normal_normalized(): s = Sphere() n = s.normal_at(Point(sqrt(3) / 3, sqrt(3) / 3, sqrt(3) / 3)) assert n == n.normalize()
def test_sphere_normal_at_arbitrary(): s = Sphere() n = s.normal_at(Point(sqrt(3) / 3, sqrt(3) / 3, sqrt(3) / 3)) assert n == Vector(sqrt(3) / 3, sqrt(3) / 3, sqrt(3) / 3)
def test_sphere_normal_at_z(): s = Sphere() n = s.normal_at(Point(0, 0, 1)) assert n == Vector(0, 0, 1)
def test_sphere_normal_at_x(): s = Sphere() n = s.normal_at(Point(1, 0, 0)) assert n == Vector(1, 0, 0)