SUMO - Simulation of Urban MObility
Position Class Reference

A point in 2D or 3D with translation and scaling methods. More...

#include <Position.h>

Inheritance diagram for Position:
Inheritance graph
Collaboration diagram for Position:
Collaboration graph

Public Member Functions

void add (const Position &pos)
 Adds the given position to this one. More...
 
void add (double dx, double dy)
 Adds the given position to this one. More...
 
void add (double dx, double dy, double dz)
 Adds the given position to this one. More...
 
bool almostSame (const Position &p2, double maxDiv=POSITION_EPS) const
 checki if two position is almost the sme as other More...
 
double angleTo2D (const Position &other) const
 returns the angle in the plane of the vector pointing from here to the other position More...
 
Position crossProduct (const Position &pos)
 returns the cross product between this point and the second one More...
 
double distanceSquaredTo (const Position &p2) const
 returns the square of the distance to another position More...
 
double distanceSquaredTo2D (const Position &p2) const
 returns the square of the distance to another position (Only using x and y positions) More...
 
double distanceTo (const Position &p2) const
 returns the euclidean distance in 3 dimension More...
 
double distanceTo2D (const Position &p2) const
 returns the euclidean distance in the x-y-plane More...
 
double dotProduct (const Position &pos)
 returns the dot product (scalar product) between this point and the second one More...
 
void mul (double val)
 Multiplies both positions with the given value. More...
 
void mul (double mx, double my)
 Multiplies position with the given values. More...
 
void mul (double mx, double my, double mz)
 Multiplies position with the given values. More...
 
void norm2d ()
 
bool operator!= (const Position &p2) const
 difference operator More...
 
Position operator* (double scalar) const
 keep the direction but modify the length of the (location) vector to length * scalar More...
 
Position operator+ (const Position &p2) const
 add operator More...
 
Position operator+ (double offset) const
 keep the direction but modify the length of the (location) vector to length + scalar More...
 
Position operator- (const Position &p2) const
 sub operator More...
 
bool operator< (const Position &p2) const
 lexicographical sorting for use in maps and sets More...
 
bool operator== (const Position &p2) const
 comparation operator More...
 
 Position ()
 default constructor More...
 
 Position (double x, double y)
 parametrised constructor More...
 
 Position (double x, double y, double z)
 parametrised constructor More...
 
void set (double x, double y)
 set positions x and y More...
 
void set (double x, double y, double z)
 set positions x, y and z More...
 
void set (const Position &pos)
 set position with another position More...
 
void setx (double x)
 set position x More...
 
void sety (double y)
 set position y More...
 
void setz (double z)
 set position z More...
 
void sub (double dx, double dy)
 Substracts the given position from this one. More...
 
void sub (double dx, double dy, double dz)
 Substracts the given position from this one. More...
 
void sub (const Position &pos)
 Substracts the given position from this one. More...
 
double x () const
 Returns the x-position. More...
 
double y () const
 Returns the y-position. More...
 
double z () const
 Returns the z-position. More...
 
 ~Position ()
 Destructor. More...
 

Static Public Attributes

static const Position INVALID
 used to indicate that a position is valid More...
 

Private Attributes

double myX
 The x-position. More...
 
double myY
 The y-position. More...
 
double myZ
 The z-position. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Position &p)
 output operator More...
 

Detailed Description

A point in 2D or 3D with translation and scaling methods.

Definition at line 46 of file Position.h.

Constructor & Destructor Documentation

◆ Position() [1/3]

Position::Position ( )
inline

default constructor

Definition at line 49 of file Position.h.

Referenced by crossProduct(), GUIPointOfInterest::drawGL(), operator*(), operator+(), and operator-().

◆ Position() [2/3]

Position::Position ( double  x,
double  y 
)
inline

parametrised constructor

Definition at line 52 of file Position.h.

◆ Position() [3/3]

Position::Position ( double  x,
double  y,
double  z 
)
inline

parametrised constructor

Definition at line 56 of file Position.h.

◆ ~Position()

Position::~Position ( )
inline

Destructor.

Definition at line 60 of file Position.h.

Member Function Documentation

◆ add() [1/3]

◆ add() [2/3]

void Position::add ( double  dx,
double  dy 
)
inline

Adds the given position to this one.

Definition at line 140 of file Position.h.

References myX, and myY.

◆ add() [3/3]

void Position::add ( double  dx,
double  dy,
double  dz 
)
inline

Adds the given position to this one.

Definition at line 146 of file Position.h.

References myX, myY, and myZ.

◆ almostSame()

bool Position::almostSame ( const Position p2,
double  maxDiv = POSITION_EPS 
) const
inline

checki if two position is almost the sme as other

Definition at line 235 of file Position.h.

References distanceTo().

Referenced by AGPosition::operator==(), PositionVector::push_back_noDoublePos(), and PositionVector::push_front_noDoublePos().

◆ angleTo2D()

◆ crossProduct()

Position Position::crossProduct ( const Position pos)
inline

returns the cross product between this point and the second one

Definition at line 265 of file Position.h.

References myX, myY, myZ, and Position().

Referenced by NBHeightMapper::Triangle::normalVector().

◆ distanceSquaredTo()

double Position::distanceSquaredTo ( const Position p2) const
inline

returns the square of the distance to another position

Definition at line 245 of file Position.h.

References myX, myY, and myZ.

Referenced by distanceTo().

◆ distanceSquaredTo2D()

double Position::distanceSquaredTo2D ( const Position p2) const
inline

returns the square of the distance to another position (Only using x and y positions)

Definition at line 255 of file Position.h.

References myX, and myY.

Referenced by distanceTo2D().

◆ distanceTo()

◆ distanceTo2D()

double Position::distanceTo2D ( const Position p2) const
inline

◆ dotProduct()

double Position::dotProduct ( const Position pos)
inline

returns the dot product (scalar product) between this point and the second one

Definition at line 273 of file Position.h.

References myX, myY, and myZ.

Referenced by NBHeightMapper::Triangle::getZ().

◆ mul() [1/3]

◆ mul() [2/3]

void Position::mul ( double  mx,
double  my 
)
inline

Multiplies position with the given values.

Definition at line 120 of file Position.h.

References myX, and myY.

◆ mul() [3/3]

void Position::mul ( double  mx,
double  my,
double  mz 
)
inline

Multiplies position with the given values.

Definition at line 126 of file Position.h.

References myX, myY, and myZ.

◆ norm2d()

void Position::norm2d ( )
inline

Definition at line 173 of file Position.h.

References myX, and myY.

Referenced by NBNode::getEmptyDir().

◆ operator!=()

bool Position::operator!= ( const Position p2) const
inline

difference operator

Definition at line 219 of file Position.h.

References myX, myY, and myZ.

◆ operator*()

Position Position::operator* ( double  scalar) const
inline

keep the direction but modify the length of the (location) vector to length * scalar

Definition at line 199 of file Position.h.

References myX, myY, myZ, and Position().

◆ operator+() [1/2]

Position Position::operator+ ( const Position p2) const
inline

add operator

Definition at line 189 of file Position.h.

References myX, myY, myZ, and Position().

◆ operator+() [2/2]

Position Position::operator+ ( double  offset) const
inline

keep the direction but modify the length of the (location) vector to length + scalar

Definition at line 204 of file Position.h.

References distanceTo(), myX, myY, myZ, and Position().

◆ operator-()

Position Position::operator- ( const Position p2) const
inline

sub operator

Definition at line 194 of file Position.h.

References myX, myY, myZ, and Position().

◆ operator<()

bool Position::operator< ( const Position p2) const
inline

lexicographical sorting for use in maps and sets

Definition at line 224 of file Position.h.

References myX, myY, and myZ.

◆ operator==()

bool Position::operator== ( const Position p2) const
inline

comparation operator

Definition at line 214 of file Position.h.

References myX, myY, and myZ.

◆ set() [1/3]

◆ set() [2/3]

void Position::set ( double  x,
double  y,
double  z 
)
inline

set positions x, y and z

Definition at line 99 of file Position.h.

References myX, myY, myZ, x(), y(), and z().

◆ set() [3/3]

void Position::set ( const Position pos)
inline

set position with another position

Definition at line 106 of file Position.h.

References myX, myY, and myZ.

◆ setx()

void Position::setx ( double  x)
inline

set position x

Definition at line 78 of file Position.h.

References myX, and x().

Referenced by GNEDetectorE3::setAttribute(), and GUISUMOAbstractView::snapToActiveGrid().

◆ sety()

void Position::sety ( double  y)
inline

set position y

Definition at line 83 of file Position.h.

References myY, and y().

Referenced by GNEDetectorE3::setAttribute(), and GUISUMOAbstractView::snapToActiveGrid().

◆ setz()

void Position::setz ( double  z)
inline

set position z

Definition at line 88 of file Position.h.

References myZ, and z().

Referenced by NBNodeShapeComputer::computeNodeShapeDefault(), and NBEdge::startShapeAt().

◆ sub() [1/3]

void Position::sub ( double  dx,
double  dy 
)
inline

◆ sub() [2/3]

void Position::sub ( double  dx,
double  dy,
double  dz 
)
inline

Substracts the given position from this one.

Definition at line 159 of file Position.h.

References myX, myY, and myZ.

◆ sub() [3/3]

void Position::sub ( const Position pos)
inline

Substracts the given position from this one.

Definition at line 166 of file Position.h.

References myX, myY, and myZ.

◆ x()

double Position::x ( ) const
inline

Returns the x-position.

Definition at line 63 of file Position.h.

References myX.

Referenced by Boundary::add(), PositionVector::add(), NIXMLNodesHandler::addNode(), GeomHelper::angle2D(), GUISettingsHandler::applyViewport(), Boundary::around(), PositionVector::around(), bezier(), NBNode::bezierControlPoints(), NIImporter_OpenDrive::calculateStraightEndPoint(), GeoConvHelper::cartesian2geo(), GUIDanielPerspectiveChanger::centerTo(), NGRandomNetBuilder::checkAngles(), GUISUMOAbstractView::checkGDALImage(), TraCIServerAPI_Simulation::commandPositionConversion(), GNEDetector::commmitAdditionalGeometryMoved(), GNEDetectorE3::commmitAdditionalGeometryMoved(), GNEAdditional::commmitAdditionalGeometryMoved(), NBNodeShapeComputer::computeNodeShapeSmall(), NGRandomNetBuilder::createNewNode(), GNEViewNet::doPaintGL(), GUIVehicle::drawAction_drawRailCarriages(), GNELane::drawArrows(), GUILane::drawArrows(), GLHelper::drawBoxLine(), GLHelper::drawBoxLines(), GUISUMOAbstractView::drawDecals(), GNEDetector::drawDetectorIcon(), GLHelper::drawFilledPoly(), GNEContainerStop::drawGL(), GNEBusStop::drawGL(), GNEJunction::drawGL(), GUITrafficLightLogicWrapper::drawGL(), GUIMEInductLoop::MyWrapper::drawGL(), GUIContainer::drawGL(), GUIInstantInductLoop::MyWrapper::drawGL(), GUILaneSpeedTrigger::drawGL(), GUICalibrator::drawGL(), GUIPointOfInterest::drawGL(), GUIPerson::drawGL(), GNEChargingStation::drawGL(), GNEEdge::drawGL(), GUIChargingStation::drawGL(), GUIContainerStop::drawGL(), GNEPoly::drawGL(), GUIBusStop::drawGL(), GUIParkingArea::drawGL(), GNECalibrator::drawGL(), GUIInductLoop::MyWrapper::drawGL(), GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(), GNELane::drawLane2LaneConnections(), GUILane::drawLane2LaneConnections(), GLHelper::drawLine(), GUIBaseVehicle::drawLinkItem(), GUILane::drawLinkRule(), GNEAdditional::drawLockIcon(), GUIBaseVehicle::drawOnPos(), GUIE3Collector::MyWrapper::drawSingleCrossing(), GLHelper::drawText(), GLHelper::drawTextAtEnd(), GLHelper::drawTextBox(), GLHelper::drawTriangleAtEnd(), MSVTypeProbe::execute(), NBNodeCont::extract(), GeomHelper::findLineCircleIntersections(), GNEDetectorE1::getAttribute(), GNEDetectorEntry::getAttribute(), GNEDetectorExit::getAttribute(), GNEDetectorE2::getAttribute(), GNEDetectorE3::getAttribute(), GNECalibrator::getAttribute(), GUIPointOfInterest::getCenteringBoundary(), NBNode::getEmptyDir(), MSPModel_Striping::getNextLaneObstacles(), PositionVector::getPolygonCenter(), GNEAdditional::getPopUpMenu(), TraCI_POI::getPosition(), GNEDetectorExit::getPositionInView(), GNEDetectorE1::getPositionInView(), GNEDetectorEntry::getPositionInView(), GNEStoppingPlace::getPositionInView(), GNEVaporizer::getPositionInView(), GNEDetectorE2::getPositionInView(), GNERouteProbe::getPositionInView(), GNEDetector::getPositionOverLane(), MSVTKExport::getPositions(), TraCIServerAPI_InductionLoop::getTree(), GUIDanielPerspectiveChanger::getXPos(), NBHeightMapper::getZ(), GNEInternalLane::GNEInternalLane(), GUIBusStop::GUIBusStop(), GUIChargingStation::GUIChargingStation(), GUIContainerStop::GUIContainerStop(), GUIJunctionWrapper::GUIJunctionWrapper(), GUILane::GUILane(), GUIParkingArea::GUIParkingArea(), NBNodeCont::insert(), PositionVector::intersects(), isLeft(), PositionVector::isLeft(), NBHeightMapper::loadTiff(), TraCI::makeTraCIPosition(), GNEDetector::moveAdditionalGeometry(), GNEAdditional::moveAdditionalGeometry(), GNEEdge::moveGeometry(), MSPModel_Striping::moveInDirection(), MSParkingArea::MSParkingArea(), GUISettingsHandler::myStartElement(), GUIMEInductLoop::MyWrapper::MyWrapper(), GUIInstantInductLoop::MyWrapper::MyWrapper(), GUIE2Collector::MyWrapper::MyWrapper(), GUIInductLoop::MyWrapper::MyWrapper(), GeomHelper::nearest_offset_on_line_to_point2D(), GUIGLObjectPopupMenu::onCmdCopyCursorGeoPosition(), GNEViewNet::onMouseMove(), PositionVector::as_poly_cw_sorter::operator()(), PositionVector::increasing_x_y_sorter::operator()(), TraCIServerAPI_Person::processGet(), TraCIServerAPI_GUI::processSet(), NBNodeCont::retrieve(), PCPolyContainer::saveDlrTDP(), set(), GNEAdditional::setBlockIconRotation(), GUIBaseVehicle::setFunctionalColor(), GNEJunction::setPosition(), GUIDialog_EditViewport::setValues(), GUICompleteSchemeStorage::setViewport(), GUISUMOAbstractView::setViewportFromTo(), setx(), NGNode::setY(), PositionVector::sideOffset(), PositionVector::simplified(), GUISUMOAbstractView::snapToActiveGrid(), NBNetBuilder::transformCoordinate(), GNEConnection::updateGeometry(), GNECrossing::updateGeometry(), GNEDetectorE1::updateGeometry(), GNEChargingStation::updateGeometry(), GNEDetectorE2::updateGeometry(), GNEBusStop::updateGeometry(), GNEContainerStop::updateGeometry(), GNECalibrator::updateGeometry(), GNELane::updateGeometry(), GNEJunction::updateGeometry(), GNEDetectorEntry::updateGeometryByParent(), GNEDetectorExit::updateGeometryByParent(), GNEDetectorE3::updateGeometryConnections(), GUISUMOAbstractView::updatePositionInformation(), MSBatteryExport::write(), MSEmissionExport::write(), MSFCDExport::write(), GNEDetectorE1::writeAdditional(), GNEDetectorE2::writeAdditional(), GNEVariableSpeedSign::writeAdditional(), GNERerouter::writeAdditional(), GNEDetectorE3::writeAdditional(), GNECalibrator::writeAdditional(), NBSign::writeAsPOI(), NWWriter_OpenDrive::writeGeomLines(), NWWriter_OpenDrive::writeGeomPP3(), NWWriter_DlrNavteq::writeNodesUnsplitted(), BinaryFormatter::writePosition(), NWFrame::writePositionLong(), NWWriter_DlrNavteq::writeTrafficSignals(), MSFCDExport::writeTransportable(), MSFullExport::writeVehicles(), PointOfInterest::writeXML(), GeoConvHelper::x2cartesian(), GeoConvHelper::x2cartesian_const(), and GUIDanielPerspectiveChanger::zoom().

◆ y()

double Position::y ( ) const
inline

Returns the y-position.

Definition at line 68 of file Position.h.

References myY.

Referenced by Boundary::add(), PositionVector::add(), NIXMLNodesHandler::addNode(), GeomHelper::angle2D(), GUISettingsHandler::applyViewport(), Boundary::around(), PositionVector::around(), bezier(), NBNode::bezierControlPoints(), NIImporter_OpenDrive::calculateStraightEndPoint(), GeoConvHelper::cartesian2geo(), GUIDanielPerspectiveChanger::centerTo(), NGRandomNetBuilder::checkAngles(), GUISUMOAbstractView::checkGDALImage(), TraCIServerAPI_Simulation::commandPositionConversion(), GNEDetectorE3::commmitAdditionalGeometryMoved(), GNEAdditional::commmitAdditionalGeometryMoved(), NBNodeShapeComputer::computeNodeShapeSmall(), NGRandomNetBuilder::createNewNode(), GNEViewNet::doPaintGL(), GUIVehicle::drawAction_drawRailCarriages(), GNELane::drawArrows(), GUILane::drawArrows(), GLHelper::drawBoxLine(), GLHelper::drawBoxLines(), GUISUMOAbstractView::drawDecals(), GNEDetector::drawDetectorIcon(), GLHelper::drawFilledPoly(), GNEBusStop::drawGL(), GNEContainerStop::drawGL(), GUITrafficLightLogicWrapper::drawGL(), GNEJunction::drawGL(), GUIMEInductLoop::MyWrapper::drawGL(), GUIContainer::drawGL(), GUIInstantInductLoop::MyWrapper::drawGL(), GUILaneSpeedTrigger::drawGL(), GUICalibrator::drawGL(), GUIPointOfInterest::drawGL(), GUIPerson::drawGL(), GNEChargingStation::drawGL(), GNEEdge::drawGL(), GUIChargingStation::drawGL(), GUIContainerStop::drawGL(), GNEPoly::drawGL(), GUIBusStop::drawGL(), GUIParkingArea::drawGL(), GNECalibrator::drawGL(), GUIInductLoop::MyWrapper::drawGL(), GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(), GNELane::drawLane2LaneConnections(), GUILane::drawLane2LaneConnections(), GLHelper::drawLine(), GUIBaseVehicle::drawLinkItem(), GUILane::drawLinkRule(), GNEAdditional::drawLockIcon(), GUIBaseVehicle::drawOnPos(), GUIE3Collector::MyWrapper::drawSingleCrossing(), GLHelper::drawText(), GLHelper::drawTextAtEnd(), GLHelper::drawTextBox(), GLHelper::drawTriangleAtEnd(), MSVTypeProbe::execute(), NBNodeCont::extract(), GeomHelper::findLineCircleIntersections(), GNEDetectorE3::getAttribute(), GUIPointOfInterest::getCenteringBoundary(), NBNode::getEmptyDir(), MSPModel_Striping::getNextLaneObstacles(), GNEAdditional::getPopUpMenu(), TraCI_POI::getPosition(), GNEVaporizer::getPositionInView(), GNERouteProbe::getPositionInView(), MSVTKExport::getPositions(), TraCIServerAPI_InductionLoop::getTree(), GUIDanielPerspectiveChanger::getYPos(), NBHeightMapper::getZ(), GNEInternalLane::GNEInternalLane(), GUIBusStop::GUIBusStop(), GUIChargingStation::GUIChargingStation(), GUIContainerStop::GUIContainerStop(), GUIJunctionWrapper::GUIJunctionWrapper(), GUILane::GUILane(), GUIParkingArea::GUIParkingArea(), NBNodeCont::insert(), PositionVector::intersects(), isLeft(), PositionVector::isLeft(), NBHeightMapper::loadTiff(), TraCI::makeTraCIPosition(), GNEAdditional::moveAdditionalGeometry(), GNEEdge::moveGeometry(), MSPModel_Striping::moveInDirection(), MSParkingArea::MSParkingArea(), GUISettingsHandler::myStartElement(), GUIMEInductLoop::MyWrapper::MyWrapper(), GUIInstantInductLoop::MyWrapper::MyWrapper(), GUIE2Collector::MyWrapper::MyWrapper(), GUIInductLoop::MyWrapper::MyWrapper(), GeomHelper::nearest_offset_on_line_to_point2D(), GUIGLObjectPopupMenu::onCmdCopyCursorGeoPosition(), PositionVector::as_poly_cw_sorter::operator()(), PositionVector::increasing_x_y_sorter::operator()(), TraCIServerAPI_Person::processGet(), TraCIServerAPI_GUI::processSet(), NBNodeCont::retrieve(), PCPolyContainer::saveDlrTDP(), set(), GUIBaseVehicle::setFunctionalColor(), GNEJunction::setPosition(), GUIDialog_EditViewport::setValues(), GUICompleteSchemeStorage::setViewport(), GUISUMOAbstractView::setViewportFromTo(), NGNode::setX(), sety(), PositionVector::sideOffset(), PositionVector::simplified(), GUISUMOAbstractView::snapToActiveGrid(), NBNetBuilder::transformCoordinate(), GNEConnection::updateGeometry(), GNECrossing::updateGeometry(), GNEChargingStation::updateGeometry(), GNEDetectorE2::updateGeometry(), GNEBusStop::updateGeometry(), GNEContainerStop::updateGeometry(), GNELane::updateGeometry(), GNEJunction::updateGeometry(), GNEDetectorE3::updateGeometryConnections(), GUISUMOAbstractView::updatePositionInformation(), MSBatteryExport::write(), MSEmissionExport::write(), MSFCDExport::write(), GNEVariableSpeedSign::writeAdditional(), GNERerouter::writeAdditional(), GNEDetectorE3::writeAdditional(), NBSign::writeAsPOI(), NWWriter_OpenDrive::writeGeomLines(), NWWriter_OpenDrive::writeGeomPP3(), NWWriter_DlrNavteq::writeNodesUnsplitted(), BinaryFormatter::writePosition(), NWFrame::writePositionLong(), NWWriter_DlrNavteq::writeTrafficSignals(), MSFCDExport::writeTransportable(), MSFullExport::writeVehicles(), PointOfInterest::writeXML(), GeoConvHelper::x2cartesian(), GeoConvHelper::x2cartesian_const(), and GUIDanielPerspectiveChanger::zoom().

◆ z()

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Position p 
)
friend

output operator

Definition at line 180 of file Position.h.

Field Documentation

◆ INVALID

◆ myX

double Position::myX
private

◆ myY

double Position::myY
private

◆ myZ

double Position::myZ
private

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