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))
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))
def write(filename, sponge, merge=False): dwg = ezdxf.new('R2000') transform = Matrix44.chain(Matrix44.z_rotate(math.radians(45)), Matrix44.translate(5, 3, 4)) sponge.render(dwg.modelspace(), merge=merge, matrix=transform) dwg.saveas(filename)