def step_impl(context): assert context.full_quarter * context.p == point(-1, 0, 0)
def step_impl(context): context.n1 = context.p.local_normal_at(context.p, point(0, 0, 0))
def step_impl(context): context.n3 = context.p.local_normal_at(context.p, point(-5, 0, 150))
def step_impl(context): context.n3 = context.t.local_normal_at(context.t, point(0.5, 0.25, 0))
def step_impl(context): context.r = ray(point(0, -1, -2), vector(0, 1, 0))
def step_impl(context): context.p2 = point(-1, 0, 0)
def step_impl(context): context.t = triangle(point(0, 1, 0), point(-1, 0, 0), point(1, 0, 0))
def step_impl(context): assert context.T * context.p == point(15, 0, 7)
def step_impl(context): context.frm = point(0, 0, 8)
def step_impl(context): assert context.p3 == point(5, -5, 0)
def step_impl(context): assert context.transform * context.p == point(2, 1, 7)
def step_impl(context): assert context.p2 == point(1, -1, 0)
def step_impl(context): context.p = point(-3, 4, 5)
def step_impl(context): context.p = point(1, 0, 1)
def step_impl(context): assert context.transform * context.p == point(-2, 3, 4)
def step_impl(context): context.to = point(0, 0, 0)
def step_impl(context): context.r = ray(point(-1, 1, -2), vector(0, 0, 1))
def step_impl(context): context.frm = point(1, 3, 2)
def step_impl(context): context.p3 = point(1, 0, 0)
def step_impl(context): context.to = point(4, -2, 8)
def step_impl(context): context.n2 = context.t.local_normal_at(context.t, point(-0.5, 0.75, 0))
def step_impl(context): context.inv * context.p == point(-8, 7, 3)
def step_impl(context): context.p1 = point(0, 1, 0)
def step_impl(context): context.p = point(-4, 6, 8)
import os.path import sys sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) import time from canvas import canvas, canvas_to_ppm, write_pixel from matrix import normalize from ray import ray from shape import hit, intersect from sphere import sphere from tuple import color, point if __name__ == "__main__": ray_origin = point(0, 0, -5) wall_z = 10 wall_size = 7 canvas_pixels = 400 pixel_size = wall_size / canvas_pixels half = wall_size / 2 canvas = canvas(canvas_pixels, canvas_pixels) color = color(1, 0, 0) shape = sphere() # transformations # shape.transform = scaling(1, 0.5, 1) # shape.transform = scaling(0.5, 1, 1) # shape.transform = rotation_z(pi / 4) * scaling(0.5, 1, 1) # shape.transform = shearing(1, 0, 0, 0, 0, 0) * scaling(0.5, 1, 1)
def step_impl(context): assert context.transform * context.p == point(-8, 18, 32)
def step_impl(context): context.n2 = context.p.local_normal_at(context.p, point(10, 0, -10))
def step_impl(context): context.p = point(2, 3, 4)
def step_impl(context): context.r = ray(point(0, 10, 0), vector(0, 0, 1))
def step_impl(context): assert context.half_quarter * context.p == point(-sqrt(2) / 2, sqrt(2) / 2, 0)