00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXSPHEREF_H
00025 #define FXSPHEREF_H
00026
00027
00028 namespace FX {
00029
00030
00031 class FXRangef;
00032
00033
00035 class FXAPI FXSpheref {
00036 public:
00037 FXVec3f center;
00038 FXfloat radius;
00039 public:
00040
00042 FXSpheref(){}
00043
00045 FXSpheref(const FXSpheref& sphere):center(sphere.center),radius(sphere.radius){}
00046
00048 FXSpheref(const FXVec3f& cen,FXfloat rad=0.0f):center(cen),radius(rad){}
00049
00051 FXSpheref(FXfloat x,FXfloat y,FXfloat z,FXfloat rad=0.0f):center(x,y,z),radius(rad){}
00052
00054 FXSpheref(const FXRangef& bounds);
00055
00057 FXSpheref& operator=(const FXSpheref& sphere){ center=sphere.center; radius=sphere.radius; return *this; }
00058
00060 FXSpheref& set(const FXSpheref& sphere){ center=sphere.center; radius=sphere.radius; return *this; }
00061
00063 FXSpheref& set(const FXVec3f& cen,FXfloat rad){ center=cen; radius=rad; return *this; }
00064
00066 FXSpheref& set(FXfloat x,FXfloat y,FXfloat z,FXfloat rad){ center.set(x,y,z); radius=rad; return *this; }
00067
00069 bool operator==(const FXSpheref& s) const { return center==s.center && radius==s.radius;}
00070 bool operator!=(const FXSpheref& s) const { return center!=s.center || radius!=s.radius;}
00071
00073 FXfloat diameter() const { return radius*2.0f; }
00074
00076 bool empty() const { return radius<0.0f; }
00077
00079 bool contains(FXfloat x,FXfloat y,FXfloat z) const;
00080
00082 bool contains(const FXVec3f& p) const;
00083
00085 bool contains(const FXRangef& box) const;
00086
00088 bool contains(const FXSpheref& sphere) const;
00089
00091 FXSpheref& include(FXfloat x,FXfloat y,FXfloat z);
00092
00094 FXSpheref& include(const FXVec3f& p);
00095
00097 FXSpheref& includeInRadius(FXfloat x,FXfloat y,FXfloat z);
00098
00100 FXSpheref& includeInRadius(const FXVec3f& p);
00101
00103 FXSpheref& include(const FXRangef& box);
00104
00106 FXSpheref& includeInRadius(const FXRangef& box);
00107
00109 FXSpheref& include(const FXSpheref& sphere);
00110
00112 FXSpheref& includeInRadius(const FXSpheref& sphere);
00113
00115 FXint intersect(const FXVec4f& plane) const;
00116
00118 bool intersect(const FXVec3f& u,const FXVec3f& v) const;
00119
00121 friend FXAPI bool overlap(const FXRangef& a,const FXSpheref& b);
00122
00124 friend FXAPI bool overlap(const FXSpheref& a,const FXRangef& b);
00125
00127 friend FXAPI bool overlap(const FXSpheref& a,const FXSpheref& b);
00128
00130 friend FXAPI FXStream& operator<<(FXStream& store,const FXSpheref& sphere);
00131
00133 friend FXAPI FXStream& operator>>(FXStream& store,FXSpheref& sphere);
00134 };
00135
00136
00137 extern FXAPI bool overlap(const FXRangef& a,const FXSpheref& b);
00138 extern FXAPI bool overlap(const FXSpheref& a,const FXRangef& b);
00139 extern FXAPI bool overlap(const FXSpheref& a,const FXSpheref& b);
00140
00141 extern FXAPI FXStream& operator<<(FXStream& store,const FXSpheref& sphere);
00142 extern FXAPI FXStream& operator>>(FXStream& store,FXSpheref& sphere);
00143
00144 }
00145
00146 #endif