-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.cpp
55 lines (54 loc) · 1.24 KB
/
Point.cpp
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
#include "Point.h"
Point::Point(double x, double y)
{
this->x = x;
this->y = y;
}
double Point::GetX()
{
return x;
}
double Point::GetY()
{
return y;
}
void Point::SetX(const double x)
{
this->x = x;
}
void Point::SetY(const double y)
{
this->y = y;
}
bool Point::WithinRectangle(double startX, double startY, double width, double height)
{
if (this->GetX() < startX + width && this->GetX() > startX && this->GetY() > startY && this->GetY() < startY + height)
return true;
else
return false;
}
bool Point::WithinCircle(double startX, double startY, double radius)
{
if (((this->GetX() - startX) * (this->GetX() - startX) + (this->GetY() - startY) * (this->GetY() - startY)) < radius * radius)
return true;
else
return false;
}
double Point::Dist(Point other)
{
double xd = x - other.x;
double yd = y - other.y;
return sqrt(xd * xd + yd * yd);
}
void Point::PrintCirc(ostream& strm)
{
strm << "cx=" << '"' << x << '"' << " " << "cy=" << '"' << y << '"' << " ";
}
void Point::Print(ostream& strm)
{
strm << "x=" << '"' << x << '"' << " " << "y=" << '"' << y << '"' << " ";
}
void Point::Print()
{
cout << x << "," << y;
}