def step_get_obj_normal_at_point(context, item, s, x, y, z): assert (s in context.dict.keys()) ensure_context_has_tuple(context) new_point = point(float(x), float(y), float(z)) test_solid = context.dict[str(s)] norm = normal_at(test_solid, new_point) context.tuple[str(item)] = norm
def step_impl_point_light_for_materials(context, item, px, py, pz, red, green, blue): ensure_context_has_dict(context) real_position = point(float(px), float(py), float(pz)) real_intensity = color(float(red), float(green), float(blue)) context.dict[item] = point_light(real_position, real_intensity)
def step_impl_point_light_for_world(context, item, px, py, pz, red, green, blue): ensure_context_has_dict(context) real_position = point(np.float32(px), np.float32(py), np.float32(pz)) real_intensity = color(np.float32(red), np.float32(green), np.float32(blue)) context.dict[item].light = [point_light(real_position, real_intensity)]
def step_get_obj_normal_at_point(context, item, s, x, ynum, ydenom, znum, zdenom): assert (s in context.dict.keys()) ensure_context_has_tuple(context) new_point = point(np.sqrt(float(x)), np.sqrt(float(ynum)) / float(ydenom), -np.sqrt(float(znum)) / float(zdenom)) test_solid = context.dict[str(s)] norm = normal_at(test_solid, new_point) context.tuple[str(item)] = norm
def step_set_lighting_values_with_shadow_explicit_point( context, item, material, light, px, py, pz, eye_vector, normal_vector, in_shadow): assert (material in context.dict.keys()) assert (light in context.dict.keys()) assert (eye_vector in context.tuple.keys()) assert (normal_vector in context.tuple.keys()) material_val = context.dict[str(material)] light_val = context.dict[str(light)] point_value = point(float(px), float(py), float(pz)) eye_vec_value = context.tuple[str(eye_vector)] norm_vec_value = context.tuple[str(normal_vector)] in_shadow_value = True if in_shadow == "true" else False lighting_value = lighting(material_val, sphere(), light_val, point_value, eye_vec_value, norm_vec_value, in_shadow_value) context.tuple[str(item)] = lighting_value
def step_cylinder_local_normal(context, nml, item1, x, y, z): assert (item1 in context.dict.keys()) ensure_context_has_tuple(context) context.tuple[str(nml)] = context.dict[str(item1)].local_normal_at( point(np.float32(x), np.float32(y), np.float32(z)))
def step_cylinder_given_test_ray(context, r, x, y, z, item): ensure_context_has_dict(context) context.dict[str(r)] = ray( point(np.float32(x), np.float32(y), np.float32(z)), context.tuple[str(item)])
def step_when_local_normal_at_on_plane(context, item_n, item_plane, x, y, z): assert (item_plane in context.dict.keys()) ensure_context_has_tuple(context) test_plane = context.dict[str(item_plane)] test_point = point(float(x), float(y), float(z)) context.tuple[str(item_n)] = test_plane.local_normal_at(test_point)
def step_impl_point_assign_B(context, item, x, y, z): ensure_context_has_tuple(context) context.tuple[item] = point(np.float32(x), np.float32(y), np.float32(z))
def step_impl_generic_ray_full(context, item, px, py, pz, vx, vy, vz): pt = point(np.float32(px), np.float32(py), np.float32(pz)) vc = vector(np.float32(vx), np.float32(vy), np.float32(vz)) ensure_context_has_dict(context) context.dict[str(item)] = ray(pt, vc)
def step_impl_eval_ray_position(context, item, t, x, y, z): assert (item in context.dict.keys()) ray = context.dict[str(item)] ray_position = ray.position(float(eval(t))) test_point = point(float(x), float(y), float(z)) assert (equal(ray_position, test_point))
def step_impl_point_assign(context, item, x, y, z): ensure_context_has_tuple(context) context.tuple[item] = point(float(x), float(y), float(z))
def step_group_when_point_is_world_to_object(context, p, s, x, y, z): assert (s in context.dict.keys()) ensure_context_has_tuple(context) context.tuple[str(p)] = world_to_object( context.dict[str(s)], point(np.float32(x), np.float32(y), np.float32(z)))