00001
00002
00003
00004
00005
00006
00007 #ifndef IMPALGEBRA_ELLIPSOID_3D_H
00008 #define IMPALGEBRA_ELLIPSOID_3D_H
00009
00010 #include "Cylinder3D.h"
00011 #include <cmath>
00012 #include <IMP/constants.h>
00013 #include "internal/cgal_predicates.h"
00014 #include "BoundingBoxD.h"
00015 #include "Transformation3D.h"
00016
00017 IMPALGEBRA_BEGIN_NAMESPACE
00018
00019
00020
00021
00022 class IMPALGEBRAEXPORT Ellipsoid3D {
00023 public:
00024 Ellipsoid3D(){
00025 #if IMP_BUILD < IMP_FAST
00026 radii_[0]= std::numeric_limits<double>::quiet_NaN();
00027 #endif
00028 }
00029 Ellipsoid3D(const VectorD<3>& center,double radius_x,
00030 double radius_y, double radius_z,
00031 const Rotation3D &rot);
00032 double get_radius(unsigned int i) const {
00033 IMP_USAGE_CHECK(!is_nan(radii_[0]),
00034 "Attempt to use uninitialized ellipsoid.");
00035 return radii_[i];
00036 }
00037 const VectorD<3> &get_center() const {return center_;}
00038 const Rotation3D &get_rotation() const {
00039 return rot_;
00040 }
00041 const Transformation3D get_transformation() const {
00042 return Transformation3D(rot_, center_);
00043 }
00044 IMP_SHOWABLE_INLINE({
00045 out << "(" << spaces_io(center_) << ": " << get_radius(0)
00046 << ", " << get_radius(1) << ", " << get_radius(2)
00047 << ")";
00048 });
00049 private:
00050 VectorD<3> center_;
00051 double radii_[3];
00052 Rotation3D rot_;
00053 };
00054
00055 IMP_VOLUME_GEOMETRY_METHODS(Ellipsoid3D,
00056 IMP_NOT_IMPLEMENTED,
00057 return 4.0/3.0 * PI *g.get_radius(0)
00058 *g.get_radius(1)*g.get_radius(2),
00059 {
00060 VectorD<3> v(g.get_radius(0),
00061 g.get_radius(1),
00062 g.get_radius(2));
00063 BoundingBoxD<3> b(-v, v);
00064 return get_transformed(b, g.get_transformation());
00065 });
00066
00067 IMPALGEBRA_END_NAMESPACE
00068
00069 #endif