IMP  2.1.1
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-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPALGEBRA_ELLIPSOID_3D_H
9 #define IMPALGEBRA_ELLIPSOID_3D_H
10 
11 #include "Cylinder3D.h"
12 #include <cmath>
13 #include "constants.h"
14 #include "BoundingBoxD.h"
15 #include "Transformation3D.h"
16 #include "GeometricPrimitiveD.h"
17 
18 IMPALGEBRA_BEGIN_NAMESPACE
19 
20 /** Represent an ellispoid in 3D.
21  \geometry
22  */
23 class IMPALGEBRAEXPORT Ellipsoid3D : public GeometricPrimitiveD<3> {
24  public:
25  Ellipsoid3D() {
26 #if IMP_HAS_CHECKS >= IMP_USAGE
27  radii_[0] = std::numeric_limits<double>::quiet_NaN();
28 #endif
29  }
30  Ellipsoid3D(const Vector3D &center, double radius_x, double radius_y,
31  double radius_z, const Rotation3D &rot);
32  double get_radius(unsigned int i) const {
33  IMP_USAGE_CHECK(!base::isnan(radii_[0]),
34  "Attempt to use uninitialized ellipsoid.");
35  return radii_[i];
36  }
37  const Vector3D &get_center() const { return center_; }
38  const Rotation3D &get_rotation() const { return rot_; }
39  const Transformation3D get_transformation() const {
40  return Transformation3D(rot_, center_);
41  }
43  out << "(" << spaces_io(center_) << ": " << get_radius(0) << ", "
44  << get_radius(1) << ", " << get_radius(2) << ")";
45  });
46 
47  private:
48  Vector3D center_;
49  double radii_[3];
50  Rotation3D rot_;
51 };
52 
54  Ellipsoid3D, ellipsoid_3d, if (0) std::cout << g;
56  return 4.0 / 3.0 * PI * g.get_radius(0) * g.get_radius(1) * g.get_radius(2),
57  {
58  Vector3D v(g.get_radius(0), g.get_radius(1), g.get_radius(2));
59  BoundingBoxD<3> b(-v, v);
60  return get_transformed(b, g.get_transformation());
61  });
62 
63 IMPALGEBRA_END_NAMESPACE
64 
65 #endif /* IMPALGEBRA_ELLIPSOID_3D_H */
Basic types used by IMP.
Simple 3D transformation class.
#define IMP_NOT_IMPLEMENTED
Use this to make that the method is not implemented yet.
stores a cylinder
static const double PI
the constant pi
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#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:45
bool isnan(const T &a)
Return true if a number is NaN.
Definition: base/math.h:24