-
Notifications
You must be signed in to change notification settings - Fork 2
/
Point.cpp
63 lines (53 loc) · 898 Bytes
/
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
56
57
58
59
60
61
62
63
#include "trilaterate.h"
float Point::getX() const
{
return x;
}
float Point::getY() const
{
return y;
}
void Point::setX (float newX)
{
x = newX;
}
void Point::setY (float newY)
{
y = newY;
}
Point::Point (float newX, float newY)
{
this->setX(newX);
this->setY(newY);
}
Point::Point (const Point& other)
{
this->setX(other.getX());
this->setY(other.getY());
}
Point Point::operator+ (const Point& l) const
{
Point n;
n.setX(l.getX()+this->getX());
n.setY(l.getY()+this->getY());
return n;
}
Point Point::operator- (const Point& l) const
{
Point n;
n.setX(this->getX()-l.getX());
n.setY(this->getY()-l.getY());
return n;
}
float Point::operator^ (const Point& l) const
{
float f = (this->getX() * l.getX()) + (this->getY() * l.getY());
return f;
}
Point Point::operator* (const float f) const
{
Point p;
p.setX(f*this->getX());
p.setY(f*this->getY());
return p;
}