SUMO - Simulation of Urban MObility
Line.h
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef Line_h
23 #define Line_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 "Position.h"
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class PositionVector;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
51 class Line {
52 public:
53  Line();
54  Line(const Position& p1, const Position& p2);
55  ~Line();
57  void extrapolateBy2D(SUMOReal length);
58  void extrapolateFirstBy(SUMOReal length);
59  void extrapolateSecondBy(SUMOReal length);
60  const Position& p1() const;
61  const Position& p2() const;
64  void move2side(SUMOReal amount);
65  std::vector<SUMOReal> intersectsAtLengths2D(const PositionVector& v);
66 
69 
70  SUMOReal atan2Angle() const;
71  SUMOReal atan2DegreeAngle() const;
73  SUMOReal atan2DegreeSlope() const;
74  bool intersects(const Line& l) const;
75  Position intersectsAt(const Line& l) const;
76  SUMOReal length() const;
77  SUMOReal length2D() const;
78  void add(SUMOReal x, SUMOReal y);
79  void add(const Position& p);
80  void sub(SUMOReal x, SUMOReal y);
81  Line& reverse();
82  void rotateAtP1(SUMOReal rot);
83 
85  friend std::ostream& operator<<(std::ostream& os, const Line& geom);
86 
87 private:
89 };
90 
91 
92 #endif
93 
94 /****************************************************************************/
95 
SUMOReal length2D() const
Definition: Line.cpp:186
SUMOReal atan2PositiveAngle() const
Definition: Line.cpp:158
SUMOReal atan2DegreeAngle() const
Definition: Line.cpp:152
const Position & p2() const
Definition: Line.cpp:95
Position myP2
Definition: Line.h:88
SUMOReal intersectsAtLength2D(const Line &v)
returns distance between myP1 and intersection or -1 if line segments do not intersect ...
Definition: Line.cpp:229
SUMOReal atan2DegreeSlope() const
Definition: Line.cpp:168
Position getPositionAtDistance2D(SUMOReal offset) const
Definition: Line.cpp:114
friend std::ostream & operator<<(std::ostream &os, const Line &geom)
Output operator.
Definition: Line.cpp:247
void rotateAtP1(SUMOReal rot)
Definition: Line.cpp:237
void extrapolateFirstBy(SUMOReal length)
Definition: Line.cpp:78
Position getPositionAtDistance(SUMOReal offset) const
Definition: Line.cpp:101
const Position & p1() const
Definition: Line.cpp:89
~Line()
Definition: Line.cpp:56
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
void move2side(SUMOReal amount)
Definition: Line.cpp:127
Definition: Line.h:51
Line & reverse()
Definition: Line.cpp:220
SUMOReal atan2Angle() const
Definition: Line.cpp:146
bool intersects(const Line &l) const
Definition: Line.cpp:180
void extrapolateBy(SUMOReal length)
Definition: Line.cpp:60
void extrapolateSecondBy(SUMOReal length)
Definition: Line.cpp:84
SUMOReal length() const
Definition: Line.cpp:192
void sub(SUMOReal x, SUMOReal y)
Definition: Line.cpp:212
void extrapolateBy2D(SUMOReal length)
Definition: Line.cpp:69
Position myP1
Definition: Line.h:88
Line()
Definition: Line.cpp:49
#define SUMOReal
Definition: config.h:218
std::vector< SUMOReal > intersectsAtLengths2D(const PositionVector &v)
Definition: Line.cpp:135
Position intersectsAt(const Line &l) const
Definition: Line.cpp:174
void add(SUMOReal x, SUMOReal y)
Definition: Line.cpp:198