SUMO - Simulation of Urban MObility
GeomHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // Some static methods performing geometrical operations
21 /****************************************************************************/
22 #ifndef GeomHelper_h
23 #define GeomHelper_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <cmath>
36 #include "Position.h"
37 #include "PositionVector.h"
39 
40 #ifndef M_PI
41 #define M_PI 3.1415926535897932384626433832795
42 #endif
43 
44 #define DEG2RAD(x) static_cast<double>((x) * M_PI / 180.)
45 #define RAD2DEG(x) static_cast<double>((x) * 180. / M_PI)
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
54 class GeomHelper {
55 
56 public:
58  static const double INVALID_OFFSET;
59 
69  static void findLineCircleIntersections(const Position& c, double radius, const Position& p1, const Position& p2,
70  std::vector<double>& into);
71 
72 
77  static double angle2D(const Position& p1, const Position& p2);
78 
80  const Position& lineStart, const Position& lineEnd,
81  const Position& p, bool perpendicular = true);
82 
83  static Position crossPoint(const Boundary& b,
84  const PositionVector& v);
85 
91  static double getCCWAngleDiff(double angle1, double angle2);
92 
93 
99  static double getCWAngleDiff(double angle1, double angle2);
100 
101 
107  static double getMinAngleDiff(double angle1, double angle2);
108 
109 
119  static double angleDiff(const double angle1, const double angle2);
120 
121 
128  static double naviDegree(const double angle);
129 
135  static double fromNaviDegree(const double angle);
136 
143  static double legacyDegree(const double angle, const bool positive = false);
144 
145 };
146 
147 
148 #endif
149 
150 /****************************************************************************/
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
Definition: GeomHelper.cpp:167
static double getCCWAngleDiff(double angle1, double angle2)
Returns the distance of second angle from first angle counter-clockwise.
Definition: GeomHelper.cpp:147
static Position crossPoint(const Boundary &b, const PositionVector &v)
Definition: GeomHelper.cpp:122
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
static double legacyDegree(const double angle, const bool positive=false)
Definition: GeomHelper.cpp:205
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:186
static double nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
Definition: GeomHelper.cpp:95
Some static methods performing geometrical operations.
Definition: GeomHelper.h:54
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
static double getCWAngleDiff(double angle1, double angle2)
Returns the distance of second angle from first angle clockwise.
Definition: GeomHelper.cpp:157
static double angle2D(const Position &p1, const Position &p2)
Returns the angle between two vectors on a plane The angle is from vector 1 to vector 2...
Definition: GeomHelper.cpp:89
static double fromNaviDegree(const double angle)
Definition: GeomHelper.cpp:199
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:58
static void findLineCircleIntersections(const Position &c, double radius, const Position &p1, const Position &p2, std::vector< double > &into)
Returns the positions the given circle is crossed by the given line.
Definition: GeomHelper.cpp:53
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
Definition: GeomHelper.cpp:173