Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef Segment2D_H
00030 #define Segment2D_H
00031
00032 #include "QGpCoreToolsDLLExport.h"
00033 #include "Point2D.h"
00034 #include "Rect.h"
00035
00036 namespace QGpCoreTools {
00037
00038 class QGPCORETOOLS_EXPORT Segment2D
00039 {
00040 public:
00041 Segment2D() {}
00042 Segment2D(const Point2D& p1, const Point2D& p2) {set(p1,p2);}
00043 Segment2D(double x1, double y1, double x2, double y2) {set(x1, y1, x2, y2);}
00044 Segment2D(const Segment2D& o);
00045
00046 bool intersects(const Segment2D& seg, Point2D& p) const;
00047 Segment2D rotated(const Point2D& center, const Angle &a) const;
00048 double distanceTo(const Point2D& p) const;
00049 Point2D p1() const {return _p1;}
00050 Point2D p2() const {return _p2;}
00051 Point2D pointAtFrom1(double distance);
00052 Point2D pointAtFrom2(double distance);
00053 void set(const Point2D& p1, const Point2D& p2);
00054 void set(double x1, double y1, double x2, double y2);
00055 bool includes(const Point2D& p, double precision=1e-10) const;
00056 double length() const {return _p1.distanceTo(_p2);}
00057 protected:
00058 Point2D _p1,_p2;
00059 Rect _limits;
00060 };
00061
00062 }
00063
00064 #endif // SEGMENT2D.H