43 #ifdef CHECK_MEMORY_LEAKS 45 #endif // CHECK_MEMORY_LEAKS 59 std::vector<SUMOReal>& into) {
63 const SUMOReal A = dx * dx + dy * dy;
64 const SUMOReal B = 2 * (dx * (p1.
x() - c.
x()) + dy * (p1.
y() - c.
y()));
65 const SUMOReal C = (p1.
x() - c.
x()) * (p1.
x() - c.
x()) + (p1.
y() - c.
y()) * (p1.
y() - c.
y()) - radius * radius;
67 const SUMOReal det = B * B - 4 * A * C;
68 if ((A <= 0.0000001) || (det < 0)) {
75 if (t >= 0. && t <= 1.) {
81 Position intersection(p1.
x() + t * dx, p1.
y() + t * dy);
82 if (t >= 0. && t <= 1.) {
86 if (t2 >= 0. && t2 <= 1.) {
95 return angleDiff(atan2(p1.
y(), p1.
x()), atan2(p2.
y(), p2.
x()));
102 const Position& p,
bool perpendicular) {
104 if (lineLength2D == 0.0f) {
109 const SUMOReal u = (((p.
x() - lineStart.
x()) * (lineEnd.
x() - lineStart.
x())) +
110 ((p.
y() - lineStart.
y()) * (lineEnd.
y() - lineStart.
y()))
111 ) / (lineLength2D * lineLength2D);
112 if (u < 0.0f || u > 1.0f) {
121 return u * lineLength2D;
193 while (degree >= 360.) {
196 while (degree < 0.) {
207 while (degree >= 360.) {
210 while (degree < 0.) {
214 while (degree >= 180.) {
217 while (degree < -180.) {
static SUMOReal 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...
static SUMOReal getCWAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the distance of second angle from first angle clockwise.
static SUMOReal getCCWAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the distance of second angle from first angle counter-clockwise.
SUMOReal ymin() const
Returns minimum y-coordinate.
SUMOReal xmin() const
Returns minimum x-coordinate.
bool intersects(const Position &p1, const Position &p2) const
static Position crossPoint(const Boundary &b, const PositionVector &v)
static SUMOReal angleDiff(const SUMOReal angle1, const SUMOReal angle2)
Returns the difference of the second angle to the first angle in radiants.
SUMOReal x() const
Returns the x-position.
SUMOReal xmax() const
Returns maximum x-coordinate.
A class that stores a 2D geometrical boundary.
static SUMOReal legacyDegree(const SUMOReal angle, const bool positive=false)
A point in 2D or 3D with translation and scaling methods.
static void findLineCircleIntersections(const Position &c, SUMOReal radius, const Position &p1, const Position &p2, std::vector< SUMOReal > &into)
Returns the positions the given circle is crossed by the given line.
static SUMOReal naviDegree(const SUMOReal angle)
SUMOReal y() const
Returns the y-position.
static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
static SUMOReal nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
Position intersectionPosition2D(const Position &p1, const Position &p2, const SUMOReal withinDist=0.) const
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
SUMOReal ymax() const
Returns maximum y-coordinate.
static const SUMOReal INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]