IMP  2.1.1
The Integrative Modeling Platform
DOFValues.h
Go to the documentation of this file.
1 /**
2  * \file kinematics/DOFValues.h
3  * \brief a simple class for storage of DOF values.
4  *
5  * \authors Dina Schneidman, Barak Raveh
6  *
7  * Copyright 2007-2013 IMP Inventors. All rights reserved.
8  *
9  */
10 
11 #ifndef IMPKINEMATICS_DOF_VALUES_H
12 #define IMPKINEMATICS_DOF_VALUES_H
13 
14 #include "DOF.h"
15 
16 IMPKINEMATICS_BEGIN_NAMESPACE
17 
18 /*
19  A class that hold DOF values for DOFs
20  */
21 class IMPKINEMATICSEXPORT DOFValues : public std::vector<double> {
22 public:
23  // Constructor from DOFs
24  DOFValues(const DOFs& dofs) {
25  reserve(dofs.size());
26  for(unsigned int i=0; i<dofs.size(); i++)
27  push_back(dofs[i]->get_value());
28  }
29 
30  // Empty Constructor
31  DOFValues() {}
32 
33  // TODO: provide an option for more general distance definition
34  // through RRT class
35  double get_distance2(const DOFValues& other_dof_values) const {
36  double dist=0.0;
37  for(unsigned int i=0; i<size(); i++) {
38  double diff = ((*this)[i] - other_dof_values[i]);
39  dist += (diff*diff);
40  }
41  return dist/size();
42  }
43 
44  double get_distance(const DOFValues& other_dof_values) const {
45  return sqrt(get_distance2(other_dof_values));
46  }
47 
48  public:
49  IMP_SHOWABLE_INLINE(DOFValues,
50  {
51  out << "[";
52  if(size()>0) {
53  out << operator[](0);
54  }
55  for(unsigned int i=1 ; i < size(); i++) {
56  out << "," << operator[](i);
57  }
58  out << "]";
59  }
60  );
61 
62 };
63 
65 
66 IMPKINEMATICS_END_NAMESPACE
67 
68 #endif /* IMPKINEMATICS_DOF_VALUES_H */
single degree of freedom
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
double get_distance(const Plane3D &pln, const Vector3D &p)
Return the distance between a plane and a point in 3D.
Definition: Plane3D.h:68
IMP::base::Vector< IMP::base::Pointer< DOF > > DOFs
Definition: DOF.h:73