IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
20IMPALGEBRA_BEGIN_NAMESPACE
21
22//! A Gaussian distribution in 3D.
23/** The variances are along the axis of the reference frame.
24*/
25class Gaussian3D : public GeometricPrimitiveD<3> {
27 Vector3D variances_;
28
29 friend class cereal::access;
30
31 template<class Archive> void serialize(Archive &ar) {
32 ar(tr_, variances_);
33 }
34
35public:
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. */
54IMPALGEBRAEXPORT Eigen::Matrix3d get_covariance(const Gaussian3D &g);
55
56//! Return a Gaussian centered at the origin from a covariance matrix.
57IMPALGEBRAEXPORT Gaussian3D
58get_gaussian_from_covariance(const Eigen::Matrix3d &covariance,
59 const Vector3D &center);
60
61//! Rasterize the Gaussians to a grid.
62IMPALGEBRAEXPORT DenseGrid3D<double>
63get_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 */
70IMPALGEBRAEXPORT DenseGrid3D<double>
71get_rasterized_fast(const Gaussian3Ds &gmm, const Floats &weights,
72 double cell_width, const BoundingBox3D &bb, double factor=2.5);
73
74IMPALGEBRA_END_NAMESPACE
75
76#endif /* IMPALGEBRA_GAUSSIAN3D_H */
A reference frame in 3D.
Simple 3D transformation class.
Simple D vector class.
A Gaussian distribution in 3D.
Definition Gaussian3D.h:25
A reference frame in 3D.
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.
Gaussian3D get_gaussian_from_covariance(const Eigen::Matrix3d &covariance, const Vector3D &center)
Return a Gaussian centered at the origin from a covariance matrix.
BoundingBoxD< 3 > BoundingBox3D
Typedef for Python.
IMP::Vector< Gaussian3D > Gaussian3Ds
Definition Gaussian3D.h:50
Eigen::Matrix3d get_covariance(const Gaussian3D &g)
DenseGrid3D< double > get_rasterized(const Gaussian3Ds &gmm, const Floats &weights, double cell_width, const BoundingBox3D &bb)
Rasterize the Gaussians to a grid.
VectorD< 3 > Vector3D
Definition VectorD.h:407
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
Definition types.h:46
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
All grids that are in the Python API should be defined here.
A dense grid of values.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.