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 (root mean squared deviation) 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 (in particular, see root-mean-square deviation (bioinformatics)).

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 (see also orthogonal Procrustes problem).

Description 

The algorithm for the rotation of  into  starts with two sets of paired points,  and . Each set of points can be represented as an  matrix. The first row is the coordinates of the first point, the second row is the coordinates of the second point, the th row is the coordinates of the th point. Check the matrix below 

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 from the point coordinates of the respective centroid.

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 (for example, the case of  not having an inverse).

If singular value decomposition (SVD) routines are available, the optimal rotation, , can be calculated using the following simple algorithm.

First, calculate the SVD of the covariance matrix .

Next, decide whether we need to correct our rotation matrix to ensure a right-handed coordinate system

Finally, calculate our optimal rotation matrix, , as

The optimal rotation matrix can also be expressed in terms of quaternions. 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 (continuous or not) was also proposed.

Generalizations 

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

External links 
This SVD algorithm is described in more detail at https://web.archive.org/web/20140225050055/http://cnx.org/content/m11608/latest/

A Matlab function is available at http://www.mathworks.com/matlabcentral/fileexchange/25746-kabsch-algorithm

A C++ implementation (and unit test) using Eigen

A Python script is available at https://github.com/charnley/rmsd. Another implementation can be found in
SciPy.

A free PyMol plugin easily implementing Kabsch is . (This previously linked to CEalign , but this uses the Combinatorial Extension (CE) algorithm.) VMD uses the Kabsch algorithm for its alignment.

The FoldX modeling toolsuite incorporates the Kabsch algorithm to measure RMSD between Wild Type and Mutated protein structures.

See also 

 Wahba's Problem
 Orthogonal Procrustes problem

References 

 
 With a correction in 
 
 

Bioinformatics algorithms