IMP  2.0.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-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,
31  double radius_y, double radius_z,
32  const Rotation3D &rot);
33  double get_radius(unsigned int i) const {
34  IMP_USAGE_CHECK(!base::isnan(radii_[0]),
35  "Attempt to use uninitialized ellipsoid.");
36  return radii_[i];
37  }
38  const Vector3D &get_center() const {return center_;}
39  const Rotation3D &get_rotation() const {
40  return rot_;
41  }
42  const Transformation3D get_transformation() const {
43  return Transformation3D(rot_, center_);
44  }
46  out << "(" << spaces_io(center_) << ": " << get_radius(0)
47  << ", " << get_radius(1) << ", " << get_radius(2)
48  << ")";
49  });
50 private:
51  Vector3D center_;
52  double radii_[3];
53  Rotation3D rot_;
54 };
55 
57  if (0) std::cout << g; IMP_NOT_IMPLEMENTED,
58  return 4.0/3.0 * PI *g.get_radius(0)
59  *g.get_radius(1)*g.get_radius(2),
60  {
61  Vector3D v(g.get_radius(0),
62  g.get_radius(1),
63  g.get_radius(2));
64  BoundingBoxD<3> b(-v, v);
65  return get_transformed(b, g.get_transformation());
66  });
67 
68 IMPALGEBRA_END_NAMESPACE
69 
70 #endif /* IMPALGEBRA_ELLIPSOID_3D_H */