forked from pchalamet/Martinez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoint.h
39 lines (28 loc) · 912 Bytes
/
point.h
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
// ------------------------------------------------------------------
// Clase Point - Punto en el plano
// ------------------------------------------------------------------
#ifndef POINT_H
#define POINT_H
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
class Point {
public:
/** coordinates */
double x, y;
Point (): x(0), y (0) {}
Point (double ax, double ay): x (ax), y (ay) {}
/** Distance to other point */
float dist(const Point& p) const
{
float dx = x - p.x;
float dy = y - p.y;
return sqrt (dx * dx + dy * dy);
}
bool operator== (const Point& p) const { return (x == p.x) && (y == p.y); }
bool operator!= (const Point& p) const { return !(*this == p); }
};
inline ostream& operator<< (ostream& o, const Point& p) { return o << "(" << p.x << "," << p.y << ")"; }
inline istream& operator>> (istream& i, Point& p) { return i >> p.x >> p.y; }
#endif