IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
directional_DOFs.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kinematics/directional_DOFs.h
3  * \brief
4  * \authors Dina Schneidman, Barak Raveh
5  *
6  * Copyright 2007-2017 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPKINEMATICS_DIRECTIONAL_DO_FS_H
11 #define IMPKINEMATICS_DIRECTIONAL_DO_FS_H
12 
13 #include "DOF.h"
14 
15 IMPKINEMATICS_BEGIN_NAMESPACE
16 
17 /**
18  this is a linear one.
19  \note We may want to make it more general. This will require
20  turning it into a virtual class.
21 */
22 class IMPKINEMATICSEXPORT DirectionalDOF : public IMP::Object {
23  public:
24  DirectionalDOF(const DOFs& dofs) : Object("DirectionalDOF%1%"), dofs_(dofs) {}
25 
26  void set_end_points(const DOFValues& q1, const DOFValues& q2) {
27  endpoint1_ = q1;
28  endpoint2_ = q2;
29  current_delta_.resize(dofs_.size());
30  // TODO: check that the size of dofs_, q1 and q2 is the same
31  // IMP_CHECK...
32 
33  // determine step size based on each DOF
34  step_number_ = 0;
35  for (unsigned int i = 0; i < dofs_.size(); i++) {
36  int dof_step_number =
37  dofs_[i]->get_number_of_steps(endpoint1_[i], endpoint2_[i]);
38  if (dof_step_number > step_number_) step_number_ = dof_step_number;
39  }
40 
41  for (unsigned int i = 0; i < dofs_.size(); i++) {
42  current_delta_[i] = (endpoint2_[i] - endpoint1_[i]) / step_number_;
43  }
44 
45  current_step_number_ = 0;
46  delta_ = 1.0 / step_number_;
47  value_ = 0.0;
48  }
49 
50  // return current DOF
51  DOFValues get_dofs_values() {
52  DOFValues ret = endpoint1_;
53  for (unsigned int i = 0; i < ret.size(); i++) {
54  ret[i] += current_step_number_ * current_delta_[i];
55  }
56  return ret;
57  }
58 
59  double get_value() const { return value_; }
60 
61 #ifndef SWIG
62  void operator++(int) {
63  current_step_number_++;
64  value_ += delta_;
65  }
66  void operator--(int) {
67  current_step_number_--;
68  value_ -= delta_;
69  }
70 #endif
71 
73 
74  protected:
75  DOFs dofs_; // can be a pointer
76  DOFValues endpoint1_;
77  DOFValues endpoint2_;
78 
79  // step size for each DOF for endpoint1 and endpoint2
80  DOFValues current_delta_;
81 
82  // step number based on current_delta_
83  int step_number_;
84 
85  // counter for step_number_
86  int current_step_number_;
87 
88  // follows curr_step_number_ between 0 and 1
89  double value_;
90 
91  // delta for value
92  double delta_;
93 };
94 
96 
97 IMPKINEMATICS_END_NAMESPACE
98 
99 #endif /* IMPKINEMATICS_DIRECTIONAL_DO_FS_H */
single degree of freedom
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Common base class for heavy weight IMP objects.
Definition: Object.h:106
A class that holds DOF values for DOFs.
Definition: DOFValues.h:20
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
Object(std::string name)
Construct an object with the given name.