Changeset 7915 in orxonox.OLD for branches/gui/src/lib
- Timestamp:
- May 28, 2006, 3:36:31 AM (19 years ago)
- Location:
- branches/gui/src/lib/math
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/math/rect2D.cc
r7914 r7915 72 72 } 73 73 74 /** 75 * @brief compares two rectanles. 76 * @param rect the rectangle to compare 77 * @returns true if the two rectangles are the same 78 */ 74 79 bool Rect2D::operator==(const Rect2D& rect) const 75 80 { 76 81 return (this->_topLeft == rect._topLeft && 77 this->_bottomRight == rect._bottomRight); 78 } 79 82 this->_bottomRight == rect._bottomRight); 83 } 84 85 /** 86 * @brief negative compares two rectanles. 87 * @param rect the rectangle to compare 88 * @returns true if the two rectangles are different 89 */ 80 90 bool Rect2D::operator!=(const Rect2D& rect) const 81 91 { 82 92 return (this->_topLeft != rect._topLeft || 83 this->_bottomRight != rect._bottomRight); 84 } 85 86 93 this->_bottomRight != rect._bottomRight); 94 } 95 96 /** 97 * @brief adds two rectangles together 98 * @param rect the rectagle to be added 99 * @returns a Rectangle, where both are added together. 100 * 101 * @note since adding rectangles does not make sense generally, here a description: 102 * adds toplefts and botomrights 103 */ 87 104 Rect2D Rect2D::operator+(const Rect2D& rect) const 88 { 89 return Rect2D(this->_topLeft + rect._topLeft, 90 this->_bottomRight + rect._bottomRight); 91 } 92 93 105 { 106 return Rect2D(this->_topLeft + rect._topLeft, 107 this->_bottomRight + rect._bottomRight); 108 } 109 110 111 /** 112 * @brief adds two rectangles together 113 * @param rect the rectagle to be added to this one 114 * @returns a Rectangle, where both are added together. 115 */ 94 116 Rect2D& Rect2D::operator+=(const Rect2D& rect) 95 117 { … … 100 122 101 123 124 /** 125 * @brief subracts two rectangles from each other 126 * @param rect the rectagle to be substracted from this one 127 * @returns a Rectangle, where both are substracted from one another. 128 */ 102 129 Rect2D Rect2D::operator-(const Rect2D& rect) const 103 130 { … … 106 133 } 107 134 135 /** 136 * @brief subracts two rectangles from each other 137 * @param rect the rectagle to be substracted from this one 138 * @returns a Rectangle, where both are substracted from one another. 139 */ 108 140 Rect2D& Rect2D::operator-=(const Rect2D& rect) 109 141 { … … 113 145 } 114 146 147 /** 148 * @brief intersects two Rectangles. 149 * @see intersection . 150 * @param rect the Rectangle to intersect with this one. 151 * @returns the intersection Region. 152 */ 115 153 Rect2D Rect2D::operator&(const Rect2D& rect) const 116 { 117 return this->intersection(rect); 118 } 119 154 { 155 return this->intersection(rect); 156 } 157 158 /** 159 * @brief intersects two Rectangles and assigns result to this one. 160 * @param rect the Rectangle to intersect with this one. 161 * @returns the intersection Region. 162 */ 120 163 Rect2D& Rect2D::operator&=(const Rect2D& rect) 121 164 { … … 123 166 } 124 167 168 /** 169 * TODO coment/implement 170 */ 125 171 Rect2D Rect2D::operator*(const Vector2D& scaling) const 126 172 { … … 129 175 } 130 176 131 177 /** 178 * @brief sets the width of the Rectangle 179 * @param width the new width of the Rectangle 180 * 181 * the rectangle will be resized from the top left corner out. 182 */ 132 183 void Rect2D::setWidth(float width) 133 184 { … … 136 187 137 188 189 /** 190 * @brief sets the height of the Rectangle 191 * @param height the new height of the Rectangle 192 * 193 * the rectangle will be resized from the top left corner out. 194 */ 138 195 void Rect2D::setHeight(float height) 139 196 { … … 141 198 } 142 199 200 /** 201 * @brief sets the size of the Rectangle 202 * @param width the new width of the Rectangle. 203 * @param height the new height of the Rectangle. 204 * the rectangle will be resized from the top left corner out. 205 */ 143 206 void Rect2D::setSize(float width, float height) 144 207 { … … 146 209 } 147 210 211 212 /** 213 * @brief sets the size of the Rectangle 214 * @param size the new size of the Rectangle. 215 * the rectangle will be resized from the top left corner out. 216 */ 148 217 void Rect2D::setSize(const Vector2D& size) 149 218 { … … 151 220 } 152 221 222 /** 223 * @brief sets the new Center 224 * @param center the center to move the Rectangle to. 225 * moves the Rectangle from its current center to the new Center 226 */ 153 227 void Rect2D::setCenter(const Vector2D& center) 154 228 { … … 156 230 } 157 231 232 /** 233 * @brief scales the Rectangle from topLeft out. 234 * @param x: the scale factor in x direction 235 */ 158 236 void Rect2D::scaleX(float x) 159 237 { … … 161 239 } 162 240 241 /** 242 * @brief scales the Rectangle from topLeft out. 243 * @param y: the scale factor in y direction 244 */ 163 245 void Rect2D::scaleY(float y) 164 246 { … … 166 248 } 167 249 250 /** 251 * @brief scales the Rectangle from topLeft out. 252 * @param x: the scale factor in x direction 253 * @param y: the scale factor in y direction 254 */ 168 255 void Rect2D::scale(float x, float y) 169 256 { … … 171 258 } 172 259 260 /** 261 * @brief scales the Rectangle from topLeft out. 262 * @param v: the scale factors. 263 */ 173 264 void Rect2D::scale(const Vector2D& v) 174 265 { … … 177 268 } 178 269 270 /** 271 * @brief scales the Rectangle from the Center out. 272 * @param x: the scale factor in x-direction. 273 * @param y: the scale factor in y-direction. 274 */ 179 275 void Rect2D::scaleCentered(float x, float y) 180 276 { … … 182 278 } 183 279 280 281 /** 282 * @brief scales the Rectangle from the Center out. 283 * @param v: the scale factors. 284 */ 184 285 void Rect2D::scaleCentered(const Vector2D& v) 185 286 { … … 187 288 } 188 289 290 /** 291 * @brief moves the Rectangle 292 * @param x the amount to move in x. 293 */ 189 294 void Rect2D::moveX(float x) 190 295 { … … 193 298 } 194 299 300 /** 301 * @brief moves the Rectangle 302 * @param y the amount to move in y. 303 */ 195 304 void Rect2D::moveY(float y) 196 305 { … … 198 307 this->_bottomRight.y += y; 199 308 } 309 310 /** 311 * @brief moves the Rectangle 312 * @param x the amount to move in x. 313 * @param y the amount to move in y. 314 */ 315 void Rect2D::move(float x, float y) 316 { 317 this->move(Vector2D(x, y)); 318 } 319 320 /** 321 * @brief moves the Rectangle 322 * @param v the amount to move. 323 */ 200 324 void Rect2D::move(const Vector2D& v) 201 325 { … … 204 328 } 205 329 330 /** 331 * @brief swaps top and bottom. 332 */ 206 333 void Rect2D::swapTopBottom() 207 334 { … … 211 338 } 212 339 340 /** 341 * @brief swaps left and right. 342 */ 213 343 void Rect2D::swapLeftRight() 214 344 { … … 218 348 } 219 349 220 350 /** 351 * @brief normalizes the Rectangle. 352 * 353 * Normalizing a Rectangle means, that the top is above bottom, and left is left of right afterwards :) 354 */ 221 355 void Rect2D::normalize() 222 356 { … … 227 361 } 228 362 363 /** 364 * @brief normalizes the Rectangle. 365 * @returns the normalized version of this rectangle. 366 * 367 * Normalizing a Rectangle means, that the top is above bottom, and left is left of right afterwards :) 368 */ 229 369 Rect2D Rect2D::normalized() const 230 370 { … … 234 374 } 235 375 236 376 /** 377 * @brief The intersection of two Rectangles is calculated and returned. 378 * @param intersector the Rectangle to intersect with this one. 379 * @return the intersection region. 380 */ 237 381 Rect2D Rect2D::intersection(const Rect2D& intersector) const 238 382 { … … 240 384 } 241 385 386 /** 387 * @brief checks if the intersection of two Rectangles is not empty. 388 */ 242 389 bool Rect2D::intersects(const Rect2D& intersector) const 243 390 { 244 391 #warning implement 245 392 246 } 393 } 394 395 /** 396 * @brief make an Extensive join of two rectangles. 397 * @param rect the rectangle to unite with this one. 398 * @returns the united rectangle 399 */ 247 400 Rect2D Rect2D::unite(const Rect2D& rect) 248 401 { 249 402 #warning implement 250 } 403 404 } 405 406 /** 407 * @brief checks if rect is inside of this Rectangle. 408 * @param rect The Rectangle that should be inside of this one. 409 * @returns tru if it is. 410 */ 251 411 bool Rect2D::contains(const Rect2D& rect) const 252 { 253 return (this->top() <= rect.top() && 254 this->bottom() >= rect.bottom() && 255 this->left() <= rect.left() && 256 this->right() >= rect.right()); 257 } 412 { 413 return (this->top() <= rect.top() && 414 this->bottom() >= rect.bottom() && 415 this->left() <= rect.left() && 416 this->right() >= rect.right()); 417 } 418 419 /** 420 * @param point the point to check if it is inside. 421 * @returns true if the point is inside of this Rectangle. 422 */ 258 423 bool Rect2D::contains(const Vector2D& point) const 259 { 260 return (this->top() <= point.y && 261 this->bottom() >= point.y && 262 this->left() <= point.x && 263 this->right() >= point.x); 264 } 265 424 { 425 return (this->top() <= point.y && 426 this->bottom() >= point.y && 427 this->left() <= point.x && 428 this->right() >= point.x); 429 } 430 431 /** 432 * @brief slerps this Rectangle to rect. 433 * @param rect the rectangle to slerp to. 434 * @param value how much to slerp to [0:stay, 1:go there] 435 * @returns reference to this. 436 */ 266 437 const Rect2D& Rect2D::slerp(const Rect2D& rect, float value) 267 438 { -
branches/gui/src/lib/math/rect2D.h
r7914 r7915 102 102 void moveX(float x); 103 103 void moveY(float y); 104 void move(float x, float y); 104 105 void move(const Vector2D& v); 105 106
Note: See TracChangeset
for help on using the changeset viewer.