|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 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 Line_h 00020 #define Line_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 "Position.h" 00033 #include <utils/common/VectorHelper.h> 00034 00035 00036 // =========================================================================== 00037 // class declarations 00038 // =========================================================================== 00039 class PositionVector; 00040 00041 00042 // =========================================================================== 00043 // class definitions 00044 // =========================================================================== 00048 class Line { 00049 public: 00050 Line(); 00051 Line(const Position& p1, const Position& p2); 00052 ~Line(); 00053 void extrapolateBy(SUMOReal length); 00054 void extrapolateFirstBy(SUMOReal length); 00055 void extrapolateSecondBy(SUMOReal length); 00056 const Position& p1() const; 00057 const Position& p2() const; 00058 Position getPositionAtDistance(SUMOReal offset) const; 00059 void move2side(SUMOReal amount); 00060 DoubleVector intersectsAtLengths(const PositionVector& v); 00061 SUMOReal intersectsAtLength(const Line& v); 00062 SUMOReal atan2Angle() const; 00063 SUMOReal atan2DegreeAngle() const; 00064 SUMOReal atan2PositiveAngle() const; 00065 bool intersects(const Line& l) const; 00066 Position intersectsAt(const Line& l) const; 00067 SUMOReal length() const; 00068 void add(SUMOReal x, SUMOReal y); 00069 void add(const Position& p); 00070 void sub(SUMOReal x, SUMOReal y); 00071 Line& reverse(); 00072 void rotateAtP1(SUMOReal rot); 00073 void rotateAround(const Position& at, SUMOReal rot); 00074 00075 private: 00076 Position myP1, myP2; 00077 }; 00078 00079 00080 #endif 00081 00082 /****************************************************************************/ 00083