forked from pchalamet/Martinez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
segment.h
41 lines (30 loc) · 1022 Bytes
/
segment.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
40
41
// ------------------------------------------------------------------
// Clase Segment - Segmentos en el plano
// ------------------------------------------------------------------
#ifndef SEGMENT_H
#define SEGMENT_H
#include "point.h"
class Polygon;
class Segment {
public:
/** Segment endpoints */
Point p1, p2;
public:
/** Default constructor */
Segment () {}
~Segment () {}
/** Constructor from two points **/
Segment(const Point& ap1, const Point& ap2) : p1 (ap1), p2 (ap2) {}
/** Set the beginning point */
void setbegin(const Point& p) { p1 = p; }
/** Set the end point */
void setend(const Point& p) { p2 = p; }
/** Get the beginning point */
const Point& begin() const { return p1; }
/** Get the end point */
const Point& end() const { return p2; }
/** Change the segment orientation */
Segment& changeOrientation () { Point tmp = p1; p1 = p2; p2 = tmp; return *this; }
};
inline ostream& operator<< (ostream& o, const Segment& p) { return o << p.begin () << "-" << p.end (); }
#endif