Go to the documentation of this file.00001
00002 #ifndef vgl_sphere_3d_h
00003 #define vgl_sphere_3d_h
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012 #include <vgl/vgl_fwd.h>
00013 #include <vgl/vgl_point_3d.h>
00014
00015
00016 template <class Type>
00017 class vgl_sphere_3d
00018 {
00019 vgl_point_3d<Type> c_;
00020 Type r_;
00021 public:
00022
00023
00024
00025
00026 inline vgl_sphere_3d (): c_(0.0, 0.0, 0.0), r_(-1) {}
00027
00028
00029 inline vgl_sphere_3d(Type px, Type py, Type pz, Type rad) : c_(px, py, pz), r_(rad) {}
00030
00031
00032 inline vgl_sphere_3d (const Type v[4]): c_(v[0], v[1], v[2]), r_(v[3]) {}
00033
00034
00035 vgl_sphere_3d (vgl_point_3d<Type> const& cntr, Type rad): c_(cntr), r_(rad) {}
00036
00037
00038 inline bool operator==(const vgl_sphere_3d<Type> &s) const { return this==&s || (c_==s.c_ && r_==s.r_); }
00039
00040 inline bool operator!=(vgl_sphere_3d<Type>const& s) const { return !operator==(s); }
00041
00042
00043
00044 inline const vgl_point_3d<Type> & centre() const {return c_;}
00045 inline Type radius() const {return r_;}
00046
00047
00048 inline bool is_empty() const {
00049 return r_ < 0.0;
00050 }
00051
00052
00053 bool contains(vgl_point_3d<Type> const& p) const;
00054
00055
00056 void set_empty() {c_.set(0,0,0); r_=-1;}
00057
00058
00059 inline void set_radius(Type r) { r_=r; }
00060
00061 inline void set_centre(const vgl_point_3d<Type> & c) { c_=c; }
00062
00063
00064 bool clip(const vgl_line_3d_2_points<Type> & line,
00065 vgl_point_3d<Type> &p1, vgl_point_3d<Type> &p2) const;
00066 };
00067
00068 #define VGL_SPHERE_3D_INSTANTIATE(T) extern "please include vgl/vgl_sphere_3d.txx first"
00069
00070 #endif // vgl_sphere_3d_h