def PiScale(*args): if len(args) > 0 and type(args[0]) == list: vec = args[0] x = float(vec[0]) y = float(vec[1]) z = float(vec[2]) elif len(args) > 0 and args[0].__class__.__name__ == "PtVector": vec = args[0] x = vec.x y = vec.y z = vec.z elif len(args) == 0: x = 1. y = 1. z = 1. else: raise PtCommon.PtTypeError("PiScale requires a list or a PtVector") m = PtMatrix([x, 0., 0., 0., 0., y, 0., 0., 0., 0., z, 0., 0., 0., 0., 1.]) #mi = PtMatrix([1./x,0.,0.,0., # 0.,1./y,0.,0., # 0.,0.,1./z,0., # 0.,0.,0.,1.]) #t = PtTransform() #t.m = m #t.mInv =mi return m
def PiTranslate(*args): if len(args) > 0 and type(args[0]) == list: vec = args[0] x = float(vec[0]) y = float(vec[1]) z = float(vec[2]) elif len(args) and args[0].__class__.__name__ in ["PtVector", 'PtPoint']: vec = args[0] x = vec.x y = vec.y z = vec.z elif len(args) == 0: x = 0. y = 0. z = 0. else: raise PtCommon.PtTypeError("PiTranslate requires a list or a PtVector") l = [1., 0., 0., x, 0., 1., 0., y, 0., 0., 1., z, 0., 0., 0., 1.] mat = PtMatrix(l) return mat