Beispiel #1
0
    def __init__(self, hsize, vsize, fov):
        self.horizontal_size_px = hsize
        self.vertical_size_px = vsize
        self.field_of_view = fov
        self.__transform = identity_matrix()
        self.__inverse_transform = identity_matrix()

        half_view = tan(self.field_of_view / 2)
        aspect = self.horizontal_size_px / self.vertical_size_px

        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.horizontal_size_px
Beispiel #2
0
def main():
    print("What happens when you invert the identity matrix?")
    a = identity_matrix()
    print(inverse(a))

    print()
    print("What do you get when you multiply a matrix by its inverse?")
    a = identity_matrix()
    a[1][0] = 2
    a[0][3] = -5
    b = multiply_matrix(a, inverse(a))
    print(b)

    print()
    print(
        "Is there any difference between the inverse of the transpose of a matrix, and the transpose of the inverse?"
    )
    c = inverse(transpose(a))
    d = transpose(inverse(a))
    print(c)
    print(d)

    print()
    print(
        "Remember how multiplying the identity matrix by a tuple gives you the tuple, unchanged?"
    )
    t = tuple_4d(5, 4, 3, 1)
    i = identity_matrix()
    c = multiply_tuple(i, t)
    print(c)

    print()
    print(
        "Now, try changing any single element of the identity matrix to a different number, and then multiplying it by a tuple. What happens to the tuple?"
    )
    i[1][1] = 2
    i[2][2] = 3
    c = multiply_tuple(i, t)
    print(c)
def step_impl(context):
    assert multiply_tuple(identity_matrix(), context.a) == context.a
def step_impl(context):
    assert multiply_matrix(context.a, identity_matrix()) == context.a
def step_impl(context):
    assert context.a == identity_matrix()
def step_impl(context):
    context.a = transpose(identity_matrix())
Beispiel #7
0
 def __init__(self):
     self.__transform = identity_matrix()
     self.__inverse_transform = identity_matrix()
     self.material = Material()
     self.parent = None
     self.cast_shadow = True
Beispiel #8
0
 def __init__(self):
     self.__transform = identity_matrix()
     self.__inverse_transform = identity_matrix()
Beispiel #9
0
def step_assert_transform_of_s_equals_identity_matrix(context):
    assert_matrix(context.s.transform(), identity_matrix())
Beispiel #10
0
def step_assert_transform_of_c_equals_identity_matrix(context):
    assert context.c.transform() == identity_matrix()
Beispiel #11
0
def step_assert_transform_of_pattern_equals_identity_matrix(context):
    assert_matrix(context.pattern.transform(), identity_matrix())