00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXSPHEREF_H
00022 #define FXSPHEREF_H
00023
00024
00025 namespace FX {
00026
00027
00028 class FXRangef;
00029 class FXMat4f;
00030
00031
00032
00033 class FXAPI FXSpheref {
00034 public:
00035 FXVec3f center;
00036 FXfloat radius;
00037 public:
00038
00039
00040 FXSpheref(){}
00041
00042
00043 FXSpheref(const FXSpheref& sphere):center(sphere.center),radius(sphere.radius){}
00044
00045
00046 FXSpheref(const FXVec3f& cen,FXfloat rad=0.0f):center(cen),radius(rad){}
00047
00048
00049 FXSpheref(FXfloat x,FXfloat y,FXfloat z,FXfloat rad=0.0f):center(x,y,z),radius(rad){}
00050
00051
00052 FXSpheref(const FXRangef& bounds);
00053
00054
00055 FXSpheref& operator=(const FXSpheref& sphere){ center=sphere.center; radius=sphere.radius; return *this; }
00056
00057
00058 FXSpheref& set(const FXSpheref& sphere){ center=sphere.center; radius=sphere.radius; return *this; }
00059
00060
00061 FXSpheref& set(const FXVec3f& cen,FXfloat rad=0.0f){ center=cen; radius=rad; return *this; }
00062
00063
00064 FXSpheref& set(FXfloat x,FXfloat y,FXfloat z,FXfloat rad=0.0f){ center.set(x,y,z); radius=rad; return *this; }
00065
00066
00067 FXbool operator==(const FXSpheref& s) const { return center==s.center && radius==s.radius;}
00068 FXbool operator!=(const FXSpheref& s) const { return center!=s.center || radius!=s.radius;}
00069
00070
00071 FXfloat diameter() const { return radius*2.0f; }
00072
00073
00074 FXbool empty() const { return radius<0.0f; }
00075
00076
00077 FXbool contains(FXfloat x,FXfloat y,FXfloat z) const;
00078
00079
00080 FXbool contains(const FXVec3f& p) const;
00081
00082
00083 FXbool contains(const FXRangef& box) const;
00084
00085
00086 FXbool contains(const FXSpheref& sphere) const;
00087
00088
00089 FXSpheref& include(FXfloat x,FXfloat y,FXfloat z);
00090
00091
00092 FXSpheref& include(const FXVec3f& p);
00093
00094
00095 FXSpheref& includeInRadius(FXfloat x,FXfloat y,FXfloat z);
00096
00097
00098 FXSpheref& includeInRadius(const FXVec3f& p);
00099
00100
00101 FXSpheref& include(const FXRangef& box);
00102
00103
00104 FXSpheref& includeInRadius(const FXRangef& box);
00105
00106
00107 FXSpheref& include(const FXSpheref& sphere);
00108
00109
00110 FXSpheref& includeInRadius(const FXSpheref& sphere);
00111
00112
00113 FXint intersect(const FXVec4f& plane) const;
00114
00115
00116 FXbool intersect(const FXVec3f& u,const FXVec3f& v) const;
00117
00118
00119 FXSpheref transform(const FXMat4f& mat) const;
00120 };
00121
00122
00123
00124 extern FXAPI FXbool overlap(const FXRangef& a,const FXSpheref& b);
00125
00126
00127 extern FXAPI FXbool overlap(const FXSpheref& a,const FXRangef& b);
00128
00129
00130 extern FXAPI FXbool overlap(const FXSpheref& a,const FXSpheref& b);
00131
00132
00133 extern FXAPI FXStream& operator<<(FXStream& store,const FXSpheref& sphere);
00134
00135
00136 extern FXAPI FXStream& operator>>(FXStream& store,FXSpheref& sphere);
00137
00138 }
00139
00140 #endif