コード例 #1
0
    def test_chain(self):
        s = Matrix44.scale(10, 20, 30)
        t = Matrix44.translate(10, 20, 30)

        c = Matrix44.chain(s, t)
        x = diag((10., 20., 30., 1.))
        x[3, 0] = 10.
        x[3, 1] = 20.
        x[3, 2] = 30.
        self.assertTrue(equal_matrix(c, x))
コード例 #2
0
    def test_chain2(self):
        s = Matrix44.scale(10, 20, 30)
        t = Matrix44.translate(10, 20, 30)
        r = Matrix44.axis_rotate(angle=pi / 2, axis=(0., 0., 1.))
        points = ((23., 97., .5), (2., 7., 13.))

        p1 = s.transform_vectors(points)
        p1 = t.transform_vectors(p1)
        p1 = r.transform_vectors(p1)

        c = Matrix44.chain(s, t, r)
        p2 = c.transform_vectors(points)
        self.assertTrue(equal_vectors(p1, p2))
コード例 #3
0
 def test_transform(self):
     t = Matrix44.scale(2., .5, 1.)
     r = t.transform((10., 20., 30.))
     self.assertEqual(r, (20., 10., 30.))
コード例 #4
0
 def test_scale(self):
     t = Matrix44.scale(10, 20, 30)
     x = diag((10., 20., 30., 1.))
     self.assertTrue(equal_matrix(t, x))