LaplaceCrossCorrelation.grad#

LaplaceCrossCorrelation.grad()#

Calculate the gradient of the cost function w.r.t. translation and rotation.

\[\begin{split}\nabla f = -\frac{1}{N} \begin{bmatrix} \sum_i w_i \nabla v(x_i) \\ \sum_i w_i (r_i \times \nabla v(x_i)) \end{bmatrix}\end{split}\]

where \(N\) is the number of points, \(w_i\) are weights, \(x_i\) are rotated template positions, and \(r_i\) are positions relative to the template center.

Returns:
np.ndarray

Negative gradient of the cost function: [dx, dy, dz, dRx, dRy, dRz].