OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
RMSD.hpp
1/*
2 * *******************************************************************
3 *
4 * rmsd.h
5 * (c) 2005 Bosco K Ho
6 *
7 * Implementation of the Kabsch algorithm to find the RMSD, and
8 * the least-squares rotation matrix for a superposition between
9 * two sets of vectors.
10 *
11 * This implementation is completely self-contained. No other dependencies.
12 *
13 * **************************************************************************
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License as published
17 * by the Free Software Foundation; either version 2.1 of the License, or (at
18 * your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public License
26 * along with this program; if not, write to the Free Software Foundation,
27 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 *
29 * **************************************************************************
30 *
31 */
32
33#ifndef MATH_RMSD_HPP
34#define MATH_RMSD_HPP
35
36#include <config.h>
37
38#include <vector>
39
41
42namespace OpenMD {
43
44 class RMSD {
45 public:
46 RMSD();
47 RMSD(std::vector<Vector3d> ref) { set_reference_structure(ref); }
48 virtual ~RMSD() {};
49
50 void set_reference_structure(std::vector<Vector3d> ref) {
51 ref_ = ref;
52 ref_com = V3Zero;
53
54 for (unsigned int n = 0; n < ref_.size(); n++) {
55 ref_com += ref_[n];
56 }
57 ref_com /= (RealType)ref.size();
58 }
59
60 /*
61 * calculate_rmsd()
62 *
63 * given a vector of Vector3 coordinates, constructs
64 * - mov_com: the centre of mass of the mov list
65 * - mov_to_ref: vector between the com of mov and ref
66 * - U: the rotation matrix for least-squares, usage of
67 *
68 * returns
69 * - rmsd: measures similarity between the vectors
70 */
71 RealType calculate_rmsd(std::vector<Vector3d> mov, Vector3d mov_com,
72 Vector3d mov_to_ref);
73
74 /*
75 * optimal_superposition()
76 *
77 * Returns best-fit rotation matrix
78 */
79 RotMat3x3d optimal_superposition(std::vector<Vector3d> mov,
80 Vector3d mov_com, Vector3d mov_to_ref);
81
82 protected:
83 std::vector<Vector3d> ref_;
84 Vector3d ref_com;
85 };
86} // namespace OpenMD
87
88#endif
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.