SUMO - Simulation of Urban MObility
GeomHelper Class Reference

Some static methods performing geometrical operations. More...

#include <GeomHelper.h>

Collaboration diagram for GeomHelper:
Collaboration graph

Static Public Member Functions

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, positive anticlockwise The result is between -pi and pi. More...
 
static SUMOReal angleDiff (const SUMOReal angle1, const SUMOReal angle2)
 Returns the difference of the second angle to the first angle in radiants. More...
 
static Position crossPoint (const Boundary &b, const PositionVector &v)
 
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. More...
 
static SUMOReal getCCWAngleDiff (SUMOReal angle1, SUMOReal angle2)
 Returns the distance of second angle from first angle counter-clockwise. More...
 
static SUMOReal getCWAngleDiff (SUMOReal angle1, SUMOReal angle2)
 Returns the distance of second angle from first angle clockwise. More...
 
static SUMOReal getMinAngleDiff (SUMOReal angle1, SUMOReal angle2)
 Returns the minimum distance (clockwise/counter-clockwise) between both angles. More...
 
static SUMOReal legacyDegree (const SUMOReal angle, const bool positive=false)
 
static SUMOReal naviDegree (const SUMOReal angle)
 
static SUMOReal nearest_offset_on_line_to_point2D (const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
 

Static Public Attributes

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

Detailed Description

Some static methods performing geometrical operations.

Definition at line 55 of file GeomHelper.h.

Member Function Documentation

SUMOReal 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 94 of file GeomHelper.cpp.

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

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

SUMOReal GeomHelper::angleDiff ( const SUMOReal  angle1,
const SUMOReal  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, and SUMOReal.

Referenced by angle2D(), NBEdge::checkGeometry(), NBNode::computeSmoothShape(), NBEdge::cutAtIntersection(), NIVissimEdge::dict_checkEdges2Join(), NBContHelper::edge_opposite_direction_sorter::getDiff(), MSDevice_Battery::getPropEnergy(), NIVissimConnectionCluster::isWeakDistrictConnRealisation(), NBNodeShapeComputer::joinSameDirectionEdges(), NIVissimConnectionCluster::same_direction_sorter::operator()(), and MSLane::by_connections_to_sorter::operator()().

void GeomHelper::findLineCircleIntersections ( const Position c,
SUMOReal  radius,
const Position p1,
const Position p2,
std::vector< SUMOReal > &  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

Definition at line 58 of file GeomHelper.cpp.

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

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

SUMOReal GeomHelper::getCCWAngleDiff ( SUMOReal  angle1,
SUMOReal  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.

References SUMOReal.

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

SUMOReal GeomHelper::getCWAngleDiff ( SUMOReal  angle1,
SUMOReal  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.

References SUMOReal.

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

SUMOReal GeomHelper::getMinAngleDiff ( SUMOReal  angle1,
SUMOReal  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(), MIN2(), and SUMOReal.

Referenced by NBNodeShapeComputer::compute(), NBOwnTLDef::getBestCombination(), NBContHelper::edge_similar_direction_sorter::operator()(), NBEdgePriorityComputer::setPriorityJunctionPriorities(), and TraCIServerAPI_Vehicle::vtdMap().

SUMOReal GeomHelper::legacyDegree ( const SUMOReal  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 204 of file GeomHelper.cpp.

References M_PI, RAD2DEG, and SUMOReal.

Referenced by NBEdge::computeAngle(), NBEdge::getAngleAtNode(), NBContHelper::relative_outgoing_edge_sorter::operator()(), NBContHelper::relative_incoming_edge_sorter::operator()(), and PositionVector::rotationDegreeAtOffset().

SUMOReal GeomHelper::naviDegree ( const SUMOReal  angle)
static

Converts an angle from mathematical radians where 0 is to the right and positive angles are counterclockwise to navigational degrees where 0 is up and positive means clockwise. The result is always in the range [0, 360).

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

Definition at line 191 of file GeomHelper.cpp.

References M_PI, RAD2DEG, and SUMOReal.

Referenced by GUIPerson::drawAction_drawAsPoly(), GLHelper::drawTriangleAtEnd(), GUIPerson::getNaviDegree(), GUIVehicle::getNaviDegree(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Person::processGet(), GUIContainer::setFunctionalColor(), GNELane::setFunctionalColor(), GUIPerson::setFunctionalColor(), GUILane::setFunctionalColor(), MSEmissionExport::write(), MSFCDExport::write(), MSFCDExport::writeTransportable(), MSXMLRawOut::writeTransportable(), and MSFullExport::writeVehicles().

Field Documentation

const SUMOReal GeomHelper::INVALID_OFFSET = -1
static

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