IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/21
The Integrative Modeling Platform
Gaussian3D.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/Gaussian3D.h
3  * \brief Gaussian shape
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPALGEBRA_GAUSSIAN3D_H
10 #define IMPALGEBRA_GAUSSIAN3D_H
11 
12 #include <IMP/algebra/algebra_config.h>
13 #include "Transformation3D.h"
14 #include "ReferenceFrame3D.h"
15 #include <IMP/algebra/VectorD.h>
17 #include <cereal/access.hpp>
18 #include <Eigen/Dense>
19 
20 IMPALGEBRA_BEGIN_NAMESPACE
21 
22 //! A Gaussian distribution in 3D.
23 /** The variances are along the axis of the reference frame.
24 */
25 class Gaussian3D : public GeometricPrimitiveD<3> {
26  ReferenceFrame3D tr_;
27  Vector3D variances_;
28 
29  friend class cereal::access;
30 
31  template<class Archive> void serialize(Archive &ar) {
32  ar(tr_, variances_);
33  }
34 
35 public:
36  Gaussian3D() {
37  tr_ = ReferenceFrame3D();
38  variances_ = Vector3D(0, 0, 0);
39  }
40  Gaussian3D(const ReferenceFrame3D &tr, const Vector3D &variances)
41  : tr_(tr), variances_(variances) {}
42 
43  const ReferenceFrame3D &get_reference_frame() const { return tr_; }
44  const Vector3D &get_variances() const { return variances_; }
45  const Vector3D &get_center() const {
46  return get_reference_frame().get_transformation_to().get_translation();
47  }
48  IMP_SHOWABLE_INLINE(Gaussian3D, out << tr_ << ": " << variances_);
49 };
51 
52 /** Return the covariance matrix from a given set of standard deviations in
53  the passed reference frame. */
54 IMPALGEBRAEXPORT Eigen::Matrix3d get_covariance(const Gaussian3D &g);
55 
56 //! Return a Gaussian centered at the origin from a covariance matrix.
57 IMPALGEBRAEXPORT Gaussian3D
58 get_gaussian_from_covariance(const Eigen::Matrix3d &covariance,
59  const Vector3D &center);
60 
61 //! Rasterize the Gaussians to a grid.
62 IMPALGEBRAEXPORT DenseGrid3D<double>
63 get_rasterized(const Gaussian3Ds &gmm, const Floats &weights, double cell_width,
64  const BoundingBox3D &bb);
65 
66 //! Rasterize the Gaussians to a grid.
67 /** The result is an approximation, but is obtained significantly faster.
68  * Good for quickly checking a GMM.
69  */
70 IMPALGEBRAEXPORT DenseGrid3D<double>
71 get_rasterized_fast(const Gaussian3Ds &gmm, const Floats &weights,
72  double cell_width, const BoundingBox3D &bb, double factor=2.5);
73 
74 IMPALGEBRA_END_NAMESPACE
75 
76 #endif /* IMPALGEBRA_GAUSSIAN3D_H */
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
DenseGrid3D< double > get_rasterized(const Gaussian3Ds &gmm, const Floats &weights, double cell_width, const BoundingBox3D &bb)
Rasterize the Gaussians to a grid.
Gaussian3D get_gaussian_from_covariance(const Eigen::Matrix3d &covariance, const Vector3D &center)
Return a Gaussian centered at the origin from a covariance matrix.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
A reference frame in 3D.
A Gaussian distribution in 3D.
Definition: Gaussian3D.h:25
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
Base class for geometric types.
const Transformation3D & get_transformation_to() const
Return transformation from local to global coordinates.
Simple D vector class.
Simple 3D transformation class.
Eigen::Matrix3d get_covariance(const Gaussian3D &g)
VectorD< 3 > Vector3D
Definition: VectorD.h:408
All grids that are in the Python API should be defined here.
A reference frame in 3D.
A dense grid of values.
DenseGrid3D< double > get_rasterized_fast(const Gaussian3Ds &gmm, const Floats &weights, double cell_width, const BoundingBox3D &bb, double factor=2.5)
Rasterize the Gaussians to a grid.
const Vector3D & get_translation() const
Return the translation vector associated with this transformation.