IMP logo
IMP Reference Guide  2.10.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-2018 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 //! Joint that combines several inner joints, acting on the same rigid body pair
28 class IMPKINEMATICSEXPORT CompositeJoint : public Joint {
29  public:
30  //! Constructor.
31  /** Constructs a composite joint between parent and child,
32  with the specified list of inner joints connecting them.
33 
34  @param parent rigid body upstream of this joint
35  @param child rigid body downstream of this joint
36  @param[in] joints The list of inner joints connecting the two
37  rigid bodies. These will be applied by their
38  specified order in the list, from the parent
39  rigid body to the child rigid body. It is
40  assumed all these joints share the same
41  parent and child as the composite joint.
42  */
44  Joints joints = Joints());
45 
46  //! Adds a joint at the end of the list (closest to the child rigid body)
47  /**
48  @note the joint must have the same parent and child as the composite
49  joint
50  */
52  IMP_ALWAYS_CHECK(j->get_parent_node() == this->get_parent_node() &&
53  j->get_child_node() == this->get_child_node(),
54  "inner joint within a composite joint must have"
55  "the same parent and child rigid body nodes",
57  joints_.push_back(j);
58  }
59 
60  //! Adds a joint at the front of the list (closest to the parent rigid body)
61  /** @note the joint must have the same parent and child as the composite
62  joint
63  */
65  IMP_ALWAYS_CHECK(j->get_parent_node() == this->get_parent_node() &&
66  j->get_child_node() == this->get_child_node(),
67  "inner joint within a composite joint must have"
68  << "the same parent and child rigid body nodes",
70  joints_.insert(joints_.begin(), j);
71  }
72 
73  //! Sets the list of inner joints instead of the existing one.
74  /** @param joints the new joints, ordered from the parent rigid body
75  downstream to the child rigid body.
76 
77  @note All joints must have the same parent and child as the composite
78  joint
79  @note This invalidates all existing inner joints if any, detaching
80  them from their current KinematicForest owner if it exists.
81  */
82  void set_joints(Joints joints);
83 
84  //! Returns the inner joints.
85  /** Returns the list of inner joints, ordered from the parent
86  rigid body downstream to the child rigid body.
87  */
88  const Joints& get_inner_joints() const { return joints_; }
89 
90 #ifndef SWIG
91  //! Returns the inner joints.
92  /** Returns the list of inner joints, ordered from the parent
93  rigid body downstream to the child rigid body.
94  */
95  Joints& get_inner_joints() { return joints_; }
96 #endif
97 
98  protected:
99  //! Update the child node reference frame by applying all the inner joints
100  virtual void update_child_node_reference_frame() const;
101 
102  /**
103  Updates all inner joints value, and the overall transformation
104  resulting from their combinations, based on the external coordinates
105  of the witnesses to each of the inner joints.
106 
107  @note It is assumed that external coordinates are updated before
108  calling this function.
109  */
110 
112 
113  private:
114  Joints joints_; // list of inner joints
115 };
116 
118 
119 IMPKINEMATICS_END_NAMESPACE
120 
121 #endif /* IMPKINEMATICS_COMPOSITE_JOINT_H */
void add_upstream_joint(Joint *j)
Adds a joint at the front of the list (closest to the parent rigid body)
Exception definitions and assertions.
Joints & get_inner_joints()
Returns the inner joints.
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
Returns the inner joints.
virtual void update_child_node_reference_frame() const
IMP::Vector< IMP::Pointer< Joint > > Joints
Definition: Joint.h:126
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
void add_downstream_joint(Joint *j)
Adds a joint at the end of the list (closest to the child rigid body)
Exception definitions and assertions.
Base class for joints between rigid bodies in a kinematic tree.
Definition: Joint.h:30
A shared base class to help in debugging and things.
Simple 3D vector class.
Joint that combines several inner joints, acting on the same rigid body pair.
A decorator for a rigid body.
Definition: rigid_bodies.h:82
#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