ENH: Implement the gradient for rigid registration