<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Kabsch_algorithm</id>
	<title>Kabsch algorithm - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Kabsch_algorithm"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Kabsch_algorithm&amp;action=history"/>
	<updated>2026-05-05T01:55:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Kabsch_algorithm&amp;diff=5038795&amp;oldid=prev</id>
		<title>82.193.241.6 at 17:15, 11 November 2024</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Kabsch_algorithm&amp;diff=5038795&amp;oldid=prev"/>
		<updated>2024-11-11T17:15:55Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Type of algorithm}}&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Kabsch algorithm&amp;#039;&amp;#039;&amp;#039;, also known as the &amp;#039;&amp;#039;&amp;#039;Kabsch-Umeyama algorithm&amp;#039;&amp;#039;&amp;#039;,&amp;lt;ref&amp;gt;{{Cite journal |last1=Lawrence |first1=Jim |last2=Bernal |first2=Javier |last3=Witzgall |first3=Christoph |date=2019-10-09 |title=A Purely Algebraic Justification of the Kabsch-Umeyama Algorithm |url=https://nvlpubs.nist.gov/nistpubs/jres/124/jres.124.028.pdf |journal=Journal of Research of the National Institute of Standards and Technology |language=en |volume=124 |pages=124028 |doi=10.6028/jres.124.028 |issn=2165-7254 |pmc=7340555 |pmid=34877177}}&amp;lt;/ref&amp;gt; named after Wolfgang Kabsch and Shinji Umeyama, is a method for calculating the optimal [[rotation matrix]] that minimizes the [[RMSD]] ([[root mean square]]d 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)]]).&lt;br /&gt;
&lt;br /&gt;
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]]).&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
Let {{mvar|P}} and {{mvar|Q}} be two sets, each containing {{mvar|N}} points in &amp;lt;math&amp;gt;\mathbb{R}^n&amp;lt;/math&amp;gt;. We want to find the transformation from {{mvar|Q}} to {{mvar|P}}.  For simplicity, we will consider the three-dimensional case (&amp;lt;math&amp;gt;n = 3&amp;lt;/math&amp;gt;).&lt;br /&gt;
The sets {{mvar|P}} and {{mvar|Q}} can each be represented by  {{math|&amp;#039;&amp;#039;N&amp;#039;&amp;#039; × 3}} [[matrix (mathematics)|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: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{pmatrix}&lt;br /&gt;
x_1 &amp;amp; y_1 &amp;amp; z_1 \\&lt;br /&gt;
x_2 &amp;amp; y_2 &amp;amp; z_2 \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \vdots \\&lt;br /&gt;
x_N &amp;amp; y_N &amp;amp; z_N \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The algorithm works in three steps: a &amp;#039;&amp;#039;&amp;#039;translation,&amp;#039;&amp;#039;&amp;#039; the &amp;#039;&amp;#039;&amp;#039;computation of a covariance matrix&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;the computation&amp;#039;&amp;#039;&amp;#039; of the optimal rotation matrix.&lt;br /&gt;
&lt;br /&gt;
=== Translation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Computation of the covariance matrix ===&lt;br /&gt;
The second step consists of calculating a matrix {{mvar|H}}. In matrix notation,&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; H = P^\mathsf{T}Q \, &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, using summation notation,&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; H_{ij} = \sum_{k = 1}^N P_{ki} Q_{kj}, &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is a [[cross-covariance|cross-covariance matrix]] when {{mvar|P}} and {{mvar|Q}} are seen as [[design_matrix|data matrices]].&lt;br /&gt;
&lt;br /&gt;
=== Computation of the optimal rotation matrix ===&lt;br /&gt;
It is possible to calculate the optimal rotation {{mvar|R}} based on the matrix formula&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; R = \left(H^\mathsf{T} H\right)^\frac12 H^{-1}, &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
but implementing a numerical solution to this formula becomes complicated when all special cases are accounted for (for example, the case of {{mvar|H}} not having an inverse).&lt;br /&gt;
&lt;br /&gt;
If [[singular value decomposition]] (SVD) routines are available the optimal rotation, {{mvar|R}}, can be calculated using the following algorithm.&lt;br /&gt;
&lt;br /&gt;
First, calculate the SVD of the covariance matrix {{mvar|H}},&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; H = U \Sigma V^\mathsf{T} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where {{mvar|U}} and {{mvar|V}} are orthogonal and &amp;lt;math&amp;gt;\Sigma&amp;lt;/math&amp;gt; is diagonal.  Next, record if the orthogonal matrices contain a reflection,&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; d = \det\left(U V^\mathsf{T}\right) = \det(U) \det(V).&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, calculate our optimal rotation matrix {{mvar|R}} as&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; R = U \begin{pmatrix}&lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; d \end{pmatrix} V^\mathsf{T}. &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This {{mvar|R}} minimizes &amp;lt;math&amp;gt;\sum_{k = 1}^N|R q_k - p_k|&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;q_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p_k&amp;lt;/math&amp;gt; are rows in {{mvar|Q}} and {{mvar|P}} respectively.&lt;br /&gt;
&lt;br /&gt;
Alternatively, optimal rotation matrix can also be directly evaluated as [[quaternion]].&amp;lt;ref&amp;gt;{{Cite journal|last=Horn|first=Berthold K. P.|authorlink=Berthold K.P. Horn|date=1987-04-01|title=Closed-form solution of absolute orientation using unit quaternions|journal=Journal of the Optical Society of America A|language=EN|volume=4|issue=4|pages=629|doi=10.1364/josaa.4.000629|bibcode=1987JOSAA...4..629H|issn=1520-8532|citeseerx=10.1.1.68.7320|s2cid=11038004 }}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite journal|last=Kneller|first=Gerald R.|date=1991-05-01|title=Superposition of Molecular Structures using Quaternions|journal=Molecular Simulation|volume=7|issue=1–2|pages=113–119|doi=10.1080/08927029108022453|issn=0892-7022}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Coutsias2004&amp;quot;&amp;gt;{{cite journal |last1=Coutsias |first1=E. A. |last2=Seok |first2=C. |last3=Dill |first3=K. A. | title = Using quaternions to calculate RMSD | journal = J. Comput. Chem. | volume = 25 | issue = 15 | pages = 1849–1857 | year = 2004 | pmid = 15376254 | doi = 10.1002/jcc.20110|s2cid=18224579 }}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;Petitjean1999&amp;quot;&amp;gt;{{cite journal | last = Petitjean | first = M. | title = On the root mean square quantitative chirality and quantitative symmetry measures | journal = J. Math. Phys. | volume = 40 | issue = 9 | pages = 4587–4595 | year = 1999 | doi = 10.1063/1.532988| bibcode = 1999JMP....40.4587P | url = https://hal.archives-ouvertes.fr/hal-02122820/file/PMP.JMP_1999.pdf }}&amp;lt;/ref&amp;gt; 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.&amp;lt;ref&amp;gt;{{Cite journal|date=2011-08-24|title=Least constraint approach to the extraction of internal motions from molecular dynamics trajectories of flexible macromolecules|journal=J. Chem. Phys.|volume=135|issue=8|pages=084110|doi=10.1063/1.3626275|pmid=21895162|issn=0021-9606|last1=Chevrot|first1=Guillaume|last2=Calligari|first2=Paolo|last3=Hinsen|first3=Konrad|last4=Kneller|first4=Gerald R.|bibcode=2011JChPh.135h4110C}}&amp;lt;/ref&amp;gt; In 2002 a generalization for the application to probability distributions (continuous or not) was also proposed.&amp;lt;ref name=&amp;quot;Petitjean2002&amp;quot;&amp;gt;{{cite journal | last = Petitjean | first = M. | title = Chiral mixtures | journal = J. Math. Phys. | volume = 43 | issue = 8 | pages = 4147–4157 | year = 2002 | doi = 10.1063/1.1484559| bibcode = 2002JMP....43.4147P | s2cid = 85454709 | url = https://hal.archives-ouvertes.fr/hal-02122882/file/PMP.JMP_2002.pdf }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Generalizations ===&lt;br /&gt;
&lt;br /&gt;
The algorithm was described for points in a three-dimensional space. The generalization to {{mvar|D}} dimensions is immediate.&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
This SVD algorithm is described in more detail at https://web.archive.org/web/20140225050055/http://cnx.org/content/m11608/latest/&lt;br /&gt;
&lt;br /&gt;
A [[Matlab]] function is available at http://www.mathworks.com/matlabcentral/fileexchange/25746-kabsch-algorithm&lt;br /&gt;
&lt;br /&gt;
A [https://github.com/oleg-alexandrov/projects/blob/master/eigen/Kabsch.cpp C++ implementation] (and unit test) using [[Eigen (C++ library)|Eigen]]&lt;br /&gt;
&lt;br /&gt;
A [[Python (programming language)|Python]] script is available at https://github.com/charnley/rmsd. Another implementation can be found in&lt;br /&gt;
[https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.align_vectors.html SciPy].&lt;br /&gt;
&lt;br /&gt;
A free [[PyMol]] plugin easily implementing Kabsch is [https://www.pymolwiki.org/index.php/Kabsch]. (This previously linked to CEalign [https://wiki.pymol.org/index.php/Cealign], but this uses the Combinatorial Extension (CE) algorithm.) [[Visual Molecular Dynamics|VMD]] uses the Kabsch algorithm for its alignment.&lt;br /&gt;
&lt;br /&gt;
The [[FoldX]] modeling toolsuite incorporates the Kabsch algorithm to measure RMSD between Wild Type and Mutated protein structures.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Wahba&amp;#039;s problem|Wahba&amp;#039;s Problem]]&lt;br /&gt;
* [[Orthogonal Procrustes problem]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
* {{cite journal|last=Kabsch|first=Wolfgang|date=1976|title=A solution for the best rotation to relate two sets of vectors|journal=Acta Crystallographica|volume=A32|issue=5|page=922|doi=10.1107/S0567739476001873|bibcode=1976AcCrA..32..922K}}&lt;br /&gt;
** With a correction in {{cite journal|last=Kabsch|first=Wolfgang|date=1978|title=A discussion of the solution for the best rotation to relate two sets of vectors|journal=Acta Crystallographica|volume=A34|issue=5|pages=827–828|doi=10.1107/S0567739478001680|bibcode=1978AcCrA..34..827K|doi-access=free}}&lt;br /&gt;
* {{cite conference|last1=Lin|first1=Ying-Hung|last2=Chang|first2=Hsun-Chang|last3=Lin|first3=Yaw-Ling|date=December 15–17, 2004|title=A Study on Tools and Algorithms for 3-D Protein Structures Alignment and Comparison|conference=International Computer Symposium|location=Taipei, Taiwan}}&lt;br /&gt;
* {{cite journal|last=Umeyama|first=Shinji|date=1991|title=Least-Squares Estimation of Transformation Parameters Between Two Point Patterns|journal=IEEE Trans. Pattern Anal. Mach. Intell.|volume=13|issue=4|pages=376–380|doi=10.1109/34.88573}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Bioinformatics algorithms]]&lt;/div&gt;</summary>
		<author><name>82.193.241.6</name></author>
	</entry>
</feed>