00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef FXRANGED_H
00024 #define FXRANGED_H
00025
00026
00027 namespace FX {
00028
00029
00030 class FXSphered;
00031 class FXMat4d;
00032
00033
00034
00035 class FXAPI FXRanged {
00036 public:
00037 FXVec3d lower;
00038 FXVec3d upper;
00039 public:
00040
00041
00042 FXRanged(){}
00043
00044
00045 FXRanged(const FXRanged& bounds):lower(bounds.lower),upper(bounds.upper){}
00046
00047
00048 FXRanged(const FXVec3d& p):lower(p),upper(p){}
00049
00050
00051 FXRanged(const FXVec3d& l,const FXVec3d& h):lower(l),upper(h){}
00052
00053
00054 FXRanged(FXdouble x,FXdouble y,FXdouble z):lower(x,y,z),upper(x,y,z){}
00055
00056
00057 FXRanged(FXdouble xl,FXdouble xh,FXdouble yl,FXdouble yh,FXdouble zl,FXdouble zh):lower(xl,yl,zl),upper(xh,yh,zh){}
00058
00059
00060 FXRanged(const FXSphered& sphere);
00061
00062
00063 FXRanged& operator=(const FXRanged& bounds){ lower=bounds.lower; upper=bounds.upper; return *this; }
00064
00065
00066 FXRanged& set(const FXRanged& bounds){ lower=bounds.lower; upper=bounds.upper; return *this; }
00067
00068
00069 FXRanged& set(const FXVec3d& p){ lower=upper=p; return *this; }
00070
00071
00072 FXRanged& set(const FXVec3d& l,const FXVec3d& h){ lower=l; upper=h; return *this; }
00073
00074
00075 FXRanged& set(FXdouble x,FXdouble y,FXdouble z){ lower.x=upper.x=x; lower.y=upper.y=y; lower.z=upper.z=z; return *this; }
00076
00077
00078 FXRanged& set(FXdouble xl,FXdouble xh,FXdouble yl,FXdouble yh,FXdouble zl,FXdouble zh){ lower.set(xl,yl,zl); upper.set(xh,yh,zh); return *this; }
00079
00080
00081 FXVec3d& operator[](FXint i){ return (&lower)[i]; }
00082
00083
00084 const FXVec3d& operator[](FXint i) const { return (&lower)[i]; }
00085
00086
00087 FXbool operator==(const FXRanged& r) const { return lower==r.lower && upper==r.upper; }
00088 FXbool operator!=(const FXRanged& r) const { return lower!=r.lower || upper!=r.upper; }
00089
00090
00091 FXdouble width() const { return upper.x-lower.x; }
00092
00093
00094 FXdouble height() const { return upper.y-lower.y; }
00095
00096
00097 FXdouble depth() const { return upper.z-lower.z; }
00098
00099
00100 FXdouble longest() const;
00101
00102
00103 FXdouble shortest() const;
00104
00105
00106 FXdouble diameter() const;
00107
00108
00109 FXdouble radius() const;
00110
00111
00112 FXVec3d diagonal() const;
00113
00114
00115 FXVec3d center() const;
00116
00117
00118 FXbool empty() const;
00119
00120
00121 FXbool contains(FXdouble x,FXdouble y,FXdouble z) const;
00122
00123
00124 FXbool contains(const FXVec3d& p) const;
00125
00126
00127 FXbool contains(const FXRanged& bounds) const;
00128
00129
00130 FXbool contains(const FXSphered& sphere) const;
00131
00132
00133 FXRanged& include(FXdouble x,FXdouble y,FXdouble z);
00134
00135
00136 FXRanged& include(const FXVec3d& v);
00137
00138
00139 FXRanged& include(const FXRanged& box);
00140
00141
00142 FXRanged& include(const FXSphered& sphere);
00143
00144
00145 FXint intersect(const FXVec4d &plane) const;
00146
00147
00148 FXbool intersect(const FXVec3d& u,const FXVec3d& v);
00149
00150
00151 friend FXAPI FXbool overlap(const FXRanged& a,const FXRanged& b);
00152
00153
00154 FXVec3d corner(FXint c) const { return FXVec3d((&lower)[c&1].x, (&lower)[(c>>1)&1].y, (&lower)[c>>2].z); }
00155
00156
00157 FXRanged transform(const FXMat4d& mat) const;
00158
00159
00160 friend FXAPI FXRanged unite(const FXRanged& a,const FXRanged& b);
00161
00162
00163 friend FXAPI FXRanged intersect(const FXRanged& a,const FXRanged& b);
00164
00165
00166 friend FXAPI FXStream& operator<<(FXStream& store,const FXRanged& bounds);
00167
00168
00169 friend FXAPI FXStream& operator>>(FXStream& store,FXRanged& bounds);
00170 };
00171
00172
00173 extern FXAPI FXbool overlap(const FXRanged& a,const FXRanged& b);
00174
00175 extern FXAPI FXRanged unite(const FXRanged& a,const FXRanged& b);
00176 extern FXAPI FXRanged intersect(const FXRanged& a,const FXRanged& b);
00177
00178 extern FXAPI FXStream& operator<<(FXStream& store,const FXRanged& bounds);
00179 extern FXAPI FXStream& operator>>(FXStream& store,FXRanged& bounds);
00180
00181 }
00182
00183 #endif
00184