QGpCoreTools/Segment2D.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2004-05-28
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
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 } // namespace QGpCoreTools
00063 
00064 #endif // SEGMENT2D.H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines