IMP logo
IMP Reference Guide  2.5.0
The Integrative Modeling Platform
CompositeJoint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kinematics/CompositeJoint.h
3  * \brief a joint composed of several joints, applied on the same
4  * pair of rigid bodies
5  * \authors Dina Schneidman, Barak Raveh
6  *
7 
8  * Copyright 2007-2015 IMP Inventors. All rights reserved.
9  */
10 
11 #ifndef IMPKINEMATICS_COMPOSITE_JOINT_H
12 #define IMPKINEMATICS_COMPOSITE_JOINT_H
13 
14 #include "kinematics_config.h"
16 #include <IMP/kinematics/Joint.h>
17 #include <IMP/Object.h>
18 #include <IMP/exception.h>
19 #include <IMP/core/internal/dihedral_helpers.h>
20 #include <IMP/algebra/Vector3D.h>
21 #include <IMP/check_macros.h>
22 
23 IMPKINEMATICS_BEGIN_NAMESPACE
24 
25 class KinematicForest;
26 
27 /********************** CompositeJoint ***************/
28 
29 /**
30  A joint that combines several inner joints, acting on the same
31  pair of rigid bodies
32 */
33 class IMPKINEMATICSEXPORT CompositeJoint : public Joint {
34  public:
35  /**
36  Constructs a composite joint between parent and child,
37  with the specified list of inner joints connecting them.
38 
39  @param parent rigid body upstream of this joint
40  @param child rigid body downstream of this joint
41  @param[in] joints The list of inner joints connecting the two
42  rigid bodies. These will be applied by their
43  specified order in the list, from the parent
44  rigid body to the child rigid body. It is
45  assumed all these joints share the same
46  parent and child as the composite joint.
47  */
49  Joints joints = Joints());
50 
51  /**
52  adds a joint at the end of the list of joints (closest to the child
53  rigid body)
54  @note the joint must have the same parent and child as the composite
55  joint
56  */
58  IMP_ALWAYS_CHECK(j->get_parent_node() == this->get_parent_node() &&
59  j->get_child_node() == this->get_child_node(),
60  "inner joint within a composite joint must have"
61  "the same parent and child rigid body nodes",
63  joints_.push_back(j);
64  }
65 
66  /**
67  adds a joint at the front of the list of joints (closest to the parent
68  rigid body)
69  @note the joint must have the same parent and child as the composite
70  joint
71  */
73  IMP_ALWAYS_CHECK(j->get_parent_node() == this->get_parent_node() &&
74  j->get_child_node() == this->get_child_node(),
75  "inner joint within a composite joint must have"
76  << "the same parent and child rigid body nodes",
78  joints_.insert(joints_.begin(), j);
79  }
80 
81  /**
82  Sets the list of inner joints instead of the existing one,
83 
84  @param joints the new joints, ordered from the parent rigid body
85  downstream to the child rigid body.
86 
87  @note All joints must have the same parent and child as the composite
88  joint
89  @note This invalidates all existing inner joints if any, detaching
90  them from their current KinematicForest owner if it exists.
91  */
92  void set_joints(Joints joints);
93 
94  /**
95  returns the list of inner joints, ordered from the parent
96  rigid body downstream to the child rigid body
97  */
98  const Joints& get_inner_joints() const { return joints_; }
99 
100 #ifndef SWIG
101  /**
102  returns the list of inner joints, ordered from the parent
103  rigid body downstream to the child rigid body
104  */
105  Joints& get_inner_joints() { return joints_; }
106 #endif
107 
108  protected:
109  /**
110  update the child node reference frame by applying all the
111  inner joints
112  */
113  virtual void update_child_node_reference_frame() const;
114 
115  /**
116  Updates all inner joints value, and the overall transformation
117  resulting from their combinations, based on the external coordinates
118  of the witnesses to each of the inner joints.
119 
120  @note It is assumed that external coordinates are updated before
121  calling this function.
122  */
123 
125 
126  private:
127  Joints joints_; // list of inner joints
128 };
129 
131 
132 IMPKINEMATICS_END_NAMESPACE
133 
134 #endif /* IMPKINEMATICS_COMPOSITE_JOINT_H */
Exception definitions and assertions.
virtual void update_joint_from_cartesian_witnesses()
functionality for defining a kinematic joint between rigid bodies as part of a kinematic tree ...
functionality for defining nodes on a kinematic chain
const Joints & get_inner_joints() const
virtual void update_child_node_reference_frame() const
IMP::Vector< IMP::Pointer< Joint > > Joints
Definition: Joint.h:130
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Definition: object_macros.h:42
Exception definitions and assertions.
A shared base class to help in debugging and things.
Simple 3D vector class.
A decorator for a rigid body.
Definition: rigid_bodies.h:75
#define IMP_ALWAYS_CHECK(condition, message, exception_name)
Throw an exception if a check fails.
Definition: check_macros.h:61
An exception for an invalid value being passed to IMP.
Definition: exception.h:137