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 FXRANGEF_H
00025
#define FXRANGEF_H
00026
00027
00028
namespace FX {
00029
00030
00031
class FXSpheref;
00032
00033
00034
00035 class FXAPI FXRangef {
00036
public:
00037
FXVec3f lower;
00038
FXVec3f upper;
00039
public:
00040
00041
00042 FXRangef(){}
00043
00044
00045 FXRangef(
const FXRangef& bounds):lower(bounds.lower),upper(bounds.upper){}
00046
00047
00048 FXRangef(
const FXVec3f& lo,
const FXVec3f& hi):lower(lo),upper(hi){}
00049
00050
00051 FXRangef(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi):lower(xlo,ylo,zlo),upper(xhi,yhi,zhi){}
00052
00053
00054 FXRangef(
const FXSpheref& sphere);
00055
00056
00057 FXRangef& operator=(
const FXRangef& bounds){ lower=bounds.
lower; upper=bounds.
upper;
return *
this; }
00058
00059
00060 FXVec3f& operator[](FXint i){
return (&lower)[i]; }
00061
00062
00063 const FXVec3f& operator[](FXint i)
const {
return (&lower)[i]; }
00064
00065
00066 FXfloat width()
const {
return upper.x-lower.x; }
00067
00068
00069 FXfloat height()
const {
return upper.y-lower.y; }
00070
00071
00072 FXfloat depth()
const {
return upper.z-lower.z; }
00073
00074
00075 FXfloat longest() const;
00076
00077
00078 FXfloat shortest() const;
00079
00080
00081 FXfloat diameter() const;
00082
00083
00084
FXVec3f diagonal() const;
00085
00086
00087
FXVec3f center() const;
00088
00089
00090 FXbool empty() const;
00091
00092
00093 FXbool contains(FXfloat x,FXfloat y,FXfloat z) const;
00094
00095
00096 FXbool contains(const
FXVec3f& p) const;
00097
00098
00099 FXbool contains(const FXRangef& bounds) const;
00100
00101
00102 FXbool contains(const FXSpheref& sphere) const;
00103
00104
00105 FXRangef& include(FXfloat x,FXfloat y,FXfloat z);
00106
00107
00108 FXRangef& include(const
FXVec3f& v);
00109
00110
00111 FXRangef& include(const FXRangef& box);
00112
00113
00114 FXRangef& include(const FXSpheref& sphere);
00115
00116
00117 FXint intersect(const
FXVec4f& plane) const;
00118
00119
00120 FXbool intersect(const
FXVec3f& u,const
FXVec3f& v);
00121
00122
00123 friend FXAPI FXbool overlap(const FXRangef& a,const FXRangef& b);
00124
00125
00126 FXVec3f corner(FXint c)
const {
return FXVec3f((&lower)[c&1].x,(&lower)[(c>>1)&1].y,(&lower)[c>>2].z); }
00127
00128
00129
friend FXAPI FXRangef unite(
const FXRangef& a,
const FXRangef& b);
00130
00131
00132
friend FXAPI FXRangef intersect(
const FXRangef& a,
const FXRangef& b);
00133
00134
00135
friend FXAPI
FXStream& operator<<(
FXStream& store,
const FXRangef& bounds);
00136
00137
00138
friend FXAPI
FXStream& operator>>(
FXStream& store,FXRangef& bounds);
00139 };
00140
00141 }
00142
00143
#endif
00144