def _check_t_value(self, name, value): test_value = float(value) print("\nExpected:") print(test_value) print("\nGot:") print(getattr(world, name).t) assert equals(getattr(world, name).t, test_value)
def _check_determinant(self, name, determinant): print("\ndeterminant(" + name + ")") print("-----") print("\nExpected:") print(float(determinant)) print("\nGot:") print(getattr(world, name).determinant()) assert equals(getattr(world, name).determinant(), float(determinant))
def _check_matrix_element(self, name, row, col, value): print("\n" + name + '[' + str(row) + '][' + str(col) + ']') print("-----") print("\nExpected:") print(value) print("\nGot:") print(getattr(world, name)[int(row)][int(col)]) assert equals(getattr(world, name)[int(row)][int(col)], float(value))
def _check_pixel_size(self, name, size): test_size = float(size) actual_size = getattr(world, name).pixel_size print("Expected:") print(test_size) print("\nGot:") print(actual_size) assert equals(actual_size, test_size)
def _check_fov(self, name, attr, value): test_fov = float(value) fov = getattr(getattr(world, name), attr) print("\nExpected:") print(test_fov) print("\nGot:") print(fov) assert equals(fov, test_fov)
def _check_intersections_t_value(self, name, index, value): test_value = float(value) test_index = int(index) print("\nExpected:") print(test_value) print("\nGot:") print(getattr(world, name)[test_index].t) assert equals(getattr(world, name)[test_index].t, test_value)
def __eq__(self, other): if self.rows == other.rows and self.cols == other.cols: for r in range(0, self.rows): for c in range(0, self.cols): if not equals(self[r][c], other[r][c]): return False return True else: return False
def _check_cofactor(self, name, row, col, cofactor): print("\ncofactor(" + name + ", " + row + ", " + col + ")") print("-----") print("\nExpected:") print(float(cofactor)) print("\nGot:") print(getattr(world, name).cofactor(int(row), int(col))) assert equals( getattr(world, name).cofactor(int(row), int(col)), float(cofactor))
def local_intersects(self, ray): # Incoming ray is now in object space already # If the ray is parallel to the plane (y = 0), there # is no intersection if maths.equals(ray.direction.y, 0): return Intersections() else: # Otherwise, the ray is intersecting from above # or below t = -ray.origin.y / ray.direction.y return Intersections(Intersection(t, self))
def _index_equals_value(self, name, index, value): print("\nExpected:") print(float(value)) print("\nGot:") print(getattr(world, name)[int(index)]) assert equals(getattr(world, name)[int(index)], float(value))
def _canvas_member_equals(self, name, member, value): assert equals(getattr(getattr(world, name), member), int(value))
def isInvertible(self): return not equals(self.determinant(), 0)
def _check_minor(self, name, row, col, minor): print("\nExpected:") print(float(minor)) print("\nGot:") print(getattr(world, name).minor(int(row), int(col))) assert equals(getattr(world, name).minor(int(row), int(col)), float(minor))
def __eq__(self, other): if (equals(self.x, other.x) and equals(self.y, other.y) and equals(self.z, other.z) and equals(self.z, other.z)): return True else: return False