00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef RECTANGLE_F_H_
00026 #define RECTANGLE_F_H_
00027
00028 namespace Lamp{
00029
00030 class RectangleI;
00031
00032
00033
00034
00035
00036
00037
00038 class RectangleF{
00039 public:
00040
00041
00042
00043
00044 union{
00045
00046 struct{
00047
00048 float x;
00049
00050 float y;
00051
00052 float width;
00053
00054 float height;
00055 };
00056
00057
00058 float array[4];
00059 };
00060
00061
00062
00063
00064
00065 static const RectangleF zero;
00066
00067
00068 static const RectangleF unit;
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 RectangleF(){}
00079
00080
00081
00082
00083
00084
00085
00086
00087 RectangleF(float sourceX, float sourceY,
00088 float sourceWidth, float sourceHeight) :
00089 x(sourceX), y(sourceY), width(sourceWidth), height(sourceHeight){}
00090
00091
00092
00093
00094
00095 explicit RectangleF(float sourceArray[4]) :
00096 x(sourceArray[0]), y(sourceArray[1]),
00097 width(sourceArray[2]), height(sourceArray[3]){}
00098
00099
00100
00101
00102
00103 explicit RectangleF(const RectangleI& source);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 inline void set(float sourceX, float sourceY,
00116 float sourceWidth, float sourceHeight){
00117 x = sourceX;
00118 y = sourceY;
00119 width = sourceWidth;
00120 height = sourceHeight;
00121 }
00122
00123
00124
00125
00126
00127 inline void set(float sourceArray[4]){
00128 x = sourceArray[0];
00129 y = sourceArray[1];
00130 width = sourceArray[2];
00131 height = sourceArray[3];
00132 }
00133
00134
00135
00136
00137
00138 void set(const RectangleI& source);
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 inline bool operator ==(const RectangleF& target) const{
00149 return ((x == target.x) && (y == target.y) &&
00150 (width == target.width) && (height == target.height));
00151 }
00152
00153
00154
00155
00156
00157
00158
00159 inline bool epsilonEquals(const RectangleF& target, float epsilon) const{
00160 Assert(epsilon >= 0.f);
00161 return (
00162 (Math::abs(x - target.x) <= epsilon) &&
00163 (Math::abs(y - target.y) <= epsilon) &&
00164 (Math::abs(width - target.width) <= epsilon) &&
00165 (Math::abs(height - target.height) <= epsilon));
00166 }
00167
00168
00169
00170
00171
00172
00173 inline bool operator !=(const RectangleF& target) const{
00174 return ((x != target.x) || (y != target.y) ||
00175 (width != target.width) || (height != target.height));
00176 }
00177
00178
00179
00180
00181
00182
00183
00184 inline bool notEpsilonEquals(
00185 const RectangleF& target, float epsilon) const{
00186 Assert(epsilon >= 0.f);
00187 return (
00188 (Math::abs(x - target.x) > epsilon) ||
00189 (Math::abs(y - target.y) > epsilon) ||
00190 (Math::abs(width - target.width) > epsilon) ||
00191 (Math::abs(height - target.height) > epsilon));
00192 }
00193
00194
00195
00196
00197
00198
00199
00200
00201 inline String toString() const{
00202 String returnString;
00203 returnString.format("( %.8f, %.8f, %.8f, %.8f )", x, y, width, height);
00204 return returnString;
00205 }
00206
00207 };
00208
00209
00210 }
00211 #endif // End of RECTANGLE_F_H_
00212