IMP logo
IMP Reference Guide  2.13.0
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-2020 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 <Eigen/Dense>
18 
19 IMPALGEBRA_BEGIN_NAMESPACE
20 
21 //! A Gaussian distribution in 3D.
22 /** The variances are along the axis of the reference frame.
23 */
24 class Gaussian3D : public GeometricPrimitiveD<3> {
25  ReferenceFrame3D tr_;
26  Vector3D variances_;
27 
28 public:
29  Gaussian3D() {
30  tr_ = ReferenceFrame3D();
31  variances_ = Vector3D(0, 0, 0);
32  }
33  Gaussian3D(const ReferenceFrame3D &tr, const Vector3D &variances)
34  : tr_(tr), variances_(variances) {}
35 
36  const ReferenceFrame3D &get_reference_frame() const { return tr_; }
37  const Vector3D &get_variances() const { return variances_; }
38  const Vector3D &get_center() const {
39  return get_reference_frame().get_transformation_to().get_translation();
40  }
41  IMP_SHOWABLE_INLINE(Gaussian3D, out << tr_ << ": " << variances_);
42 };
44 
45 /** Return the covariance matrix from a given set of standard deviations in
46  the passed reference frame. */
47 IMPALGEBRAEXPORT Eigen::Matrix3d get_covariance(const Gaussian3D &g);
48 
49 //! Return a Gaussian centered at the origin from a covariance matrix.
50 IMPALGEBRAEXPORT Gaussian3D
51 get_gaussian_from_covariance(const Eigen::Matrix3d &covariance,
52  const Vector3D &center);
53 
54 //! Rasterize the Gaussians to a grid.
55 IMPALGEBRAEXPORT DenseGrid3D<double>
56 get_rasterized(const Gaussian3Ds &gmm, const Floats &weights, double cell_width,
57  const BoundingBox3D &bb);
58 
59 //! Rasterize the Gaussians to a grid.
60 /** The result is an approximation, but is obtained significantly faster.
61  * Good for quickly checking a GMM.
62  */
63 IMPALGEBRAEXPORT DenseGrid3D<double>
64 get_rasterized_fast(const Gaussian3Ds &gmm, const Floats &weights,
65  double cell_width, const BoundingBox3D &bb, double factor=2.5);
66 
67 IMPALGEBRA_END_NAMESPACE
68 
69 #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:39
A reference frame in 3D.
A Gaussian distribution in 3D.
Definition: Gaussian3D.h:24
#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:421
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.