IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
core/RigidBodyMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/RigidBodyMover.h
3  * \brief A mover that transforms a rigid body
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_RIGID_BODY_MOVER_H
10 #define IMPCORE_RIGID_BODY_MOVER_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/SingletonContainer.h>
18 #include <IMP/core/rigid_bodies.h>
19 #include <cereal/access.hpp>
20 #include <cereal/types/base_class.hpp>
21 
22 IMPCORE_BEGIN_NAMESPACE
23 
24 //! Modify the transformation of a rigid body
25 /** The transformation of the rigid body is moved in two ways -
26  the translation is moved with a ball of given size, and the
27  rotation changed up to a given maximum angle. In both cases
28  the probability distribution is uniform over the ball.
29  \see MonteCarlo
30  */
31 class IMPCOREEXPORT RigidBodyMover : public MonteCarloMover {
32  algebra::Transformation3D last_transformation_;
33  Float max_translation_;
34  Float max_angle_;
35  ParticleIndex pi_;
36 
37  friend class cereal::access;
38  template<class Archive> void serialize(Archive &ar) {
39  ar(cereal::base_class<MonteCarloMover>(this),
40  last_transformation_, max_translation_, max_angle_, pi_);
41  }
43 
44  public:
45  //! Constructor. The given rigid body is rotated and translated.
46  /** \param[in] m the Model
47  \param[in] pi particle index of the rigid body
48  \param[in] max_translation maximum translation during a step
49  \param[in] max_rotation maximum rotation angle in radians
50  */
52  Float max_translation, Float max_rotation);
53 
54  RigidBodyMover() {}
55 
56  void set_maximum_translation(Float mt) {
57  IMP_USAGE_CHECK(mt > 0, "Max translation must be positive");
58  max_translation_ = mt;
59  }
60 
61  void set_maximum_rotation(Float mr) {
62  IMP_USAGE_CHECK(mr > 0, "Max rotation must be positive");
63  max_angle_ = mr;
64  }
65 
66  Float get_maximum_translation() const { return max_translation_; }
67 
68  Float get_maximum_rotation() const { return max_angle_; }
69 
70  protected:
71  virtual ModelObjectsTemp do_get_inputs() const override;
72  virtual MonteCarloMoverResult do_propose() override;
73  virtual void do_reject() override;
75 };
76 
77 IMPCORE_END_NAMESPACE
78 
79 #endif /* IMPCORE_RIGID_BODY_MOVER_H */
Simple 3D transformation class.
A container for Singletons.
Simple Monte Carlo optimizer.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Modify the transformation of a rigid body.
virtual void do_reject()=0
Implement reset_proposed_move()
Return value of the MonteCarloMover::propose() function.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A base class for classes which perturb particles.
functionality for defining rigid bodies
The base class for movers for Monte Carlo optimization.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
virtual MonteCarloMoverResult do_propose()=0
Implement propose_move()
Simple 3D transformation class.
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
Simple 3D vector class.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
virtual ModelObjectsTemp do_get_inputs() const =0