def solve3DTransform(points1, points2):
 import numpy.linalg
 pts = []
 for inp in (points1, points2):
  if isinstance(inp, np.ndarray):
   A = np.empty((4, 4), dtype=float)
   A[:, :3] = inp[:, :3]
   A[:, 3] = 1.0
  else:
   A = np.array([[inp[i].x(), inp[i].y(), inp[i].z(), 1] for i in range(4)])
  pts.append(A)
 matrix = np.zeros((4, 4))
 for i in range(3):
  matrix[i] = numpy.linalg.solve(pts[0], pts[1][:, i])
 return matrix

def solve3DTransform ( points1 , points2 ) : import numpy . linalg pts = [ ] for inp in ( points1 , points2 ) : if isinstance ( inp , np . ndarray ) : A = np . empty ( ( 4 , 4 ) , dtype = float ) A [ : , : 3 ] = inp [ : , : 3 ] A [ : , 3 ] = 1.0 else : A = np . array ( [ [ inp [ i ] . x ( ) , inp [ i ] . y ( ) , inp [ i ] . z ( ) , 1 ] for i in range ( 4 ) ] ) pts . append ( A ) matrix = np . zeros ( ( 4 , 4 ) ) for i in range ( 3 ) : matrix [ i ] = numpy . linalg . solve ( pts [ 0 ] , pts [ 1 ] [ : , i ] ) return matrix
find a 3d transformation matrix that maps points1 onto points2 .