Ejemplo n.º 1
0
def question_one():
    print('1. What happens when you invert the identity matrix?')
    print('You get this:')

    m = Matrix.identity_matrix().submatrix(3, 3)
    m = m.inverse()
    for row in m.matrix:
        print(row)
    print('The Identity matrix again :)\n')
    def __init__(self, hsize, vsize, field_of_view):
        self.hsize = hsize
        self.vsize = vsize
        self.field_of_view = field_of_view
        self.transform = Matrix.identity_matrix()

        # Calculate pixel size, pixel width, pixel height
        self.fov_radians = math.radians(field_of_view)
        half_view = math.tan(self.fov_radians / 2)
        aspect = hsize / vsize
        if aspect >= 1:
            self.half_width = half_view
            self.half_height = half_view / aspect
        else:
            self.half_width = half_view * aspect
            self.half_height = half_view
        self.pixel_size = (self.half_width * 2) / self.hsize
Ejemplo n.º 3
0
 def __init__(self, parent=None):
     # Converts itself from shape -> world space
     self.transform = Matrix.identity_matrix()
     self.material = Material()
     self.parent = parent
     self.id = id(self)
Ejemplo n.º 4
0
def step_impl(context):
    assert context.t == Matrix.identity_matrix(), 't != identity_matrix'
def step_impl(context, attribute):
    obj = getattr(context, attribute)
    expected = Matrix.identity_matrix()
    result = obj.transform
    assert expected == result, f'Tranform:{result} != identity_matrix'
 def __init__(self):
     self.transform = Matrix.identity_matrix()