00001 /****************************************************************************/ 00007 // 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef Line2D_h 00020 #define Line2D_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include "Position2D.h" 00033 #include <utils/common/VectorHelper.h> 00034 00035 00036 // =========================================================================== 00037 // class declarations 00038 // =========================================================================== 00039 class Position2DVector; 00040 00041 00042 // =========================================================================== 00043 // class definitions 00044 // =========================================================================== 00048 class Line2D { 00049 public: 00050 Line2D(); 00051 Line2D(const Position2D &p1, const Position2D &p2); 00052 ~Line2D(); 00053 void extrapolateBy(SUMOReal length); 00054 void extrapolateFirstBy(SUMOReal length); 00055 void extrapolateSecondBy(SUMOReal length); 00056 const Position2D &p1() const; 00057 const Position2D &p2() const; 00058 Position2D getPositionAtDistance(SUMOReal offset) const; 00059 void move2side(SUMOReal amount); 00060 DoubleVector intersectsAtLengths(const Position2DVector &v); 00061 SUMOReal intersectsAtLength(const Line2D &v); 00062 SUMOReal atan2Angle() const; 00063 SUMOReal atan2DegreeAngle() const; 00064 SUMOReal atan2PositiveAngle() const; 00065 bool intersects(const Line2D &l) const; 00066 Position2D intersectsAt(const Line2D &l) const; 00067 SUMOReal length() const; 00068 void add(SUMOReal x, SUMOReal y); 00069 void add(const Position2D &p); 00070 void sub(SUMOReal x, SUMOReal y); 00071 Line2D &reverse(); 00072 void rotateAtP1(SUMOReal rot); 00073 void rotateAround(const Position2D &at, SUMOReal rot); 00074 00075 private: 00076 Position2D myP1, myP2; 00077 }; 00078 00079 00080 #endif 00081 00082 /****************************************************************************/ 00083
1.5.6