IMP  2.2.1
The Integrative Modeling Platform
algebra/distance.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/distance.h
3  * \brief distance metrics
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPALGEBRA_DISTANCE_H
10 #define IMPALGEBRA_DISTANCE_H
11 
12 #include <IMP/algebra/algebra_config.h>
13 #include "Transformation3D.h"
14 #include "VectorD.h"
15 #include "IMP/base_types.h"
16 
17 IMPALGEBRA_BEGIN_NAMESPACE
18 
19 //! Calculate the root mean square deviation between two sets of 3D points.
20 /**
21  \note the function assumes correspondence between the two sets of
22  points and does not perform rigid alignment.
23 
24  \genericgeometry
25  */
26 template <class Vector3DsOrXYZs0, class Vector3DsOrXYZs1>
28  const Vector3DsOrXYZs0& m1,
29  const Vector3DsOrXYZs1& m2) {
30  using algebra::get_vector_geometry;
31  IMP_USAGE_CHECK(std::distance(m1.begin(), m1.end()) ==
32  std::distance(m2.begin(), m2.end()),
33  "The input sets of XYZ points "
34  << "should be of the same size");
35  double rmsd = 0.0;
36  typename Vector3DsOrXYZs0::const_iterator it0 = m1.begin();
37  typename Vector3DsOrXYZs1::const_iterator it1 = m2.begin();
38  for (; it0 != m1.end(); ++it0, ++it1) {
39  Vector3D tred = tr.get_transformed(get_vector_geometry(*it0));
40  rmsd += get_squared_distance(tred, get_vector_geometry(*it1));
41  }
42  return std::sqrt(rmsd / m1.size());
43 }
44 
45 /** Se get_rmsd_transforming_first(). */
46 template <class Vector3DsOrXYZs0, class Vector3DsOrXYZs1>
47 inline double get_rmsd(const Vector3DsOrXYZs0& m1, const Vector3DsOrXYZs1& m2) {
49 }
50 
51 IMPALGEBRA_END_NAMESPACE
52 
53 #endif /* IMPALGEBRA_DISTANCE_H */
Simple 3D transformation class.
Import IMP/kernel/base_types.h in the namespace.
double get_squared_distance(const VectorD< D > &v1, const VectorD< D > &v2)
compute the squared distance between two vectors
Definition: VectorD.h:201
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
double get_rmsd(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2)
Simple D vector class.
Vector3D get_transformed(const Vector3D &o) const
transform
Simple 3D transformation class.
Transformation3D get_identity_transformation_3d()
Return a transformation that does not do anything.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
double get_rmsd_transforming_first(const Transformation3D &tr, const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2)
Calculate the root mean square deviation between two sets of 3D points.