def transformToArray(tr):
 if isinstance(tr, QtGui.QTransform):
  return np.array([[tr.m11(), tr.m21(), tr.m31()], [tr.m12(), tr.m22(), tr.m32()], [tr.m13(), tr.m23(), tr.m33()]])
 elif isinstance(tr, QtGui.QMatrix4x4):
  return np.array(tr.copyDataTo()).reshape(4, 4)
 else:
  raise Exception('Transform argument must be either QTransform or QMatrix4x4.')

def transformToArray ( tr ) : if isinstance ( tr , QtGui . QTransform ) : return np . array ( [ [ tr . m11 ( ) , tr . m21 ( ) , tr . m31 ( ) ] , [ tr . m12 ( ) , tr . m22 ( ) , tr . m32 ( ) ] , [ tr . m13 ( ) , tr . m23 ( ) , tr . m33 ( ) ] ] ) elif isinstance ( tr , QtGui . QMatrix4x4 ) : return np . array ( tr . copyDataTo ( ) ) . reshape ( 4 , 4 ) else : raise Exception ( 'Transform argument must be either QTransform or QMatrix4x4.' )
given a qtransform .