-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRect2D.h
More file actions
106 lines (89 loc) · 1.93 KB
/
Rect2D.h
File metadata and controls
106 lines (89 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef _RECT2D_H
#define _RECT2D_H
#ifndef _VECTOR2D_H
#include "Vector2D.h"
#endif
//------------------------------------------------------------------------------
// Rect2D Struct
//------------------------------------------------------------------------------
struct Rect2D
{
public:
Rect2D()
: left(0)
, top(0)
, right(0)
, bottom(0)
{
width = right - left;
height = bottom - top;
}
Rect2D(const Rect2D& r)
: left(r.left)
, top(r.top)
, right(r.right)
, bottom(r.bottom)
{
width = r.width;
height = r.height;
}
Rect2D(double l, double t, double r, double b)
: left(l)
, top(t)
, right(r)
, bottom(b)
{
width = right - left;
height = bottom - top;
}
Rect2D(const Vector2D& v1, const Vector2D& v2)
: top(v1.y)
, left(v1.x)
, bottom(v2.y)
, right(v2.x)
{
width = right - left;
height = bottom - top;
}
~Rect2D()
{}
double top;
double left;
double bottom;
double right;
double width;
double height;
static const Rect2D empty;
Rect2D operator= (const Rect2D other)
{
Rect2D r;
r.left = other.left;
r.right = other.right;
r.bottom = other.bottom;
r.top = other.top;
r.width = other.width;
r.height = other.height;
return r;
}
bool operator== (const Rect2D& other)
{
if (this->left == other.left && this->right == other.right && this->top == other.top && this->bottom == other.bottom)
return true;
return false;
}
bool IsEqual(Rect2D& other)
{
if (this->left == other.left && this->right == other.right && this->top == other.top && this->bottom == other.bottom)
return true;
return false;
}
};
inline bool operator== (const Rect2D r1, const Rect2D& r2)
{
return (r1.left == r2.left && r1.right == r2.right && r1.top == r2.top && r1.bottom == r2.bottom);
}
inline bool operator!= (const Rect2D r1, const Rect2D& r2)
{
return !(r1 == r2);
}
#endif