Position2D Class Reference

#include <Position2D.h>

Inheritance diagram for Position2D:

PointOfInterest GUIPointOfInterest

Detailed Description

A point in 2D with translation and scaling methods.

Definition at line 42 of file Position2D.h.


Public Member Functions

void add (SUMOReal dx, SUMOReal dy)
 Adds the given position to this one.
void add (const Position2D &pos)
 Adds the given position to this one.
bool almostSame (const Position2D &p2, SUMOReal maxDiv=POSITION_EPS) const
SUMOReal distanceSquaredTo (const Position2D &p2) const
SUMOReal distanceTo (const Position2D &p2) const
void mul (SUMOReal mx, SUMOReal my)
 Multiplies position with the given values.
void mul (SUMOReal val)
 Multiplies both positions with the given value.
void norm ()
bool operator!= (const Position2D &p2) const
bool operator== (const Position2D &p2) const
 Position2D (SUMOReal x, SUMOReal y)
 parametrised constructor
 Position2D ()
 default constructor
void reshiftRotate (SUMOReal xoff, SUMOReal yoff, SUMOReal rot)
void set (const Position2D &pos)
void set (SUMOReal x, SUMOReal y)
void sub (const Position2D &pos)
 Substracts the given position from this one.
void sub (SUMOReal dx, SUMOReal dy)
 Substracts the given position from this one.
SUMOReal x () const
 Returns the x-position.
SUMOReal y () const
 Returns the y-position.
 ~Position2D ()
 Destructor.

Private Attributes

SUMOReal myX
 The x-position.
SUMOReal myY
 The y-position.

Friends

std::ostream & operator<< (std::ostream &os, const Position2D &p)
 Prints to the output.

Constructor & Destructor Documentation

Position2D::Position2D (  )  [inline]

default constructor

Definition at line 45 of file Position2D.h.

00045 : myX(0.0), myY(0.0) { }

Position2D::Position2D ( SUMOReal  x,
SUMOReal  y 
) [inline]

parametrised constructor

Definition at line 48 of file Position2D.h.

00049             : myX(x), myY(y) { }

Position2D::~Position2D (  )  [inline]

Destructor.

Definition at line 52 of file Position2D.h.

00052 { }


Member Function Documentation

void Position2D::add ( SUMOReal  dx,
SUMOReal  dy 
) [inline]

Adds the given position to this one.

Definition at line 96 of file Position2D.h.

References myX, and myY.

00096                                        {
00097         myX += dx;
00098         myY += dy;
00099     }

void Position2D::add ( const Position2D pos  )  [inline]

bool Position2D::almostSame ( const Position2D p2,
SUMOReal  maxDiv = POSITION_EPS 
) const [inline]

Definition at line 142 of file Position2D.h.

References myX, and myY.

Referenced by NBNode::computeInternalLaneShape(), Position2DVector::push_back_noDoublePos(), and Position2DVector::push_front_noDoublePos().

00142                                                                               {
00143         return fabs(myX-p2.myX)<maxDiv && fabs(myY-p2.myY)<maxDiv;
00144     }

SUMOReal Position2D::distanceSquaredTo ( const Position2D p2  )  const [inline]

Definition at line 152 of file Position2D.h.

References myX, and myY.

Referenced by GeomHelper::distancePointLine(), distanceTo(), and GeomHelper::nearest_position_on_line_to_point().

00152                                                                   {
00153         return (myX-p2.myX)*(myX-p2.myX) + (myY-p2.myY)*(myY-p2.myY);
00154     }

SUMOReal Position2D::distanceTo ( const Position2D p2  )  const [inline]

void Position2D::mul ( SUMOReal  mx,
SUMOReal  my 
) [inline]

Multiplies position with the given values.

Definition at line 84 of file Position2D.h.

References myX, and myY.

00084                                        {
00085         myX *= mx;
00086         myY *= my;
00087     }

void Position2D::mul ( SUMOReal  val  )  [inline]

Multiplies both positions with the given value.

Definition at line 78 of file Position2D.h.

References myX, and myY.

Referenced by GUIDanielPerspectiveChanger::centerTo(), NBNodeShapeComputer::computeContinuationNodeShape(), Position2DVector::distancesExt(), GUIEdge::drawGL(), NBNode::getEmptyDir(), and NIXMLNodesHandler::myStartElement().

00078                            {
00079         myX *= val;
00080         myY *= val;
00081     }

void Position2D::norm (  )  [inline]

Definition at line 113 of file Position2D.h.

References myX, myY, and SUMOReal.

Referenced by NBNode::getEmptyDir().

00113                 {
00114         SUMOReal val = sqrt(myX*myX + myY*myY);
00115         myX = myX / val;
00116         myY = myY / val;
00117     }

bool Position2D::operator!= ( const Position2D p2  )  const [inline]

Definition at line 137 of file Position2D.h.

References myX, and myY.

00137                                                 {
00138         return myX!=p2.myX || myY!=p2.myY;
00139     }

bool Position2D::operator== ( const Position2D p2  )  const [inline]

Definition at line 133 of file Position2D.h.

References myX, and myY.

00133                                                 {
00134         return myX==p2.myX && myY==p2.myY;
00135     }

void Position2D::reshiftRotate ( SUMOReal  xoff,
SUMOReal  yoff,
SUMOReal  rot 
) [inline]

Definition at line 119 of file Position2D.h.

References myX, myY, SUMOReal, x(), and y().

Referenced by NBNode::reshiftPosition(), and Line2D::rotateAtP1().

00119                                                                    {
00120         SUMOReal x = myX * cos(rot) -myY * sin(rot) + xoff;
00121         SUMOReal y = myX * sin(rot) + yoff + myY * cos(rot);
00122         myX = x;
00123         myY = y;
00124     }

void Position2D::set ( const Position2D pos  )  [inline]

Definition at line 71 of file Position2D.h.

References myX, and myY.

00071                                     {
00072         myX = pos.myX;
00073         myY = pos.myY;
00074     }

void Position2D::set ( SUMOReal  x,
SUMOReal  y 
) [inline]

void Position2D::sub ( const Position2D pos  )  [inline]

Substracts the given position from this one.

Definition at line 108 of file Position2D.h.

References myX, and myY.

00108                                     {
00109         myX -= pos.myX;
00110         myY -= pos.myY;
00111     }

void Position2D::sub ( SUMOReal  dx,
SUMOReal  dy 
) [inline]

Substracts the given position from this one.

Definition at line 102 of file Position2D.h.

References myX, and myY.

Referenced by GeoConvHelper::cartesian2geo(), GUIDanielPerspectiveChanger::centerTo(), NBNode::computeInternalLaneShape(), NBNode::getEmptyDir(), Line2D::rotateAtP1(), and Line2D::sub().

00102                                        {
00103         myX -= dx;
00104         myY -= dy;
00105     }

SUMOReal Position2D::x (  )  const [inline]

Returns the x-position.

Definition at line 55 of file Position2D.h.

References myX.

Referenced by Line2D::add(), Boundary::add(), GUISUMOAbstractView::applyChanges(), Position2DVector::around(), Boundary::around(), Line2D::atan2Angle(), Line2D::atan2DegreeAngle(), GeoConvHelper::cartesian2geo(), NGRandomNetBuilder::checkAngles(), GeomHelper::closestDistancePointLine(), traci::TraCIServer::commandPositionConversion(), traci::TraCIServer::commandSimulationParameter(), NBNode::computeInternalLaneShape(), NBEdge::computeLaneShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), traci::TraCIServer::convertCartesianToRoadMap(), GeomHelper::distancePointLine(), GLHelper::drawBoxLines(), GLHelper::drawFilledPoly(), GUIVehicle::drawGL(), GUITriggeredRerouter::drawGL(), GUIPointOfInterest::drawGL(), GUILaneSpeedTrigger::drawGL(), GUIJunctionWrapper::drawGL(), GUIInductLoop::MyWrapper::drawGL(), GUIEmitter::drawGL(), GUIEdge::drawGL(), GUIBusStop::drawGL(), GUIGlObject_AbstractAdd::drawGLName(), GUIE3Collector::MyWrapper::drawSingleCrossing(), MSVehicle::enterLaneAtLaneChange(), MSVTypeProbe::execute(), GeomHelper::extrapolate_first(), GeomHelper::extrapolate_second(), Line2D::extrapolateBy(), GUIPointOfInterest::getCenteringBoundary(), GUIEmitter::getCenteringBoundary(), NBNode::getEmptyDir(), GeomHelper::getNormal90D_CW(), GeoConvHelper::getOffsetBase(), Line2D::getPositionAtDistance(), GUISUMOAbstractView::getPositionInformation(), GUIDanielPerspectiveChanger::getXPos(), GUIBusStop::GUIBusStop(), GUIJunctionWrapper::GUIJunctionWrapper(), GUILaneWrapper::GUILaneWrapper(), traci::TraCIServer::handlePoiDomain(), traci::TraCIServer::handlePolygonDomain(), traci::TraCIServer::handleTrafficLightDomain(), traci::TraCIServer::handleVehicleDomain(), NBEdge::init(), NIXMLEdgesHandler::insertNodeChecking(), GeomHelper::interpolate(), GeomHelper::intersection_position(), GeomHelper::intersects(), Position2DVector::isLeft(), isLeft(), Line2D::length(), main(), Position2DVector::move2side(), MSVehicle::moveFirstChecked(), MSVehicle::moveRegardingCritical(), GUI_E2_ZS_Collector::MyWrapper::myConstruct(), NIXMLNodesHandler::myStartElement(), GeomHelper::nearest_position_on_line_to_point(), Position2DVector::increasing_x_y_sorter::operator()(), Position2DVector::as_poly_cw_sorter::operator()(), Position2DVector::positionAtLengthPosition(), traci::TraCIServer::postProcessSimulationStep(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Junction::processGet(), reshiftRotate(), NBNodeCont::retrieve(), Line2D::rotateAround(), ROWdrawAction_drawArrows(), ROWdrawAction_drawLane2LaneConnections(), ROWdrawAction_drawLinkNo(), ROWdrawAction_drawLinkRules(), ROWdrawAction_drawTLSLinkNo(), NBNodeCont::savePlain(), set(), GUIVehicle::Colorer::setFunctionalColor(), NIXMLEdgesHandler::setNodes(), NGNode::setY(), NBNode::sortNodesEdges(), TEST(), TEST_F(), GeomHelper::transfer_to_side(), GUISUMOAbstractView::updatePositionInformation(), NBNode::writeXML(), NBNode::writeXMLInternalNodes(), and GeoConvHelper::x2cartesian().

00055                        {
00056         return myX;
00057     }

SUMOReal Position2D::y (  )  const [inline]

Returns the y-position.

Definition at line 60 of file Position2D.h.

References myY.

Referenced by Line2D::add(), Boundary::add(), GUISUMOAbstractView::applyChanges(), Position2DVector::around(), Boundary::around(), Line2D::atan2Angle(), Line2D::atan2DegreeAngle(), GeoConvHelper::cartesian2geo(), NGRandomNetBuilder::checkAngles(), GeomHelper::closestDistancePointLine(), traci::TraCIServer::commandPositionConversion(), traci::TraCIServer::commandSimulationParameter(), NBNode::computeInternalLaneShape(), NBEdge::computeLaneShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), traci::TraCIServer::convertCartesianToRoadMap(), GeomHelper::distancePointLine(), GLHelper::drawBoxLines(), GLHelper::drawFilledPoly(), GUIVehicle::drawGL(), GUITriggeredRerouter::drawGL(), GUIPointOfInterest::drawGL(), GUILaneSpeedTrigger::drawGL(), GUIJunctionWrapper::drawGL(), GUIInductLoop::MyWrapper::drawGL(), GUIEmitter::drawGL(), GUIEdge::drawGL(), GUIBusStop::drawGL(), GUIGlObject_AbstractAdd::drawGLName(), GUIE3Collector::MyWrapper::drawSingleCrossing(), MSVehicle::enterLaneAtLaneChange(), MSVTypeProbe::execute(), GeomHelper::extrapolate_first(), GeomHelper::extrapolate_second(), Line2D::extrapolateBy(), GUIPointOfInterest::getCenteringBoundary(), GUIEmitter::getCenteringBoundary(), NBNode::getEmptyDir(), GeomHelper::getNormal90D_CW(), GeoConvHelper::getOffsetBase(), Line2D::getPositionAtDistance(), GUISUMOAbstractView::getPositionInformation(), GUIDanielPerspectiveChanger::getYPos(), GUIBusStop::GUIBusStop(), GUIJunctionWrapper::GUIJunctionWrapper(), GUILaneWrapper::GUILaneWrapper(), traci::TraCIServer::handlePoiDomain(), traci::TraCIServer::handlePolygonDomain(), traci::TraCIServer::handleTrafficLightDomain(), traci::TraCIServer::handleVehicleDomain(), NBEdge::init(), NIXMLEdgesHandler::insertNodeChecking(), GeomHelper::interpolate(), GeomHelper::intersection_position(), GeomHelper::intersects(), Position2DVector::isLeft(), isLeft(), Line2D::length(), main(), Position2DVector::move2side(), MSVehicle::moveFirstChecked(), MSVehicle::moveRegardingCritical(), GUI_E2_ZS_Collector::MyWrapper::myConstruct(), NIXMLNodesHandler::myStartElement(), GeomHelper::nearest_position_on_line_to_point(), Position2DVector::increasing_x_y_sorter::operator()(), Position2DVector::as_poly_cw_sorter::operator()(), Position2DVector::positionAtLengthPosition(), traci::TraCIServer::postProcessSimulationStep(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Junction::processGet(), reshiftRotate(), NBNodeCont::retrieve(), Line2D::rotateAround(), ROWdrawAction_drawArrows(), ROWdrawAction_drawLane2LaneConnections(), ROWdrawAction_drawLinkNo(), ROWdrawAction_drawLinkRules(), ROWdrawAction_drawTLSLinkNo(), NBNodeCont::savePlain(), set(), GUIVehicle::Colorer::setFunctionalColor(), NIXMLEdgesHandler::setNodes(), NGNode::setX(), NBNode::sortNodesEdges(), TEST(), TEST_F(), GeomHelper::transfer_to_side(), GUISUMOAbstractView::updatePositionInformation(), NBNode::writeXML(), NBNode::writeXMLInternalNodes(), and GeoConvHelper::x2cartesian().

00060                        {
00061         return myY;
00062     }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Position2D p 
) [friend]

Prints to the output.

Definition at line 128 of file Position2D.h.

00128                                                                        {
00129         os << p.x() << "," << p.y();
00130         return os;
00131     }


Field Documentation

SUMOReal Position2D::myX [private]

The x-position.

Definition at line 159 of file Position2D.h.

Referenced by add(), almostSame(), distanceSquaredTo(), mul(), norm(), operator!=(), operator==(), reshiftRotate(), set(), sub(), and x().

SUMOReal Position2D::myY [private]

The y-position.

Definition at line 162 of file Position2D.h.

Referenced by add(), almostSame(), distanceSquaredTo(), mul(), norm(), operator!=(), operator==(), reshiftRotate(), set(), sub(), and y().


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

Generated on Wed May 5 00:06:58 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6