Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio n. 6
0
 def _check(self):
     res = mmmul(self.m, self.inv_m)
     if mcmp(res, identity()):
         print "OK"
     else:
         print "FAIL", res