def step_default_world_contains_element(context, item, element, item2): assert (item in context.dict.keys()) local_object_str = "context.dict['" + str(item) + "']." + str(element) light_list = eval(local_object_str) test_value = context.dict[str(item2)] match_found = False for source in light_list: if equal(source.position, test_value.position): if equal(source.intensity, test_value.intensity): match_found = True break assert (match_found)
def step_impl_ray_intersect_list_count(context, item, element, red, green, blue): assert (item in context.dict.keys()) local_object_str = "context.dict['" + str(item) + "']." + str(element) local_object = eval(local_object_str) value = color(np.float32(red), np.float32(green), np.float32(blue)) assert (equal(local_object, value))
def step_impl_ray_intersect_list_count(context, item, element, item2): assert(item in context.dict.keys()) assert(item2 in context.tuple.keys()) local_object_str = "context.dict['"+str(item)+"']."+str(element) local_object = eval(local_object_str) value = context.tuple[str(item2)] assert(equal(local_object, value))
def step_impl_ray_element(context, item, element, value): assert (item in context.dict.keys()) assert (element in valid_ray_elements) ray = context.dict[str(item)] thing = eval("ray." + str(element)) vec4_value = context.tuple[str(value)] assert (base.equal(thing, vec4_value))
def step_impl_ray_element_vector(context, item, element, x, y, z): assert (item in context.dict.keys()) assert (element in valid_ray_elements) ray = context.dict[str(item)] thing = eval("ray." + str(element)) vec4_value = base.vector(float(x), float(y), float(z)) assert (base.equal(thing, vec4_value))
def step_camera_element_has_rational_value(context, item, element, numerator, denominator): assert(item in context.dict.keys()) local_object_str = "context.dict['"+str(item)+"']."+str(element) camera_object_element = eval(local_object_str) numerator = np.pi if numerator=="π" else float(numerator) test_value = numerator/float(denominator) assert(base.equal(camera_object_element, test_value))
def step_impl_ray_intersect_list_count(context, listname, element, value): assert (listname in context.dict.keys()) listlen = len(context.dict[str(listname)]) element = int(element) assert (element >= 0) assert (element < listlen) t_value = (context.dict[str(listname)])[element].t assert (equal(t_value, float(value)))
def step_get_obj_normal_at_point(context, item, xnum, xdenom, ynum, ydenom, znum, zdenom): assert (item in context.tuple.keys()) value = context.tuple[str(item)] new_vector = vector( np.sqrt(float(xnum)) / float(xdenom), np.sqrt(float(ynum)) / float(ydenom), np.sqrt(float(znum)) / float(zdenom)) assert (equal(value, new_vector))
def step_impl_ray_intersect_list_count(context, listname, element, value): assert (listname in context.dict.keys()) listlen = len(context.dict[str(listname)]) element = int(element) assert (element >= 0) assert (element < listlen) thing = (context.dict[str(listname)])[element].object value_object = context.dict[str(value)] assert (equal(thing.instance_id, value_object.instance_id))
def step_impl_ray_element_vector(context, item, element, xnum, xdenom, znum, zdenom): assert (item in context.dict.keys()) assert (element in valid_ray_elements) ray = context.dict[str(item)] thing = eval("ray." + str(element)) vec4_value = base.vector( np.sqrt(float(xnum)) / float(xdenom), 0, -np.sqrt(float(znum)) / float(zdenom)) assert (base.equal(thing, vec4_value))
def local_normal_at(self, local_pt): # assume that local point _is_ on border of cylinder x = local_pt.x z = local_pt.z if not self.closed: # then point must be on the wall of cylinder return vector(x, 0, z) else: # need to figure out if we point is on wall or on edge # is it an end? y = local_pt.y if equal(y, self.minimum): # lower end return vector(0, -1, 0) elif equal(y, self.maximum): return vector(0, 1, 0) else: # assert(equal((x*x)+(z*z), 1)) # assume is on wall return vector(x, 0, z)
def intersect_caps(self, local_ray): xs = [] if self.closed == True and not equal(local_ray.direction.y, 0): # check for an intersection with the lower end cap by intersecting the ray with the plane at y=cyl.minimum t = (self.minimum - local_ray.origin.y) / local_ray.direction.y if self.check_cap(local_ray, t): xs.append(Intersection(t, self)) # check for an intersection with the upper end cap by intersecting the ray with the plane at y=cyl.maximum t = (self.maximum - local_ray.origin.y) / local_ray.direction.y if self.check_cap(local_ray, t): xs.append(Intersection(t, self)) return xs
def step_default_world_contains_object(context, item, item2): assert (item in context.dict.keys()) local_object_str = "context.dict['" + str(item) + "'].objects" object_list = eval(local_object_str) test_object = context.dict[str(item2)] match_found = False for thing in object_list: for element in thing.material.__dict__.keys(): if thing.material.__dict__[str( element)] == test_object.material.__dict__[str(element)]: match_found = True else: match_found = False break if match_found and equal(thing.transform, test_object.transform): break else: match_found = False assert (match_found)
def step_cube_local_normal_is_vector(context, nml, x, y, z): assert (nml in context.tuple.keys()) cube_normal = context.tuple[str(nml)] test_vector = vector(np.float32(x), np.float32(y), np.float32(z)) assert (equal(cube_normal, test_vector))
def step_test_sphere_transform_is_identity(context, item): assert (item in context.dict.keys()) s = context.dict[item] assert (equal(s.transform, np.identity(4, dtype=float)))
def step_test_sphere_transform_is_identity(context, item, value): assert (item in context.dict.keys()) assert (value in context.dict.keys()) s = context.dict[item] transform_matrix = context.dict[value] assert (equal(s.transform, transform_matrix))
def step_ray_element_has_value(context, x, y, red, green, blue): assert("image" in context.dict.keys()) test_value = base.pixel_at(context.dict["image"], int(x), int(y)) test_color = base.color(float(red), float(green), float(blue)) assert(base.equal(test_value, test_color))
def step_ray_element_has_value(context, item, element, x, y, z): assert(item in context.dict.keys()) comps_object_element = context.dict[str(item)].__dict__[str(element)] test_value = base.point(float(x), float(y), float(z)) assert(base.equal(comps_object_element, test_value))
def step_camera_element_has_value_identity(context, item, element): assert(item in context.dict.keys()) local_object_str = "context.dict['"+str(item)+"']."+str(element) camera_object_element = eval(local_object_str) test_value = np.identity(4, dtype=float) assert(base.equal(camera_object_element, test_value))
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 = base.point(float(x), float(y), float(z)) assert (base.equal(ray_position, test_point))
def step_test_normal_value3(context, item, item2): assert (item in context.tuple.keys()) nval = context.tuple[str(item)] assert (item2 in context.tuple.keys()) nval2 = context.tuple[str(item2)] assert (equal(nval, normalize(nval2)))
def step_then_solid_material_characteristic_is_value(context, item, mchar, value): result = context.dict[str(item)].material.__dict__[str(mchar)] test_value = float(value) assert (equal(result, test_value))
def step_impl_ray_element_point(context, item, element, x, y, z): assert (item in context.dict.keys()) assert (element in valid_ray_elements) thing = context.dict[str(item)].__dict__[str(element)] vec4_value = base.point(float(x), float(y), float(z)) assert (base.equal(thing, vec4_value))
def step_then_variable_equals_vector_value(context, item_n, x, y, z): assert (item_n in context.tuple.keys()) local_vector = context.tuple[str(item_n)] test_vector = vector(float(x), float(y), float(z)) assert (equal(local_vector, test_vector))
def step_lighting_color_test(context, item, red, green, blue): assert (item in context.tuple.keys()) local_object_str = "context.tuple['" + str(item) + "']" local_object = eval(local_object_str) value = color(np.float32(red), np.float32(green), np.float32(blue)) assert (equal(local_object, value))
def step_then_material_color_test(context, item1, item2): assert (item1 in context.tuple.keys()) assert (item2 in context.dict.keys()) local_color = context.tuple[str(item1)] material_color = context.dict[str(item2)].material.color assert (equal(local_color, material_color))