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 FXEXTENTF_H
00025 #define FXEXTENTF_H
00026
00027
00028 namespace FX {
00029
00030
00032 class FXAPI FXExtentf {
00033 public:
00034 FXVec2f lower;
00035 FXVec2f upper;
00036 public:
00037
00039 FXExtentf(){}
00040
00042 FXExtentf(const FXExtentf& ext):lower(ext.lower),upper(ext.upper){}
00043
00045 FXExtentf(const FXVec2f& lo,const FXVec2f& hi):lower(lo),upper(hi){}
00046
00048 FXExtentf(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi):lower(xlo,ylo),upper(xhi,yhi){}
00049
00051 FXExtentf& operator=(const FXExtentf& ext){ lower=ext.lower; upper=ext.upper; return *this; }
00052
00054 FXVec2f& operator[](FXint i){ return (&lower)[i]; }
00055
00057 const FXVec2f& operator[](FXint i) const { return (&lower)[i]; }
00058
00060 bool operator==(const FXExtentf& ext) const { return lower==ext.lower && upper==ext.upper;}
00061 bool operator!=(const FXExtentf& ext) const { return lower!=ext.lower || upper!=ext.upper;}
00062
00064 FXfloat width() const { return upper.x-lower.x; }
00065
00067 FXfloat height() const { return upper.y-lower.y; }
00068
00070 FXfloat longest() const;
00071
00073 FXfloat shortest() const;
00074
00076 FXfloat diameter() const;
00077
00079 FXfloat radius() const;
00080
00082 FXVec2f diagonal() const;
00083
00085 FXVec2f center() const;
00086
00088 bool empty() const;
00089
00091 bool contains(FXfloat x,FXfloat y) const;
00092
00094 bool contains(const FXVec2f& p) const;
00095
00097 bool contains(const FXExtentf& ext) const;
00098
00100 FXExtentf& include(FXfloat x,FXfloat y);
00101
00103 FXExtentf& include(const FXVec2f& v);
00104
00106 FXExtentf& include(const FXExtentf& ext);
00107
00109 friend FXAPI bool overlap(const FXExtentf& a,const FXExtentf& b);
00110
00112 FXVec2f corner(FXint c) const { return FXVec2f((&lower)[c&1].x, (&lower)[(c>>1)&1].y); }
00113
00115 friend FXAPI FXExtentf unite(const FXExtentf& a,const FXExtentf& b);
00116
00118 friend FXAPI FXExtentf intersect(const FXExtentf& a,const FXExtentf& b);
00119
00121 friend FXAPI FXStream& operator<<(FXStream& store,const FXExtentf& ext);
00122
00124 friend FXAPI FXStream& operator>>(FXStream& store,FXExtentf& ext);
00125 };
00126
00127
00128 extern FXAPI bool overlap(const FXExtentf& a,const FXExtentf& b);
00129
00130 extern FXAPI FXExtentf unite(const FXExtentf& a,const FXExtentf& b);
00131 extern FXAPI FXExtentf intersect(const FXExtentf& a,const FXExtentf& b);
00132
00133 extern FXAPI FXStream& operator<<(FXStream& store,const FXExtentf& ext);
00134 extern FXAPI FXStream& operator>>(FXStream& store,FXExtentf& ext);
00135
00136 }
00137
00138 #endif
00139