Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GeomHelper.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// Some static methods performing geometrical operations
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <cmath>
27#include "Position.h"
28#include "PositionVector.h"
30
31#ifndef M_PI
32#define M_PI 3.1415926535897932384626433832795
33#endif
34
35#define DEG2RAD(x) static_cast<double>((x) * M_PI / 180.)
36#define RAD2DEG(x) static_cast<double>((x) * 180. / M_PI)
37#define GRAVITY 9.80665
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
47
48public:
50 static const double INVALID_OFFSET;
51
61 static void findLineCircleIntersections(const Position& c, double radius, const Position& p1, const Position& p2,
62 std::vector<double>& into);
63
64
69 static double angle2D(const Position& p1, const Position& p2);
70
72 const Position& lineStart, const Position& lineEnd,
73 const Position& p, bool perpendicular = true);
74
76 const Position& lineStart, const Position& lineEnd,
77 const Position& p, bool perpendicular = true);
78
79 static Position crossPoint(const Boundary& b,
80 const PositionVector& v);
81
87 static double getCCWAngleDiff(double angle1, double angle2);
88
89
95 static double getCWAngleDiff(double angle1, double angle2);
96
97
103 static double getMinAngleDiff(double angle1, double angle2);
104
105
115 static double angleDiff(const double angle1, const double angle2);
116
117
124 static double naviDegree(const double angle);
125
131 static double fromNaviDegree(const double angle);
132
139 static double legacyDegree(const double angle, const bool positive = false);
140
147 static PositionVector makeCircle(const double radius, const Position& center, unsigned int nPoints);
148
156 static PositionVector makeRing(const double radius1, const double radius2, const Position& center, unsigned int nPoints);
157
159 static const Position calculateLotSpacePosition(const PositionVector& shape, const int index,
160 const double spaceDim, const double angle, const double width, const double length);
161
163 static double calculateLotSpaceAngle(const PositionVector& shape, const int index, const double spaceDim, const double angle);
164
166 static double calculateLotSpaceSlope(const PositionVector& shape, const int index, const double spaceDim);
167};
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
Some static methods performing geometrical operations.
Definition GeomHelper.h:46
static double getCCWAngleDiff(double angle1, double angle2)
Returns the distance of second angle from first angle counter-clockwise.
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.
static double nearest_offset_on_line_to_point25D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
static const Position calculateLotSpacePosition(const PositionVector &shape, const int index, const double spaceDim, const double angle, const double width, const double length)
calculate lotSpace position
static double calculateLotSpaceAngle(const PositionVector &shape, const int index, const double spaceDim, const double angle)
calculate lotSpace angle
static Position crossPoint(const Boundary &b, const PositionVector &v)
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,...
static PositionVector makeRing(const double radius1, const double radius2, const Position &center, unsigned int nPoints)
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition GeomHelper.h:50
static double getCWAngleDiff(double angle1, double angle2)
Returns the distance of second angle from first angle clockwise.
static double calculateLotSpaceSlope(const PositionVector &shape, const int index, const double spaceDim)
calculate lotSpace slope
static double nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
static PositionVector makeCircle(const double radius, const Position &center, unsigned int nPoints)
static double naviDegree(const double angle)
static double fromNaviDegree(const double angle)
static double legacyDegree(const double angle, const bool positive=false)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.