Exemplo n.º 1
0
    def setUp(self):
        self.A = Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9)
        self.B = Matrix([9, 8, 7, 6, 5, 4, 3, 2, 1])
        self.C = Matrix([[3, 2, 1], [6, 5, 4], [9, 8, 7]])

        self.D = Matrix(x for x in range(11, 20))
        self.p = Point(1, 2, 3)
Exemplo n.º 2
0
 def test_matrix_matrix_mul(self):
     self.assertEqual(self.A * self.B,
                      Matrix(30, 24, 18, 84, 69, 54, 138, 114, 90))
Exemplo n.º 3
0
 def test_matrix_isub(self):
     self.A -= self.B
     self.assertEqual(self.A, Matrix(-8, -6, -4, -2, 0, 2, 4, 6, 8))
Exemplo n.º 4
0
 def test_matrix_iadd(self):
     self.A += self.D
     self.assertEqual(self.A, Matrix(12, 14, 16, 18, 20, 22, 24, 26, 28))
Exemplo n.º 5
0
 def test_matrix_eq(self):
     self.assertEqual(self.A, self.A)
     self.assertEqual(self.A, Matrix(list(range(1, 10))))
Exemplo n.º 6
0
from rubik.maths import Point, Matrix

RIGHT = X_AXIS = Point(1, 0, 0)
LEFT = Point(-1, 0, 0)
UP = Y_AXIS = Point(0, 1, 0)
DOWN = Point(0, -1, 0)
FRONT = Z_AXIS = Point(0, 0, 1)
BACK = Point(0, 0, -1)

FACE = 'face'
EDGE = 'edge'
CORNER = 'corner'

# 90 degree rotations in the XY plane. CW is clockwise, CC is counter-clockwise.
ROT_XY_CW = Matrix(0, 1, 0, -1, 0, 0, 0, 0, 1)
ROT_XY_CC = Matrix(0, -1, 0, 1, 0, 0, 0, 0, 1)

# 90 degree rotations in the XZ plane (around the y-axis when viewed pointing toward you).
ROT_XZ_CW = Matrix(0, 0, -1, 0, 1, 0, 1, 0, 0)
ROT_XZ_CC = Matrix(0, 0, 1, 0, 1, 0, -1, 0, 0)

# 90 degree rotations in the YZ plane (around the x-axis when viewed pointing toward you).
ROT_YZ_CW = Matrix(1, 0, 0, 0, 0, 1, 0, -1, 0)
ROT_YZ_CC = Matrix(1, 0, 0, 0, 0, -1, 0, 1, 0)


def get_rot_from_face(face):
    """
    :param face: One of FRONT, BACK, LEFT, RIGHT, UP, DOWN
    :return: A pair (CW, CC) given the clockwise and counterclockwise rotations for that face