Line2D Class Reference

#include <Line2D.h>


Detailed Description

Definition at line 48 of file Line2D.h.


Public Member Functions

void add (const Position2D &p)
void add (SUMOReal x, SUMOReal y)
SUMOReal atan2Angle () const
SUMOReal atan2DegreeAngle () const
SUMOReal atan2PositiveAngle () const
void extrapolateBy (SUMOReal length)
void extrapolateFirstBy (SUMOReal length)
void extrapolateSecondBy (SUMOReal length)
Position2D getPositionAtDistance (SUMOReal offset) const
bool intersects (const Line2D &l) const
Position2D intersectsAt (const Line2D &l) const
SUMOReal intersectsAtLength (const Line2D &v)
DoubleVector intersectsAtLengths (const Position2DVector &v)
SUMOReal length () const
 Line2D (const Position2D &p1, const Position2D &p2)
 Line2D ()
void move2side (SUMOReal amount)
const Position2Dp1 () const
const Position2Dp2 () const
Line2Dreverse ()
void rotateAround (const Position2D &at, SUMOReal rot)
void rotateAtP1 (SUMOReal rot)
void sub (SUMOReal x, SUMOReal y)
 ~Line2D ()

Private Attributes

Position2D myP1
Position2D myP2

Constructor & Destructor Documentation

Line2D::Line2D (  ) 

Definition at line 45 of file Line2D.cpp.

00045 {}

Line2D::Line2D ( const Position2D p1,
const Position2D p2 
)

Definition at line 48 of file Line2D.cpp.

00049         : myP1(p1), myP2(p2) {}

Line2D::~Line2D (  ) 

Definition at line 52 of file Line2D.cpp.

00052 {}


Member Function Documentation

void Line2D::add ( const Position2D p  ) 

Definition at line 176 of file Line2D.cpp.

References Position2D::add(), myP1, myP2, Position2D::x(), and Position2D::y().

00176                                {
00177     myP1.add(p.x(), p.y());
00178     myP2.add(p.x(), p.y());
00179 }

void Line2D::add ( SUMOReal  x,
SUMOReal  y 
)

Definition at line 169 of file Line2D.cpp.

References Position2D::add(), myP1, and myP2.

Referenced by NBNodeShapeComputer::computeNodeShapeByCrosses(), and TEST().

00169                                   {
00170     myP1.add(x, y);
00171     myP2.add(x, y);
00172 }

SUMOReal Line2D::atan2Angle (  )  const

Definition at line 127 of file Line2D.cpp.

References myP1, myP2, Position2D::x(), and Position2D::y().

Referenced by atan2PositiveAngle(), and Position2DVector::beginEndAngle().

00127                          {
00128     return atan2(myP1.x()-myP2.x(), myP1.y()-myP2.y());
00129 }

SUMOReal Line2D::atan2DegreeAngle (  )  const

SUMOReal Line2D::atan2PositiveAngle (  )  const

Definition at line 139 of file Line2D.cpp.

References atan2Angle(), PI, and SUMOReal.

00139                                  {
00140     SUMOReal angle = atan2Angle();
00141     if (angle<0) {
00142         angle = (SUMOReal) PI * (SUMOReal) 2.0 + angle;
00143     }
00144     return angle;
00145 }

void Line2D::extrapolateBy ( SUMOReal  length  ) 

void Line2D::extrapolateFirstBy ( SUMOReal  length  ) 

Definition at line 68 of file Line2D.cpp.

References GeomHelper::extrapolate_first(), myP1, and myP2.

Referenced by NBNode::computeInternalLaneShape().

00068                                           {
00069     myP1 = GeomHelper::extrapolate_first(myP1, myP2, length);
00070 }

void Line2D::extrapolateSecondBy ( SUMOReal  length  ) 

Definition at line 74 of file Line2D.cpp.

References GeomHelper::extrapolate_second(), myP1, and myP2.

Referenced by NBNode::computeInternalLaneShape().

00074                                            {
00075     myP2 = GeomHelper::extrapolate_second(myP1, myP2, length);
00076 }

Position2D Line2D::getPositionAtDistance ( SUMOReal  offset  )  const

Definition at line 91 of file Line2D.cpp.

References Position2D::distanceTo(), length(), myP1, myP2, SUMOReal, Position2D::x(), and Position2D::y().

Referenced by NBEdge::computeEdgeShape(), NBNode::computeInternalLaneShape(), computeSameEnd(), and Position2DVector::splitAt().

00091                                                    {
00092     SUMOReal length = myP1.distanceTo(myP2);
00093     if (length==0) {
00094         if (offset!=0) {
00095             throw 1;
00096         }
00097         return myP1;
00098     }
00099     SUMOReal x = myP1.x() + (myP2.x() - myP1.x()) / length * offset;
00100     SUMOReal y = myP1.y() + (myP2.y() - myP1.y()) / length * offset;
00101     /*    SUMOReal x2 = myP2.x() - (myP1.x() - myP2.x())  / length * offset;
00102         SUMOReal y2 = myP2.y() - (myP1.y() - myP2.y()) / length * offset;*/
00103     return Position2D(x, y);
00104 }

bool Line2D::intersects ( const Line2D l  )  const

Position2D Line2D::intersectsAt ( const Line2D l  )  const

SUMOReal Line2D::intersectsAtLength ( const Line2D v  ) 

DoubleVector Line2D::intersectsAtLengths ( const Position2DVector v  ) 

Definition at line 116 of file Line2D.cpp.

References Position2D::distanceTo(), Position2DVector::intersectsAtPoints(), myP1, myP2, and Position2DVector::size().

Referenced by NBEdge::computeEdgeShape(), and Position2DVector::intersectsAtLengths().

00116                                                      {
00117     Position2DVector p = v.intersectsAtPoints(myP1, myP2);
00118     DoubleVector ret;
00119     for (size_t i=0; i<p.size(); i++) {
00120         ret.push_back(myP1.distanceTo(p[i]));
00121     }
00122     return ret;
00123 }

SUMOReal Line2D::length (  )  const

Definition at line 160 of file Line2D.cpp.

References myP1, myP2, Position2D::x(), and Position2D::y().

Referenced by NBNode::computeInternalLaneShape(), getPositionAtDistance(), Position2DVector::intersectsAtLengths(), and TEST().

00160                      {
00161     return sqrt(
00162                (myP1.x()-myP2.x())*(myP1.x()-myP2.x())
00163                +
00164                (myP1.y()-myP2.y())*(myP1.y()-myP2.y()));
00165 }

void Line2D::move2side ( SUMOReal  amount  ) 

Definition at line 108 of file Line2D.cpp.

References Position2D::add(), GeomHelper::getNormal90D_CW(), myP1, and myP2.

Referenced by NBNodeShapeComputer::replaceFirstChecking(), NBNodeShapeComputer::replaceLastChecking(), and TEST().

00108                                  {
00109     std::pair<SUMOReal, SUMOReal> p = GeomHelper::getNormal90D_CW(myP1, myP2, amount);
00110     myP1.add(p.first, p.second);
00111     myP2.add(p.first, p.second);
00112 }

const Position2D & Line2D::p1 (  )  const

const Position2D & Line2D::p2 (  )  const

Line2D & Line2D::reverse (  ) 

Definition at line 191 of file Line2D.cpp.

References myP1, and myP2.

Referenced by TEST().

00191                 {
00192     Position2D tmp(myP1);
00193     myP1 = myP2;
00194     myP2 = tmp;
00195     return *this;
00196 }

void Line2D::rotateAround ( const Position2D at,
SUMOReal  rot 
)

Definition at line 218 of file Line2D.cpp.

References Position2D::add(), myP1, myP2, SUMOReal, Position2D::x(), and Position2D::y().

Referenced by NBNodeShapeComputer::computeNodeShapeByCrosses().

00218                                                        {
00219     myP1.add(-at.x(), -at.y());
00220     myP2.add(-at.x(), -at.y());
00221     {
00222         SUMOReal x = myP1.x() * cos(rot) + myP1.y() * sin(rot);
00223         SUMOReal y = myP1.y() * cos(rot) - myP1.x() * sin(rot);
00224         myP1 = Position2D(x, y);
00225     }
00226     {
00227         SUMOReal x = myP2.x() * cos(rot) + myP2.y() * sin(rot);
00228         SUMOReal y = myP2.y() * cos(rot) - myP2.x() * sin(rot);
00229         myP2 = Position2D(x, y);
00230     }
00231     myP1.add(at.x(), at.y());
00232     myP2.add(at.x(), at.y());
00233 }

void Line2D::rotateAtP1 ( SUMOReal  rot  ) 

Definition at line 208 of file Line2D.cpp.

References Position2D::add(), myP1, myP2, Position2D::reshiftRotate(), and Position2D::sub().

Referenced by NBNode::computeInternalLaneShape(), and TEST().

00208                                {
00209     Position2D p = myP2;
00210     p.sub(myP1);
00211     p.reshiftRotate(0, 0, rot);
00212     p.add(myP1);
00213     myP2 = p;
00214 }

void Line2D::sub ( SUMOReal  x,
SUMOReal  y 
)

Definition at line 183 of file Line2D.cpp.

References myP1, myP2, and Position2D::sub().

Referenced by NBNode::computeInternalLaneShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), and TEST().

00183                                   {
00184     myP1.sub(x, y);
00185     myP2.sub(x, y);
00186 }


Field Documentation


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

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