IMP  2.2.0
The Integrative Modeling Platform
RigidBodyTunneler.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/RigidBodyTunneler.h
3  * \brief A mover that transform a rigid body
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_RIGID_BODY_TUNNELER_H
10 #define IMPCORE_RIGID_BODY_TUNNELER_H
11 
12 #include <IMP/core/core_config.h>
13 #include "MonteCarlo.h"
14 #include "MonteCarloMover.h"
15 #include <IMP/algebra/Vector3D.h>
17 #include <IMP/core/rigid_bodies.h>
18 #include <IMP/core/XYZ.h>
19 #include <IMP/algebra/eigen3/Eigen/Dense>
20 #include <IMP/algebra/eigen3/Eigen/Geometry>
21 
22 IMPCORE_BEGIN_NAMESPACE
23 
24 //! Modify the transformation of a rigid body
25 /** Provided a number of entry points in cartesian space, this mover will
26  * propose random translations of the rigid body from the closest entry point to
27  * a randomly chosen other one. This way of moving thus satisfies detailed
28  * balance. Entry points are relative to the center of the provided reference
29  * rigid body.
30  *
31  * \see RigidBodyMover
32  * \see MonteCarlo
33  */
34 class IMPCOREEXPORT RigidBodyTunneler : public MonteCarloMover {
35 
36  public:
37  /** Constructor
38  * \param m the model
39  * \param pi the rigidbody to move
40  * \param ref the rigidbody reference
41  * \param move_probability the prior probability to actually
42  * move somewhere else
43  */
45  kernel::ParticleIndex ref, double move_probability = 1.);
46 
47  //! add entry point in cartesian space
48  void add_entry_point(double x, double y, double z) {
49  IMP_Eigen::Vector3d pt;
50  pt << x, y, z;
51  entries_.push_back(pt);
52  }
53 
54  //! returns center of mass coordinates and quaternion of rotation wrt ref
55  static Floats get_reduced_coordinates(kernel::Model*m,
57 
58  //! returns center of mass coordinates and quaternion of rotation of pi
59  static Floats get_reduced_coordinates(kernel::Model*m,
61 
62  /// sets rigid body coordinates in the reference frame of ref
63  //void set_reduced_coordinates(algebra::VectorD<3> com, algebra::VectorD<4> q);
64 
65  protected:
66  virtual kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
67  virtual MonteCarloMoverResult do_propose() IMP_OVERRIDE;
68  virtual void do_reject() IMP_OVERRIDE;
70 
71 // Hide private nested classes from doxygen
72 #ifndef IMP_DOXYGEN
73  private:
74  class Referential {
75  private:
76  kernel::Model *m_;
78  IMP_Eigen::Vector3d centroid_;
79  IMP_Eigen::Matrix3d base_;
80  IMP_Eigen::Quaterniond q_;
81  IMP_Eigen::Vector3d t_;
82 
83  public:
84  Referential() {} //undefined behaviour, don't use
85  Referential(kernel::Model *m, kernel::ParticleIndex pi);
86  // return properties of this rigid body
87  IMP_Eigen::Vector3d get_centroid() const { return centroid_; }
88  IMP_Eigen::Matrix3d get_base() const { return base_; }
89  IMP_Eigen::Quaterniond get_rotation() const { return q_; }
90  // project some properties on this or the global frame's coordinates
91  IMP_Eigen::Vector3d get_local_coords(const IMP_Eigen::Vector3d
92  & other) const;
93  IMP_Eigen::Quaterniond get_local_rotation(const IMP_Eigen::Quaterniond
94  & other) const;
95 
96  private:
97  IMP_Eigen::Vector3d compute_centroid() const;
98  IMP_Eigen::Matrix3d compute_base() const;
99  IMP_Eigen::Quaterniond compute_quaternion() const;
100  IMP_Eigen::Quaterniond pick_positive(const IMP_Eigen::Quaterniond& q) const;
101  };
102 
103  class Translater {
104  private:
105  kernel::Model *m_;
106  Referential ref_;
107  kernel::ParticleIndex target_;
108  IMP_Eigen::Vector3d t_;
109  bool moved_;
110 
111  public:
112  // translate other by t in this reference frame
113  Translater(kernel::Model* m, const Referential& ref,
114  kernel::ParticleIndex other, const IMP_Eigen::Vector3d& t)
115  : m_(m), ref_(ref), target_(other), t_(t), moved_(true) {
116  translate();
117  }
118  // no-op
119  Translater() : moved_(false) {}
120  void undo_translate();
121  private:
122  void translate();
123  };
124 
125  private:
126  kernel::ParticleIndex pi_, ref_;
127  double move_probability_;
128  Translater last_translation_;
129  std::vector<IMP_Eigen::Vector3d> entries_; //Vector3d not vectorizable
130 #endif
131 
132 };
133 
134 IMPCORE_END_NAMESPACE
135 
136 #endif /* IMPCORE_RIGID_BODY_TUNNELER_H */
Simple Monte Carlo optimizer.
Simple xyz decorator.
A base class for classes which perturb particles.
functionality for defining rigid bodies
The base class for movers for MC optimization.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Simple 3D transformation class.
Vector3D get_centroid(const Vector3Ds &ps)
Returns the centroid of a set of vectors.
Definition: Vector3D.h:56
base::Index< ParticleIndexTag > ParticleIndex
Modify the transformation of a rigid body.
virtual ModelObjectsTemp do_get_inputs() const =0
Simple 3D vector class.
void add_entry_point(double x, double y, double z)
add entry point in cartesian space
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72