IMP  2.0.0
The Integrative Modeling Platform
ProjectionParameters.h
Go to the documentation of this file.
1 /**
2  * \file ProjectionParameters.h
3  * \brief Decorator for projection parameters
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5 */
6 
7 #ifndef IMPEM2D_PROJECTION_PARAMETERS_H
8 #define IMPEM2D_PROJECTION_PARAMETERS_H
9 
10 #include "IMP/em2d/em2d_config.h"
11 #include "IMP/algebra/Vector3D.h"
12 #include "IMP/algebra/Vector2D.h"
13 #include "IMP/algebra/Rotation3D.h"
14 #include "IMP/Decorator.h"
15 #include "IMP/decorator_macros.h"
16 #include "IMP/ScoreState.h"
17 #include "IMP/score_state_macros.h"
18 
19 
20 
21 IMPEM2D_BEGIN_NAMESPACE
22 
23 //! Decorator for particles representing the parameters
24 //! Rotation and tranlation. In this cases, the translation is the translation
25 //! to apply to the model in 3D, in order to perform the registration
26 class IMPEM2DEXPORT ProjectionParameters: public Decorator {
27 public:
28 
30 
31 
33 
34  //! Keys of the decorator
35  // FloatKeys get_keys();
36  static const FloatKeys& get_keys();
37 
38  //! ranges for the keys. Only adjust the translations, the rotations are
39  //! self adjusted
40  void set_proper_ranges_for_keys(Model *m,
41  const algebra::Vector3D &min_translation_values,
42  const algebra::Vector3D &max_translation_values);
43 
44  //! Create the proper attributes for a particle
45  static ProjectionParameters setup_particle(Particle *p);
46 
47  //!Return true of the particle is a set of projection parameters
48  static bool particle_is_instance(Particle *p);
49 
50 
51  //! Get whether the parameters are optimized
52  /*! \return true only if all of them are optimized.
53  */
54  bool get_parameters_optimized() const {
55  for(int i=0;i<6;++i) {
56  if(get_particle()->get_is_optimized(get_keys()[i])==false) {
57  return false;
58  }
59  }
60  return true;
61  }
62 
63  algebra::Vector3D get_translation() const {
64  return algebra::Vector3D(get_translation_x(),
65  get_translation_y(),
66  0.0);
67 
68  }
69 
70  void set_translation(const algebra::Vector3D &v) {
71  set_translation_x(v[0]);
72  set_translation_y(v[1]);
73  }
74 
75  algebra::Rotation3D get_rotation() const {
76  algebra::Vector4D v(get_quaternion_1(),
77  get_quaternion_2(),
78  get_quaternion_3(),
79  get_quaternion_4());
80  // normalize the vector. Given that the numbers generated with
81  // simplex are not necessarily a unit vector.
83  return algebra::Rotation3D(unit[0],
84  unit[1],
85  unit[2],
86  unit[3]);
87  }
88 
89  void set_rotation(const algebra::Rotation3D &R) {
90  set_quaternion_1(R.get_quaternion()[0]);
91  set_quaternion_2(R.get_quaternion()[1]);
92  set_quaternion_3(R.get_quaternion()[2]);
93  set_quaternion_4(R.get_quaternion()[3]);
94  }
95 
96  //! Set whether the parameters are optimized
97  inline void set_parameters_optimized(bool tf) const {
98  for(int i=0;i<6;++i) {
99  get_particle()->set_is_optimized(get_keys()[i], tf);
100  }
101  }
102 
103 
104 
105  //! Get and set functions for the parameters
106  IMP_DECORATOR_GET_SET(quaternion_1,get_keys()[0],Float,double);
107  IMP_DECORATOR_GET_SET(quaternion_2,get_keys()[1],Float,double);
108  IMP_DECORATOR_GET_SET(quaternion_3,get_keys()[2],Float,double);
109  IMP_DECORATOR_GET_SET(quaternion_4,get_keys()[3],Float,double);
110  IMP_DECORATOR_GET_SET(translation_x,get_keys()[4],Float,double);
111  IMP_DECORATOR_GET_SET(translation_y,get_keys()[5],Float,double);
112 
113 private:
114  algebra::Rotation3D rotation_;
115  algebra::Vector3D translation_;
116 
117 };
118 
119 IMP_DECORATORS(ProjectionParameters, ProjectionParametersList, Particles);
120 
121 
122 
123 
124 //! Score state to give information about the values of a ProjectionParameters
125 //! Decorator
126 class IMPEM2DEXPORT ProjectionParametersScoreState : public ScoreState {
127 public:
129  proj_params_ = p;
130  }
132 
133 private:
134  // Particle to store the projection params
135  Pointer<Particle> proj_params_;
136 };
137 
138 
139 
140 IMPEM2D_END_NAMESPACE
141 
142 #endif /* IMPEM2D_PROJECTION_PARAMETERS_H */