def find_frame_of_reference(target, source): target = copy(target) source = copy(source[:, :target.shape[1]]) target /= target[3,:] source /= source[3,:] return dot(linalg.pinv(source.T), target.T).T