Exemplo n.º 1
0
 def translate(self, tx, ty, tz):
     tr = ((1.0, 0.0, 0.0, tx), (0.0, 1.0, 0.0, ty), (0.0, 0.0, 1.0, tz),
           (0.0, 0.0, 0.0, 1.0))
     inv_tr = ((1.0, 0.0, 0.0, -tx), (0.0, 1.0, 0.0, -ty),
               (0.0, 0.0, 1.0, -tz), (0.0, 0.0, 0.0, 1.0))
     self.m = mmmul(tr, self.m)
     self.inv_m = mmmul(self.inv_m, inv_tr)
Exemplo n.º 2
0
 def scale(self, sx, sy, sz):
     sc = ((sx, 0.0, 0.0, 0.0), (0.0, sy, 0.0, 0.0), (0.0, 0.0, sz, 0.0),
           (0.0, 0.0, 0.0, 1.0))
     inv_sc = ((1.0 / sx, 0.0, 0.0, 0.0), (0.0, 1.0 / sy, 0.0, 0.0),
               (0.0, 0.0, 1.0 / sz, 0.0), (0.0, 0.0, 0.0, 1.0))
     self.m = mmmul(sc, self.m)
     self.inv_m = mmmul(self.inv_m, inv_sc)
Exemplo n.º 3
0
 def rotatez(self, d):
     cosd = math.cos(math.radians(d))
     sind = math.sin(math.radians(d))
     rz = ((cosd, -sind, 0.0, 0.0), (sind, cosd, 0.0, 0.0),
           (0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 1.0))
     inv_rz = ((cosd, sind, 0.0, 0.0), (-sind, cosd, 0.0, 0.0),
               (0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 1.0))
     self.m = mmmul(rz, self.m)
     self.inv_m = mmmul(self.inv_m, inv_rz)
Exemplo n.º 4
0
 def rotatey(self, d):
     cosd = math.cos(math.radians(d))
     sind = math.sin(math.radians(d))
     ry = ((cosd, 0.0, sind, 0.0), (0.0, 1.0, 0.0, 0.0),
           (-sind, 0.0, cosd, 0.0), (0.0, 0.0, 0.0, 1.0))
     inv_ry = ((cosd, 0.0, -sind, 0.0), (0.0, 1.0, 0.0, 0.0),
               (sind, 0.0, cosd, 0.0), (0.0, 0.0, 0.0, 1.0))
     self.m = mmmul(ry, self.m)
     self.inv_m = mmmul(self.inv_m, inv_ry)
Exemplo n.º 5
0
 def rotatex(self, d):
     cosd = math.cos(math.radians(d))
     sind = math.sin(math.radians(d))
     rx = ((1.0, 0.0, 0.0, 0.0), (0.0, cosd, -sind, 0.0),
           (0.0, sind, cosd, 0.0), (0.0, 0.0, 0.0, 1.0))
     inv_rx = ((1.0, 0.0, 0.0, 0.0), (0.0, cosd, sind, 0.0),
               (0.0, -sind, cosd, 0.0), (0.0, 0.0, 0.0, 1.0))
     self.m = mmmul(rx, self.m)
     self.inv_m = mmmul(self.inv_m, inv_rx)
Exemplo n.º 6
0
 def _check(self):
     res = mmmul(self.m, self.inv_m)
     if mcmp(res, identity()):
         print "OK"
     else:
         print "FAIL", res