IMP  2.2.1
The Integrative Modeling Platform
Gaussian.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/Gaussian.h
3  * \brief Decorator to hold Gaussian3D
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_GAUSSIAN_H
10 #define IMPCORE_GAUSSIAN_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/algebra/Gaussian3D.h>
14 #include <IMP/kernel/Particle.h>
15 #include <IMP/kernel/Model.h>
16 #include <IMP/Decorator.h>
17 #include <IMP/decorator_macros.h>
18 #include <IMP/base/exception.h>
19 #include <IMP/core/rigid_bodies.h>
20 #include "internal/rigid_bodies.h"
21 #include <IMP/algebra/eigen3/Eigen/Dense>
22 
23 IMPCORE_BEGIN_NAMESPACE
24 
25 /** A decorator for a particle storing a Gaussian. */
26 class IMPCOREEXPORT Gaussian : public RigidBody {
27  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
28  const algebra::Gaussian3D &g);
29  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi);
30 
31  public:
35 
36  IMP_Eigen::Matrix3d get_covariance() const;
37  void set_gaussian(const algebra::Gaussian3D &g);
38 
39  void set_variances(const algebra::Vector3D &radii) {
40  for (unsigned int i = 0; i < 3; ++i) {
41  get_model()->set_attribute(get_variance_key(i), get_particle_index(),
42  radii[i]);
43  }
44  }
45 
46  inline algebra::Vector3D get_variances() const {
47  return algebra::Vector3D(
48  get_model()->get_attribute(get_variance_key(0), get_particle_index()),
49  get_model()->get_attribute(get_variance_key(1), get_particle_index()),
50  get_model()->get_attribute(get_variance_key(2), get_particle_index()));
51  }
52 
53  inline algebra::Gaussian3D get_gaussian() const {
54  return algebra::Gaussian3D(RigidBody::get_reference_frame(),
55  get_variances());
56  }
57 
58  static FloatKey get_variance_key(unsigned int i);
59 
60  static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi) {
61  return m->get_has_attribute(get_variance_key(0), pi);
62  }
63 };
64 IMP_DECORATORS(Gaussian, Gaussians, kernel::Particles);
65 
66 IMPCORE_END_NAMESPACE
67 
68 #endif /* IMPCORE_GAUSSIAN_H */
Import IMP/kernel/Decorator.h in the namespace.
ParticleIndex get_particle_index() const
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
IMP_Eigen::Matrix3d get_covariance(const Gaussian3D &g)
#define IMP_DECORATOR_SETUP_0(Name)
IMP::kernel::Model Model
functionality for defining rigid bodies
Import IMP/kernel/decorator_macros.h in the namespace.
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles.
Exception definitions and assertions.
base::Index< ParticleIndexTag > ParticleIndex
VectorD< 3 > Vector3D
Definition: VectorD.h:395
gaussian shape
A decorator for a rigid body.
Definition: rigid_bodies.h:75
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72