Kabsch algorithm


The Kabsch algorithm, also known as the Kabsch-Umeyama algorithm, named after Wolfgang Kabsch and Shinji Umeyama, is a method for calculating the optimal rotation matrix that minimizes the RMSD between two paired sets of points. It is useful for point-set registration in computer graphics, and in cheminformatics and bioinformatics to compare molecular and protein structures.
The algorithm only computes the rotation matrix, but it also requires the computation of a translation vector. When both the translation and rotation are actually performed, the algorithm is sometimes called partial Procrustes superimposition.

Description

Let and be two sets, each containing points in. We want to find the transformation from to. For simplicity, we will consider the three-dimensional case.
The sets and can each be represented by matrices with the first row containing the coordinates of the first point, the second row containing the coordinates of the second point, and so on, as shown in this matrix:
The algorithm works in three steps: a translation, the computation of a covariance matrix, and the computation of the optimal rotation matrix.

Translation

Both sets of coordinates must be translated first, so that their centroid coincides with the origin of the coordinate system. This is done by subtracting the centroid coordinates from the point coordinates.

Computation of the covariance matrix

The second step consists of calculating a matrix. In matrix notation,
or, using summation notation,
which is a cross-covariance matrix when and are seen as data matrices.

Computation of the optimal rotation matrix

It is possible to calculate the optimal rotation based on the matrix formula
but implementing a numerical solution to this formula becomes complicated when all special cases are accounted for.
If singular value decomposition routines are available the optimal rotation,, can be calculated using the following algorithm.
First, calculate the SVD of the covariance matrix,
where and are orthogonal and is diagonal. Next, record if the orthogonal matrices contain a reflection,
Finally, calculate our optimal rotation matrix as
This minimizes, where and are rows in and respectively.
Alternatively, optimal rotation matrix can also be directly evaluated as quaternion. This alternative description has been used in the development of a rigorous method for removing rigid-body motions from molecular dynamics trajectories of flexible molecules. In 2002 a generalization for the application to probability distributions was also proposed.

Generalizations

The algorithm was described for points in a three-dimensional space. The generalization to dimensions is immediate.