SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NBHelpers.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// Some mathematical helper methods
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13
// Copyright (C) 2001-2014 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
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <cmath>
35
#include <string>
36
#include <sstream>
37
#include "
NBNode.h
"
38
#include "
NBHelpers.h
"
39
#include <
utils/common/StringTokenizer.h
>
40
#include <
utils/geom/Position.h
>
41
#include <
utils/geom/GeomHelper.h
>
42
#include <iostream>
43
44
#ifdef CHECK_MEMORY_LEAKS
45
#include <
foreign/nvwa/debug_new.h
>
46
#endif // CHECK_MEMORY_LEAKS
47
48
49
// ===========================================================================
50
// method definitions
51
// ===========================================================================
52
SUMOReal
53
NBHelpers::angle
(
SUMOReal
x1,
SUMOReal
y1,
SUMOReal
x2,
SUMOReal
y2) {
54
SUMOReal
angle
=
RAD2DEG
(atan2(x1 - x2, y1 - y2));
55
if
(angle < 0) {
56
angle = 360 +
angle
;
57
}
58
return
angle
;
59
}
60
61
62
SUMOReal
63
NBHelpers::relAngle
(
SUMOReal
angle1,
SUMOReal
angle2) {
64
angle2 -= angle1;
65
if
(angle2 > 180) {
66
angle2 = (360 - angle2) * -1;
67
}
68
while
(angle2 < -180) {
69
angle2 = 360 + angle2;
70
}
71
return
angle2;
72
}
73
74
75
SUMOReal
76
NBHelpers::normRelAngle
(
SUMOReal
angle1,
SUMOReal
angle2) {
77
SUMOReal
rel =
relAngle
(angle1, angle2);
78
if
(rel +
NUMERICAL_EPS
>= 180) {
79
return
-180;
80
}
else
{
81
return
rel;
82
}
83
}
84
85
86
std::string
87
NBHelpers::normalIDRepresentation
(
const
std::string&
id
) {
88
std::stringstream strm1(
id
);
89
long
numid;
90
strm1 >> numid;
91
std::stringstream strm2;
92
strm2 << numid;
93
return
strm2.str();
94
}
95
96
97
SUMOReal
98
NBHelpers::distance
(
NBNode
* node1,
NBNode
* node2) {
99
return
node1->
getPosition
().
distanceTo
(node2->
getPosition
());
100
}
101
102
103
104
/****************************************************************************/
tmp
buildd
sumo-0.21.0+dfsg
src
netbuild
NBHelpers.cpp
Generated on Thu Nov 20 2014 19:49:56 for SUMO - Simulation of Urban MObility by
1.8.1.2