-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.cpp
More file actions
34 lines (27 loc) · 767 Bytes
/
Rectangle.cpp
File metadata and controls
34 lines (27 loc) · 767 Bytes
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
#include "Rectangle.h"
#include "Point.h"
Rectangle::Rectangle(): Point(), width(0.0f), height(0.0f) {}
Rectangle::Rectangle(float x, float y, float w, float h): Point(x, y), width(w), height(h) {}
Rectangle::Rectangle(const Rectangle& other) : Point(other.x, other.y), width(other.width), height(other.height) {}
float Rectangle::GetWidth()
{
return width;
}
float Rectangle::GetHeight()
{
return height;
}
bool Rectangle::Intersects(const Rectangle& other) const
{
return (
(y <= other.y && (y + height) >= other.y) || (y >= other.y && y <= (other.y + other.height))
)
&&
(
(x <= other.x && (x + width) >= other.x) || (x >= other.x && x <= (other.x + other.width))
);
}
Rectangle Rectangle::GetRect() const
{
return *this;
}