IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
Ellipsoid3D.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/Ellipsoid3D.h \brief Simple 3D ellipsoid class.
3  *
4  * Copyright 2007-2022 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPALGEBRA_ELLIPSOID_3D_H
9 #define IMPALGEBRA_ELLIPSOID_3D_H
10 
11 #include <IMP/algebra/algebra_config.h>
12 #include "constants.h"
13 #include "BoundingBoxD.h"
14 #include "Transformation3D.h"
15 #include "ReferenceFrame3D.h"
16 #include "GeometricPrimitiveD.h"
17 #include <cereal/access.hpp>
18 
19 IMPALGEBRA_BEGIN_NAMESPACE
20 
21 //! Represent an ellipsoid in 3D.
22 /** \geometry */
23 class IMPALGEBRAEXPORT Ellipsoid3D : public GeometricPrimitiveD<3> {
24  public:
25  Ellipsoid3D() {}
26  Ellipsoid3D(const ReferenceFrame3D &rf, const algebra::Vector3D &radii)
27  : rf_(rf), radii_(radii) {}
28  Ellipsoid3D(const Vector3D &center, double radius_x, double radius_y,
29  double radius_z, const Rotation3D &rot);
30  const Vector3D &get_radii() const { return radii_; }
31  const ReferenceFrame3D &get_reference_frame() const { return rf_; }
32  IMP_SHOWABLE_INLINE(Ellipsoid3D, out << rf_ << ": " << radii_);
33 
34  private:
35  ReferenceFrame3D rf_;
36  Vector3D radii_;
37 
38  friend class cereal::access;
39 
40  template<class Archive> void serialize(Archive &ar) {
41  ar(rf_, radii_);
42  }
43 };
44 
47  return 4.0 / 3.0 * PI * g.get_radii()[0] *
48  g.get_radii()[1] * g.get_radii()[2],
49 {
50  Vector3D v = g.get_radii();
51  BoundingBoxD<3> b(-v, v);
52  return get_transformed(b, g.get_reference_frame().get_transformation_to());
53 });
54 
55 IMPALGEBRA_END_NAMESPACE
56 
57 #endif /* IMPALGEBRA_ELLIPSOID_3D_H */
Base class for geometric types.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Represent an ellipsoid in 3D.
Definition: Ellipsoid3D.h:23
static const double PI
the constant pi
A reference frame in 3D.
Base class for geometric types.
#define IMP_UNUSED(variable)
#define IMP_VOLUME_GEOMETRY_METHODS(Name, name, area, volume, bounding_box)
Implement the needed namespace methods for a geometry type.
A bounding box in D dimensions.
Various useful constants.
Simple 3D transformation class.
3D rotation class.
Definition: Rotation3D.h:52
VectorD< 3 > Vector3D
Definition: VectorD.h:408
A reference frame in 3D.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
Definition: check_macros.h:81
DensityMap * get_transformed(const DensityMap *input, const algebra::Transformation3D &tr, double threshold)
Return a new density map containing a rotated version of the old one.