9 #ifndef IMPALGEBRA_DISTANCE_H
10 #define IMPALGEBRA_DISTANCE_H
12 #include <IMP/algebra/algebra_config.h>
17 IMPALGEBRA_BEGIN_NAMESPACE
26 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
28 const Vector3DsOrXYZs0& m1,
29 const Vector3DsOrXYZs1& m2) {
30 using algebra::get_vector_geometry;
32 std::distance(m2.begin(), m2.end()),
33 "The input sets of XYZ points "
34 <<
"should be of the same size");
36 typename Vector3DsOrXYZs0::const_iterator it0 = m1.begin();
37 typename Vector3DsOrXYZs1::const_iterator it1 = m2.begin();
38 for (; it0 != m1.end(); ++it0, ++it1) {
42 return std::sqrt(rmsd / m1.size());
46 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
47 inline double get_rmsd(
const Vector3DsOrXYZs0& m1,
const Vector3DsOrXYZs1& m2) {
52 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
53 inline double get_weighted_rmsd_transforming_first(
const Transformation3D& tr,
54 const Vector3DsOrXYZs0& m1,
55 const Vector3DsOrXYZs1& m2,
57 using algebra::get_vector_geometry;
59 std::distance(m2.begin(), m2.end()),
60 "The input sets of XYZ points "
61 <<
"should be of the same size");
63 std::distance(weights.begin(), weights.end()),
64 "The input sets of XYZ points and the weights "
65 <<
"should be of the same size");
68 double weight_sum = 0.0;
69 typename Vector3DsOrXYZs0::const_iterator it0 = m1.begin();
70 typename Vector3DsOrXYZs1::const_iterator it1 = m2.begin();
71 Floats::const_iterator it3 = weights.begin();
72 for (; it0 != m1.end(); ++it0, ++it1, ++it3) {
73 Vector3D tred = tr.get_transformed(get_vector_geometry(*it0));
77 return std::sqrt(rmsd / weight_sum);
82 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
89 IMPALGEBRA_END_NAMESPACE
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.
double get_weighted_rmsd(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2, const Floats &weights)
double get_rmsd(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2)
Transformation3D get_identity_transformation_3d()
Return a transformation that does not do anything.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
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.