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