Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 19th, 2010 | Syntax: C++ | Size: 0.78 KB | Hits: 52 | Expires: Never
Copy text to clipboard
  1. /*
  2.  * dim2f.cpp
  3.  *
  4.  *  Created on: Mar 11, 2010
  5.  *      Author: dbaranov
  6.  */
  7.  
  8. #include "square.h"
  9.  
  10. Dim2F::Dim2F() {
  11.         init(0, 0);
  12. }
  13.  
  14. Dim2F::Dim2F(float _x, float _y) {
  15.         init(_x, _y);
  16. }
  17.  
  18. void Dim2F::init(float _x, float _y) {
  19.         x = _x;
  20.         y = _y;
  21. }
  22.  
  23. Dim2F *Dim2F::sum(float _x, float _y) {
  24.         x += _x;
  25.         y += _y;
  26.         return this;
  27. }
  28.  
  29. Dim2F *Dim2F::sum(Dim2F *arg) {
  30.         return sum(arg->x, arg->y);
  31. }
  32.  
  33. Dim2F *Dim2F::set(float _x, float _y) {
  34.         x = _x;
  35.         y = _y;
  36.         return this;
  37. }
  38.  
  39. Dim2F *Dim2F::set(Dim2F *arg) {
  40.         return set(arg->x, arg->y);
  41. }
  42.  
  43. bool Dim2F::isPointInside(float w, float h, float _x, float _y){
  44.         return _x>x && _y>y && _x<x+w && _y<y+h;
  45. }
  46.  
  47. bool Dim2F::isPointInside(Dim2F* area, Dim2F* coord){
  48.         return isPointInside(area->x, area->y, coord->x, coord->y);
  49. }