diff options
author | Rafael Laboissière <rafael@debian.org> | 2020-02-09 05:51:46 -0300 |
---|---|---|
committer | Rafael Laboissière <rafael@debian.org> | 2020-02-09 05:51:46 -0300 |
commit | a45e15f167ef0a7cba3e9ed572209f3522658320 (patch) | |
tree | 481982ed20977db86d2e3309ee5e709da54e2b79 /src/segment.h | |
parent | 87f1c69f10eb490ae5bdfbd551ba386b58e199e3 (diff) |
New upstream version 4.0.0
Diffstat (limited to 'src/segment.h')
-rw-r--r-- | src/segment.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/segment.h b/src/segment.h new file mode 100644 index 0000000..6cf5cd3 --- /dev/null +++ b/src/segment.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * Developer: Francisco Martínez del Río (2011) * + * fmartin@ujaen.es * + * Version: 1.4.1 * + * * + * This is a public domain program * + ***************************************************************************/ + +// ------------------------------------------------------------------ +// 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 |