Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GeomHelper Class Reference

Some static methods performing geometrical operations. More...

#include <GeomHelper.h>

Static Public Member Functions

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, positive anticlockwise The result is between -pi and pi.
 
static double angleDiff (const double angle1, const double angle2)
 Returns the difference of the second angle to the first angle in radiants.
 
static double calculateLotSpaceAngle (const PositionVector &shape, const int index, const double spaceDim, const double angle)
 calculate lotSpace angle
 
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 calculateLotSpaceSlope (const PositionVector &shape, const int index, const double spaceDim)
 calculate lotSpace slope
 
static Position crossPoint (const Boundary &b, const PositionVector &v)
 
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 fromNaviDegree (const double angle)
 
static double getCCWAngleDiff (double angle1, double angle2)
 Returns the distance of second angle from first angle counter-clockwise.
 
static double getCWAngleDiff (double angle1, double angle2)
 Returns the distance of second angle from first angle clockwise.
 
static double getMinAngleDiff (double angle1, double angle2)
 Returns the minimum distance (clockwise/counter-clockwise) between both angles.
 
static double legacyDegree (const double angle, const bool positive=false)
 
static PositionVector makeCircle (const double radius, const Position &center, unsigned int nPoints)
 
static PositionVector makeRing (const double radius1, const double radius2, const Position &center, unsigned int nPoints)
 
static double naviDegree (const double angle)
 
static double nearest_offset_on_line_to_point25D (const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
 
static double nearest_offset_on_line_to_point2D (const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
 

Static Public Attributes

static const double INVALID_OFFSET = -1
 a value to signify offsets outside the range of [0, Line.length()]
 

Detailed Description

Some static methods performing geometrical operations.

Definition at line 46 of file GeomHelper.h.

Member Function Documentation

◆ angle2D()

double GeomHelper::angle2D ( const Position p1,
const Position p2 
)
static

Returns the angle between two vectors on a plane The angle is from vector 1 to vector 2, positive anticlockwise The result is between -pi and pi.

Definition at line 82 of file GeomHelper.cpp.

References angleDiff(), Position::x(), and Position::y().

Referenced by PositionVector::around(), and NGRandomNetBuilder::checkAngles().

Here is the caller graph for this function:

◆ angleDiff()

double GeomHelper::angleDiff ( const double  angle1,
const double  angle2 
)
static

Returns the difference of the second angle to the first angle in radiants.

The results are always between -pi and pi. Positive values denote that the second angle is counter clockwise closer, negative values mean it is clockwise closer.

Parameters
[in]angle1The first angle
[in]angle2The second angle
Returns
angle starting from first to second angle

Definition at line 178 of file GeomHelper.cpp.

References M_PI.

Referenced by MSDevice_ElecHybrid::acceleration(), angle2D(), libsumo::Helper::applySubscriptionFilterFieldOfVision(), NBNodeShapeComputer::badIntersection(), NBNode::bezierControlPoints(), NBEdge::buildInnerEdges(), NBNode::buildWalkingAreas(), NBEdge::checkGeometry(), NBNodeShapeComputer::computeNodeShapeDefault(), MSDevice_ElecHybrid::consumption(), GNENet::createRoundabout(), NBEdge::cutAtIntersection(), NIVissimEdge::dict_checkEdges2Join(), NBNodeShapeComputer::getDefaultRadius(), NBContHelper::edge_opposite_direction_sorter::getDiff(), NBNodeShapeComputer::getSmoothCorner(), MSLane::handleCollisionBetween(), MSLink::isInFront(), MSLink::isOnComingPed(), NIVissimConnectionCluster::isWeakDistrictConnRealisation(), NBNodeShapeComputer::joinSameDirectionEdges(), PositionVector::localAngle(), MSDevice_Battery::notifyMove(), MSLane::incoming_lane_priority_sorter::operator()(), MSLane::by_connections_to_sorter::operator()(), MSLane::outgoing_lane_priority_sorter::operator()(), NIVissimConnectionCluster::same_direction_sorter::operator()(), MSLink::setRequestInformation(), NBRailwayGeometryHelper::straigthenCorrdidor(), and NWWriter_OpenDrive::writeGeomSmooth().

Here is the caller graph for this function:

◆ calculateLotSpaceAngle()

double GeomHelper::calculateLotSpaceAngle ( const PositionVector shape,
const int  index,
const double  spaceDim,
const double  angle 
)
static

calculate lotSpace angle

Definition at line 319 of file GeomHelper.cpp.

References M_PI, PositionVector::positionAtOffset(), Position::x(), and Position::y().

Referenced by MSParkingArea::setRoadsideCapacity(), and GNEParkingArea::updateGeometry().

Here is the caller graph for this function:

◆ calculateLotSpacePosition()

const Position GeomHelper::calculateLotSpacePosition ( const PositionVector shape,
const int  index,
const double  spaceDim,
const double  angle,
const double  width,
const double  length 
)
static

calculate lotSpace position

Definition at line 280 of file GeomHelper.cpp.

References M_PI, PositionVector::positionAtOffset(), Position::setx(), Position::sety(), Position::setz(), Position::x(), Position::y(), and Position::z().

Referenced by MSParkingArea::setRoadsideCapacity(), and GNEParkingArea::updateGeometry().

Here is the caller graph for this function:

◆ calculateLotSpaceSlope()

double GeomHelper::calculateLotSpaceSlope ( const PositionVector shape,
const int  index,
const double  spaceDim 
)
static

calculate lotSpace slope

Definition at line 329 of file GeomHelper.cpp.

References PositionVector::slopeDegreeAtOffset().

Referenced by MSParkingArea::setRoadsideCapacity().

Here is the caller graph for this function:

◆ crossPoint()

Position GeomHelper::crossPoint ( const Boundary b,
const PositionVector v 
)
static

Definition at line 127 of file GeomHelper.cpp.

References PositionVector::intersectionPosition2D(), PositionVector::intersects(), Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), and Boundary::ymin().

Referenced by NIVissimConnectionCluster::getPositionForEdge().

Here is the caller graph for this function:

◆ findLineCircleIntersections()

void GeomHelper::findLineCircleIntersections ( const Position c,
double  radius,
const Position p1,
const Position p2,
std::vector< double > &  into 
)
static

Returns the positions the given circle is crossed by the given line.

Parameters
[in]cThe center position of the circle
[in]radiusThe radius of the circle
[in]p1The begin of the line
[in]p2The end of the line
[filled]into The list of crossing positions (0-1 along the line's length)
See also
http://blog.csharphelper.com/2010/03/28/determine-where-a-line-intersects-a-circle-in-c.aspx
http://gamedev.stackexchange.com/questions/18333/circle-line-collision-detection-problem (jazzdawg)

Definition at line 46 of file GeomHelper.cpp.

References Position::x(), and Position::y().

Referenced by MSDevice_BTreceiver::BTreceiverUpdate::updateVisibility().

Here is the caller graph for this function:

◆ fromNaviDegree()

double GeomHelper::fromNaviDegree ( const double  angle)
static

Converts an angle from navigational degrees to mathematical radians.

See also
naviDegree
Parameters
[in]angleThe angle in degree to convert
Returns
the angle in radians

Definition at line 208 of file GeomHelper.cpp.

References DEG2RAD, and M_PI.

Referenced by MSVehicle::loadState(), MSPModel_Striping::PState::moveToXY(), and MSVehicle::Influencer::postProcessRemoteControl().

Here is the caller graph for this function:

◆ getCCWAngleDiff()

double GeomHelper::getCCWAngleDiff ( double  angle1,
double  angle2 
)
static

Returns the distance of second angle from first angle counter-clockwise.

Parameters
[in]angle1The first angle
[in]angle2The second angle
Returns
Angle (counter-clockwise) starting from first to second angle

Definition at line 152 of file GeomHelper.cpp.

Referenced by NBNode::computeLanes2Lanes(), getMinAngleDiff(), and NBNode::isLeftMover().

Here is the caller graph for this function:

◆ getCWAngleDiff()

double GeomHelper::getCWAngleDiff ( double  angle1,
double  angle2 
)
static

Returns the distance of second angle from first angle clockwise.

Parameters
[in]angle1The first angle
[in]angle2The second angle
Returns
Angle (clockwise) starting from first to second angle

Definition at line 162 of file GeomHelper.cpp.

Referenced by NBNode::computeLanes2Lanes(), getMinAngleDiff(), NBNode::isLeftMover(), and NBNode::rightTurnConflict().

Here is the caller graph for this function:

◆ getMinAngleDiff()

double GeomHelper::getMinAngleDiff ( double  angle1,
double  angle2 
)
static

Returns the minimum distance (clockwise/counter-clockwise) between both angles.

Parameters
[in]angle1The first angle
[in]angle2The second angle
Returns
The minimum distance between both angles

Definition at line 172 of file GeomHelper.cpp.

References getCCWAngleDiff(), getCWAngleDiff(), and MIN2().

Referenced by NBOwnTLDef::getBestCombination(), NBEdgeCont::joinTramEdges(), NBEdgePriorityComputer::markBestParallel(), MSPModel_Striping::PState::moveToXY(), libsumo::Helper::moveToXYMap(), NBEdgePriorityComputer::setPriorityJunctionPriorities(), and MSLink::setRequestInformation().

Here is the caller graph for this function:

◆ legacyDegree()

double GeomHelper::legacyDegree ( const double  angle,
const bool  positive = false 
)
static

Converts an angle from mathematical radians where 0 is to the right and positive angles are counterclockwise to the legacy degrees used in sumo where 0 is down and positive means clockwise. If positive is true the result is in the range [0, 360), otherwise in the range [-180, 180).

Parameters
[in]angleThe angle in radians to convert
Returns
the angle in degrees

Definition at line 214 of file GeomHelper.cpp.

References M_PI, and RAD2DEG.

Referenced by NBEdge::computeAngle(), NBEdge::getAngleAtNode(), NBEdge::getAngleAtNodeNormalized(), NBTurningDirectionsComputer::getFarAngleAtNode(), NBEdge::getShapeEndAngle(), NBEdge::getShapeStartAngle(), NBEdgeCont::joinTramEdges(), NBContHelper::relative_outgoing_edge_sorter::operator()(), NBContHelper::relative_incoming_edge_sorter::operator()(), and PositionVector::rotationDegreeAtOffset().

Here is the caller graph for this function:

◆ makeCircle()

PositionVector GeomHelper::makeCircle ( const double  radius,
const Position center,
unsigned int  nPoints 
)
static

Creates a circular polygon

Parameters
[in]radiusRadius of the circle
[in]centerPosition of the circle's center
[in]nPointsNumber of points of the circle (Polygon's shape will have noPoints+1 points), must be >=3
Returns
the polygon approximating the circle

Definition at line 235 of file GeomHelper.cpp.

References PositionVector::add(), M_PI, TL, and WRITE_ERROR.

◆ makeRing()

PositionVector GeomHelper::makeRing ( const double  radius1,
const double  radius2,
const Position center,
unsigned int  nPoints 
)
static

Creates a circular polygon

Parameters
[in]radius1Inner radius of the ring
[in]radius2Outer radius of the ring
[in]centerPosition of the circle's center
[in]nPointsNumber of points of the circle (Polygon's shape will have noPoints+1 points), must be >=3
Returns
the polygon approximating the circle

Definition at line 252 of file GeomHelper.cpp.

References PositionVector::add(), M_PI, and WRITE_ERROR.

Referenced by LIBSUMO_NAMESPACE::POI::highlight(), and LIBSUMO_NAMESPACE::Vehicle::highlight().

Here is the caller graph for this function:

◆ naviDegree()

double GeomHelper::naviDegree ( const double  angle)
static

◆ nearest_offset_on_line_to_point25D()

double GeomHelper::nearest_offset_on_line_to_point25D ( const Position lineStart,
const Position lineEnd,
const Position p,
bool  perpendicular = true 
)
static

◆ nearest_offset_on_line_to_point2D()

double GeomHelper::nearest_offset_on_line_to_point2D ( const Position lineStart,
const Position lineEnd,
const Position p,
bool  perpendicular = true 
)
static

Field Documentation

◆ INVALID_OFFSET


The documentation for this class was generated from the following files: