00 /*
01  * point3.cpp
02  *
03  *      Author: Kurt Nørmark / Simonas Saltenis
04  */
05 
06 #include <cmath>
07 #include <iostream>
08 #include "point3.h"
09 
10 double Point::getx () const
11 {
12   return x;
13 }
14 
15 double Point::gety () const
16 {
17   return y;
18 }
19 
20 void Point::move(double dx, double dy)
21 {
22     x += dx; y += dy;
23 }
24 
25 double Point::distance_to(Point p) const
26 {
27     return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
28 }
29 
30 Point Point::operator+(const Point& p)
31 {
32   return Point(x+p.x, y+p.y);
33 }
34 
35 Point Point::operator++(int)   // int means Postfix ++
36 {
37   x++; y++;
38   return *this;
39 }
40 
41 bool Point::operator==(const Point& p)
42 		{
43   return std::abs(p.x - x) <= 3.0 && std::abs(p.y - y) <= 3.0;
44 }
45 
46 std::ostream& operator<<(std::ostream& s, const Point& p)
47 {
48   return s << "(" << p.getx() << "," << p.gety() << ")" ;
49 }
50