SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeomHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Some geometrical helpers
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef GeomHelper_h
24 #define GeomHelper_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include "Position.h"
37 #include "PositionVector.h"
39 
40 
41 #ifndef PI
42 #define PI 3.1415926535897932384626433832795
43 #endif
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
51 class GeomHelper {
52 public:
56  static bool intersects(const Position& p11, const Position& p12,
57  const Position& p21, const Position& p22);
58 
64  const Position& p11, const Position& p12,
65  const Position& p21, const Position& p22);
66 
67  static SUMOReal Angle2D(SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2);
68 
69  static Position interpolate(const Position& p1,
70  const Position& p2, SUMOReal length);
71 
72  static Position extrapolate_first(const Position& p1,
73  const Position& p2, SUMOReal length);
74 
75  static Position extrapolate_second(const Position& p1,
76  const Position& p2, SUMOReal length);
77 
79  const Position& l1, const Position& l2,
80  const Position& p, bool perpendicular = true);
81 
83  static SUMOReal distancePointLine(const Position& point,
84  const Position& lineStart, const Position& lineEnd);
85 
90  static SUMOReal closestDistancePointLine(const Position& point,
91  const Position& lineStart, const Position& lineEnd,
92  Position& outIntersection);
93 
95  const Position& lineBeg, const Position& lineEnd,
96  SUMOReal amount);
97 
98 
99  static Position crossPoint(const Boundary& b,
100  const PositionVector& v);
101 
102  static std::pair<SUMOReal, SUMOReal> getNormal90D_CW(const Position& beg,
103  const Position& end, SUMOReal length, SUMOReal wanted_offset);
104 
105  static std::pair<SUMOReal, SUMOReal> getNormal90D_CW(const Position& beg,
106  const Position& end, SUMOReal wanted_offset);
107 
113  static SUMOReal getCCWAngleDiff(SUMOReal angle1, SUMOReal angle2);
114 
115 
121  static SUMOReal getCWAngleDiff(SUMOReal angle1, SUMOReal angle2);
122 
123 
129  static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2);
130 
131 
137  static SUMOReal getMaxAngleDiff(SUMOReal angle1, SUMOReal angle2);
138 
139 
140 private:
144  static bool intersects(
145  const SUMOReal x1, const SUMOReal y1, const SUMOReal x2, const SUMOReal y2,
146  const SUMOReal x3, const SUMOReal y3, const SUMOReal x4, const SUMOReal y4,
147  SUMOReal* x, SUMOReal* y, SUMOReal* mu);
148 
149 };
150 
151 
152 #endif
153 
154 /****************************************************************************/