blob: bcec7c14ad3316b197b2f4337de818ea35c9afe0 (
plain)
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
|
/***************************************************************************
* Developer: Francisco Martínez del Río (2011) *
* fmartin@ujaen.es *
* Version: 1.4.1 *
* *
* This is a public domain program *
***************************************************************************/
// ------------------------------------------------------------------
// 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
|