00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXEXTENTF_H
00022 #define FXEXTENTF_H
00023
00024
00025 namespace FX {
00026
00027
00029 class FXAPI FXExtentf {
00030 public:
00031 FXVec2f lower;
00032 FXVec2f upper;
00033 public:
00034
00036 FXExtentf(){}
00037
00039 FXExtentf(const FXExtentf& ext):lower(ext.lower),upper(ext.upper){}
00040
00042 FXExtentf(const FXVec2f& p):lower(p),upper(p){}
00043
00045 FXExtentf(const FXVec2f& lo,const FXVec2f& hi):lower(lo),upper(hi){}
00046
00048 FXExtentf(FXfloat x,FXfloat y):lower(x,y),upper(x,y){}
00049
00051 FXExtentf(FXfloat xl,FXfloat xh,FXfloat yl,FXfloat yh):lower(xl,yl),upper(xh,yh){}
00052
00054 FXExtentf& operator=(const FXExtentf& ext){ lower=ext.lower; upper=ext.upper; return *this; }
00055
00057 FXExtentf& set(const FXExtentf& ext){ lower=ext.lower; upper=ext.upper; return *this; }
00058
00060 FXExtentf& set(const FXVec2f& p){ lower=upper=p; return *this; }
00061
00063 FXExtentf& set(const FXVec2f& lo,const FXVec2f& hi){ lower=lo; upper=hi; return *this; }
00064
00066 FXExtentf& set(FXfloat x,FXfloat y){ lower.x=upper.x=x; lower.y=upper.y=y; return *this; }
00067
00069 FXExtentf& set(FXfloat xl,FXfloat xh,FXfloat yl,FXfloat yh){ lower.set(xl,yl); upper.set(xh,yh); return *this; }
00070
00072 FXVec2f& operator[](FXint i){ return (&lower)[i]; }
00073
00075 const FXVec2f& operator[](FXint i) const { return (&lower)[i]; }
00076
00078 FXbool operator==(const FXExtentf& ext) const { return lower==ext.lower && upper==ext.upper;}
00079 FXbool operator!=(const FXExtentf& ext) const { return lower!=ext.lower || upper!=ext.upper;}
00080
00082 FXfloat width() const { return upper.x-lower.x; }
00083
00085 FXfloat height() const { return upper.y-lower.y; }
00086
00088 FXfloat longest() const;
00089
00091 FXfloat shortest() const;
00092
00094 FXfloat diameter() const;
00095
00097 FXfloat radius() const;
00098
00100 FXVec2f diagonal() const;
00101
00103 FXVec2f center() const;
00104
00106 FXbool empty() const;
00107
00109 FXbool contains(FXfloat x,FXfloat y) const;
00110
00112 FXbool contains(const FXVec2f& p) const;
00113
00115 FXbool contains(const FXExtentf& ext) const;
00116
00118 FXExtentf& include(FXfloat x,FXfloat y);
00119
00121 FXExtentf& include(const FXVec2f& v);
00122
00124 FXExtentf& include(const FXExtentf& ext);
00125
00127 FXVec2f corner(FXint c) const { return FXVec2f((&lower)[c&1].x, (&lower)[(c>>1)&1].y); }
00128
00130 ~FXExtentf(){}
00131 };
00132
00133
00135 extern FXAPI FXbool overlap(const FXExtentf& a,const FXExtentf& b);
00136
00138 extern FXAPI FXExtentf unite(const FXExtentf& a,const FXExtentf& b);
00139
00141 extern FXAPI FXExtentf intersect(const FXExtentf& a,const FXExtentf& b);
00142
00144 extern FXAPI FXStream& operator<<(FXStream& store,const FXExtentf& ext);
00145
00147 extern FXAPI FXStream& operator>>(FXStream& store,FXExtentf& ext);
00148
00149 }
00150
00151 #endif
00152