Пример #1
0
 def test_shearing_x_z(self):
     transform = Transformations.shearing(0, 1, 0, 0, 0, 0)
     p = Point(2, 3, 4)
     self.assertEqual(Matrix.multiply_tuple(transform, p), Point(6, 3, 4))
Пример #2
0
def menu(obj):
    mh = np.eye(4)
    t = Transformations()

    print("Vertices dados:")
    print(obj.get_vertices())

    op = 0

    while op != -1:
        print("Escolha uma opção:")
        print("1 - Escala")
        print("2 - Aplicar Escala")
        print("3 - Translacao")
        print("4 - Aplicar Translacao")
        print("5 - Rotacao")
        print("6 - Aplicar Rotacao")
        print("7 - Cisalhamento")
        print("8 - Aplicar Cisalhamento")
        print("")
        print("0 - Sair")

        op = int(input("-> "))

        if op == 1:
            x = float(input("Qual a escala do eixo x? "))
            y = float(input("Qual a escala do eixo y? "))
            z = float(input("Qual a escala do eixo z? "))

            mh = t.scale(mh, x, y, z)

            print("")
            print("Matriz homogenea resultante:")
            print(mh)

        elif op == 2:
            obj = t.apply_scale(obj, mh)
            mh = np.eye(4)

            print("")
            print("Vertices resultantes:")
            print(obj.get_vertices())

        elif op == 3:
            x = float(input("Qual a translacao do eixo x? "))
            y = float(input("Qual a translacao do eixo y? "))
            z = float(input("Qual a translacao do eixo z? "))

            mh = t.translation(mh, x, y, z)

            print("")
            print("Matriz homogenea resultante:")
            print(mh)

        elif op == 4:
            obj = t.apply_translation(obj, mh)
            mh = np.eye(4)

            print("")
            print("Vertices resultantes:")
            print(obj.get_vertices())

        elif op == 5:
            alpha = float(input("Qual o angulo de rotacao? "))
            axis = input("Qual o eixo de rotacao (x, y, z) ? ")

            mh = t.rotation(mh, alpha, axis)

            print("")
            print("Matriz homogenea resultante:")
            print(mh)

        elif op == 6:
            obj = t.apply_rotation(obj, mh)
            mh = np.eye(4)

            print("")
            print("Vertices resultantes:")
            print(obj.get_vertices())

        elif op == 7:
            alpha = float(input("Qual o angulo de cisalhamento? "))
            direction = input("Qual a direcao do cisalhamento(x, y, z) ? ")
            plane = input("Qual o plano de cisalhamento (xy, xz, yz) ? ")

            mh = t.shearing(mh, alpha, direction, plane)

            print("")
            print("Matriz homogenea resultante:")
            print(mh)

        elif op == 8:
            obj = t.apply_shearing(obj, mh)
            mh = np.eye(4)

            print("")
            print("Vertices resultantes:")
            print(obj.get_vertices())

        elif op == 0:
            op = -1