def affine_map(points1, points2):
 A = np.ones((4, 4))
 A[:, :3] = points1
 B = np.ones((4, 4))
 B[:, :3] = points2
 matrix = np.eye(4)
 for i in range(3):
  matrix[i] = np.linalg.solve(A, B[:, i])
 return matrix

def affine_map ( points1 , points2 ) : A = np . ones ( ( 4 , 4 ) ) A [ : , : 3 ] = points1 B = np . ones ( ( 4 , 4 ) ) B [ : , : 3 ] = points2 matrix = np . eye ( 4 ) for i in range ( 3 ) : matrix [ i ] = np . linalg . solve ( A , B [ : , i ] ) return matrix
find a 3d transformation matrix that maps points1 onto points2 .