def compute_rigid_transform(refpoints, points):
 A = array([[points[0], (- points[1]), 1, 0], [points[1], points[0], 0, 1], [points[2], (- points[3]), 1, 0], [points[3], points[2], 0, 1], [points[4], (- points[5]), 1, 0], [points[5], points[4], 0, 1]])
 y = array([refpoints[0], refpoints[1], refpoints[2], refpoints[3], refpoints[4], refpoints[5]])
 (a, b, tx, ty) = linalg.lstsq(A, y)[0]
 R = array([[a, (- b)], [b, a]])
 return (R, tx, ty)

def compute_rigid_transform ( refpoints , points ) : A = array ( [ [ points [ 0 ] , ( - points [ 1 ] ) , 1 , 0 ] , [ points [ 1 ] , points [ 0 ] , 0 , 1 ] , [ points [ 2 ] , ( - points [ 3 ] ) , 1 , 0 ] , [ points [ 3 ] , points [ 2 ] , 0 , 1 ] , [ points [ 4 ] , ( - points [ 5 ] ) , 1 , 0 ] , [ points [ 5 ] , points [ 4 ] , 0 , 1 ] ] ) y = array ( [ refpoints [ 0 ] , refpoints [ 1 ] , refpoints [ 2 ] , refpoints [ 3 ] , refpoints [ 4 ] , refpoints [ 5 ] ] ) ( a , b , tx , ty ) = linalg . lstsq ( A , y ) [ 0 ] R = array ( [ [ a , ( - b ) ] , [ b , a ] ] ) return ( R , tx , ty )
computes rotation .