#ifndef __SEGMENT_H__
#define __SEGMENT_H__
#include "Point.h"
class Segment
{
public:
explicit Segment (double x1 = 0, double y1 = 0,
double x2 = 0, double y2 = 0)
: p1 (x1, y1), p2 (x2, y2) {}
explicit Segment (const Point & _p1, const Point & _p2)
: p1 (_p1), p2 (_p2) {}
void draw () const;
bool intersects (const Segment &) const;
bool contains (const Point &) const;
bool operator== (const Segment & s) const;
bool operator!= (const Segment & s) const;
const Point & get_p1 () const
{
return p1;
}
const Point & get_p2 () const
{
return p2;
}
private:
Point p1, p2;
};
#endif;
Return to article