IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
ProjectionParameters.h
Go to the documentation of this file.
1/**
2 * \file IMP/em2d/ProjectionParameters.h
3 * \brief Decorator for projection parameters
4 * Copyright 2007-2022 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>
14#include "IMP/Decorator.h"
16#include "IMP/ScoreState.h"
17
18IMPEM2D_BEGIN_NAMESPACE
19
20//! Decorator for particles representing the parameters
21//! Rotation and translation. In this cases, the translation is the translation
22//! to apply to the model in 3D, in order to perform the registration
23class IMPEM2DEXPORT ProjectionParameters : public Decorator {
24 static void do_setup_particle(Model *m, ParticleIndex pi);
25
26 public:
27 IMP_DECORATOR_METHODS(ProjectionParameters, Decorator);
28 IMP_DECORATOR_SETUP_0(ProjectionParameters);
29
30 ~ProjectionParameters() {};
31
32 //! Keys of the decorator
33 // FloatKeys get_keys();
34 static const FloatKeys &get_keys();
35
36 //! ranges for the keys. Only adjust the translations, the rotations are
37 //! self adjusted
39 Model *m, const algebra::Vector3D &min_translation_values,
40 const algebra::Vector3D &max_translation_values);
41
42 //! Return true if the particle is a set of projection parameters
43 static bool get_is_setup(Model *m, ParticleIndex pi);
44
45 //! Get whether the parameters are optimized
46 /** \return true only if all of them are optimized.
47 */
49 for (int i = 0; i < 6; ++i) {
50 if (get_particle()->get_is_optimized(get_keys()[i]) == false) {
51 return false;
52 }
53 }
54 return true;
55 }
56
57 algebra::Vector3D get_translation() const {
58 return algebra::Vector3D(get_translation_x(), get_translation_y(), 0.0);
59 }
60
61 void set_translation(const algebra::Vector3D &v) {
62 set_translation_x(v[0]);
63 set_translation_y(v[1]);
64 }
65
66 algebra::Rotation3D get_rotation() const {
67 algebra::Vector4D v(get_quaternion_1(), get_quaternion_2(),
68 get_quaternion_3(), get_quaternion_4());
69 // normalize the vector. Given that the numbers generated with
70 // simplex are not necessarily a unit vector.
71 algebra::Vector4D unit = v.get_unit_vector();
72 return algebra::Rotation3D(unit[0], unit[1], unit[2], unit[3]);
73 }
74
75 void set_rotation(const algebra::Rotation3D &R) {
76 set_quaternion_1(R.get_quaternion()[0]);
77 set_quaternion_2(R.get_quaternion()[1]);
78 set_quaternion_3(R.get_quaternion()[2]);
79 set_quaternion_4(R.get_quaternion()[3]);
80 }
81
82 //! Set whether the parameters are optimized
83 inline void set_parameters_optimized(bool tf) const {
84 for (int i = 0; i < 6; ++i) {
85 get_particle()->set_is_optimized(get_keys()[i], tf);
86 }
87 }
88
89 //! Get and set functions for the parameters
90 IMP_DECORATOR_GET_SET(quaternion_1, get_keys()[0], Float, double);
91 IMP_DECORATOR_GET_SET(quaternion_2, get_keys()[1], Float, double);
92 IMP_DECORATOR_GET_SET(quaternion_3, get_keys()[2], Float, double);
93 IMP_DECORATOR_GET_SET(quaternion_4, get_keys()[3], Float, double);
94 IMP_DECORATOR_GET_SET(translation_x, get_keys()[4], Float, double);
95 IMP_DECORATOR_GET_SET(translation_y, get_keys()[5], Float, double);
96
97 private:
98 algebra::Rotation3D rotation_;
99 algebra::Vector3D translation_;
100};
101
102IMP_DECORATORS(ProjectionParameters, ProjectionParametersList,
103 Particles);
104
105//! Score state to give information about the values of a ProjectionParameters
106//! Decorator
107class IMPEM2DEXPORT ProjectionParametersScoreState : public ScoreState {
108 public:
109 ProjectionParametersScoreState(Particle *p)
110 : ScoreState(p->get_model(), "ProjectionParametersScoreState%1%") {
111 proj_params_ = p;
112 }
113 virtual void do_before_evaluate() override;
114 virtual void do_after_evaluate(DerivativeAccumulator *da) override;
115 virtual ModelObjectsTemp do_get_inputs() const override;
116 virtual ModelObjectsTemp do_get_outputs() const override;
117 IMP_OBJECT_METHODS(ProjectionParametersScoreState);
118
119 private:
120 // Particle to store the projection params
121 Pointer<Particle> proj_params_;
122};
123
124IMPEM2D_END_NAMESPACE
125
126#endif /* IMPEM2D_PROJECTION_PARAMETERS_H */
The base class for decorators.
Simple 3D rotation class.
Shared score state.
Simple 2D vector class.
Simple 3D vector class.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition Decorator.h:194
Class for adding derivatives from restraints to the model.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
3D rotation class.
Definition Rotation3D.h:52
virtual void do_before_evaluate() override
Update the state given the current state of the model.
virtual ModelObjectsTemp do_get_inputs() const override
virtual void do_after_evaluate(DerivativeAccumulator *da) override
Do any necessary updates after the model score is calculated.
virtual ModelObjectsTemp do_get_outputs() const override
bool get_parameters_optimized() const
Get whether the parameters are optimized.
void set_parameters_optimized(bool tf) const
Set whether the parameters are optimized.
static const FloatKeys & get_keys()
Keys of the decorator.
void set_proper_ranges_for_keys(Model *m, const algebra::Vector3D &min_translation_values, const algebra::Vector3D &max_translation_values)
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is a set of projection parameters.
Helper macros for implementing Decorators.
#define IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType)
Define methods for getting and setting a particular simple field.
#define IMP_DECORATOR_SETUP_0(Name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Vector< Pointer< Particle > > Particles
A list of reference-counted Particle objects.
Definition base_types.h:138
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
VectorD< 3 > Vector3D
Definition VectorD.h:407
IMP::Vector< FloatKey > FloatKeys
Definition base_types.h:33
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A smart pointer to a reference counted object.
Definition Pointer.h:88