|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // Some geometrical helpers 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef GeomHelper_h 00024 #define GeomHelper_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include "Position.h" 00037 #include "PositionVector.h" 00038 #include <utils/common/UtilExceptions.h> 00039 00040 00041 #ifndef PI 00042 #define PI 3.1415926535897932384626433832795 00043 #endif 00044 00045 // =========================================================================== 00046 // class definitions 00047 // =========================================================================== 00051 class GeomHelper { 00052 public: 00056 static bool intersects( 00057 SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2, 00058 SUMOReal x3, SUMOReal y3, SUMOReal x4, SUMOReal y4); 00059 00063 static bool intersects(const Position& p11, const Position& p12, 00064 const Position& p21, const Position& p22); 00065 00070 static Position intersection_position( 00071 const Position& p11, const Position& p12, 00072 const Position& p21, const Position& p22); 00073 00074 static SUMOReal Angle2D(SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2); 00075 00076 static Position interpolate(const Position& p1, 00077 const Position& p2, SUMOReal length); 00078 00079 static Position extrapolate_first(const Position& p1, 00080 const Position& p2, SUMOReal length); 00081 00082 static Position extrapolate_second(const Position& p1, 00083 const Position& p2, SUMOReal length); 00084 00085 static SUMOReal nearest_position_on_line_to_point2D( 00086 const Position& l1, const Position& l2, 00087 const Position& p, bool perpendicular = true); 00088 00090 static SUMOReal distancePointLine(const Position& point, 00091 const Position& lineStart, const Position& lineEnd); 00092 00097 static SUMOReal closestDistancePointLine(const Position& point, 00098 const Position& lineStart, const Position& lineEnd, 00099 Position& outIntersection); 00100 00101 static Position transfer_to_side(Position& p, 00102 const Position& lineBeg, const Position& lineEnd, 00103 SUMOReal amount); 00104 00105 00106 static Position crossPoint(const Boundary& b, 00107 const PositionVector& v); 00108 00109 static std::pair<SUMOReal, SUMOReal> getNormal90D_CW(const Position& beg, 00110 const Position& end, SUMOReal length, SUMOReal wanted_offset); 00111 00112 static std::pair<SUMOReal, SUMOReal> getNormal90D_CW(const Position& beg, 00113 const Position& end, SUMOReal wanted_offset); 00114 00120 static SUMOReal getCCWAngleDiff(SUMOReal angle1, SUMOReal angle2) ; 00121 00122 00128 static SUMOReal getCWAngleDiff(SUMOReal angle1, SUMOReal angle2) ; 00129 00130 00136 static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2) ; 00137 00138 00144 static SUMOReal getMaxAngleDiff(SUMOReal angle1, SUMOReal angle2) ; 00145 00146 00147 }; 00148 00149 00150 #endif 00151 00152 /****************************************************************************/ 00153