#include <Line2D.h>
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 Position2D & | p1 () const |
| const Position2D & | p2 () const |
| Line2D & | reverse () |
| void | rotateAround (const Position2D &at, SUMOReal rot) |
| void | rotateAtP1 (SUMOReal rot) |
| void | sub (SUMOReal x, SUMOReal y) |
| ~Line2D () | |
Private Attributes | |
| Position2D | myP1 |
| Position2D | myP2 |
| Line2D::Line2D | ( | ) |
| Line2D::Line2D | ( | const Position2D & | p1, | |
| const Position2D & | p2 | |||
| ) |
| Line2D::~Line2D | ( | ) |
| void Line2D::add | ( | const Position2D & | p | ) |
Definition at line 176 of file Line2D.cpp.
References Position2D::add(), myP1, myP2, Position2D::x(), and Position2D::y().
| 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().
| 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().
| SUMOReal Line2D::atan2DegreeAngle | ( | ) | const |
Definition at line 133 of file Line2D.cpp.
References myP1, myP2, PI, SUMOReal, Position2D::x(), and Position2D::y().
Referenced by NBEdge::computeEdgeShape(), NBNode::computeInternalLaneShape(), NBEdge::computeLaneShape(), NIVissimEdge::dict_checkEdges2Join(), NBEdge::getAngle(), NBNodeShapeComputer::joinSameDirectionEdges(), and Position2DVector::rotationDegreeAtLengthPosition().
00133 { 00134 return (SUMOReal) atan2(myP1.x()-myP2.x(), myP1.y()-myP2.y()) *(SUMOReal) 180.0 / (SUMOReal) PI; 00135 }
| 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 | ) |
Definition at line 56 of file Line2D.cpp.
References Position2D::distanceTo(), myP1, myP2, SUMOReal, Position2D::x(), and Position2D::y().
Referenced by Position2DVector::appendWithCrossingPoint(), NBNodeShapeComputer::computeContinuationNodeShape(), NBEdge::computeEdgeShape(), NBEdge::computeLaneShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), computeSameEnd(), NBNodeShapeComputer::joinSameDirectionEdges(), and Position2DVector::move2side().
00056 { 00057 SUMOReal oldlen = myP1.distanceTo(myP2); 00058 SUMOReal x1 = myP1.x() - (myP2.x() - myP1.x()) * (length) / oldlen; 00059 SUMOReal y1 = myP1.y() - (myP2.y() - myP1.y()) * (length) / oldlen; 00060 SUMOReal x2 = myP2.x() - (myP1.x() - myP2.x()) * (length) / oldlen; 00061 SUMOReal y2 = myP2.y() - (myP1.y() - myP2.y()) * (length) / oldlen; 00062 myP1 = Position2D(x1, y1); 00063 myP2 = Position2D(x2, y2); 00064 }
| 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 }
Definition at line 154 of file Line2D.cpp.
References GeomHelper::intersects(), myP1, and myP2.
Referenced by NBNode::computeInternalLaneShape(), NBEdge::computeLaneShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), Position2DVector::move2side(), and TEST().
00154 { 00155 return GeomHelper::intersects(myP1, myP2, l.myP1, l.myP2); 00156 }
| Position2D Line2D::intersectsAt | ( | const Line2D & | l | ) | const |
Definition at line 148 of file Line2D.cpp.
References GeomHelper::intersection_position(), myP1, and myP2.
Referenced by NBNode::computeInternalLaneShape(), NBEdge::computeLaneShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), Position2DVector::move2side(), and TEST().
00148 { 00149 return GeomHelper::intersection_position(myP1, myP2, l.myP1, l.myP2); 00150 }
| SUMOReal Line2D::intersectsAtLength | ( | const Line2D & | v | ) |
Definition at line 200 of file Line2D.cpp.
References GeomHelper::intersection_position(), myP1, myP2, and GeomHelper::nearest_position_on_line_to_point().
Referenced by TEST().
00200 { 00201 Position2D pos = 00202 GeomHelper::intersection_position(myP1, myP2, v.myP1, v.myP2); 00203 return GeomHelper::nearest_position_on_line_to_point(myP1, myP2, pos); 00204 }
| 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 |
Definition at line 79 of file Line2D.cpp.
References myP1.
Referenced by NBEdge::computeEdgeShape(), NBNode::computeInternalLaneShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), computeSameEnd(), Position2DVector::intersectsAtLengths(), NBNodeShapeComputer::joinSameDirectionEdges(), NBNodeShapeComputer::replaceFirstChecking(), and TEST().
00079 { 00080 return myP1; 00081 }
| const Position2D & Line2D::p2 | ( | ) | const |
Definition at line 85 of file Line2D.cpp.
References myP2.
Referenced by NBEdge::computeEdgeShape(), NBNode::computeInternalLaneShape(), NIVissimEdge::dict_checkEdges2Join(), Position2DVector::intersectsAtLengths(), NBNodeShapeComputer::replaceLastChecking(), and TEST().
00085 { 00086 return myP2; 00087 }
| Line2D & Line2D::reverse | ( | ) |
Definition at line 191 of file Line2D.cpp.
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().
Position2D Line2D::myP1 [private] |
Definition at line 76 of file Line2D.h.
Referenced by add(), atan2Angle(), atan2DegreeAngle(), extrapolateBy(), extrapolateFirstBy(), extrapolateSecondBy(), getPositionAtDistance(), intersects(), intersectsAt(), intersectsAtLength(), intersectsAtLengths(), length(), move2side(), p1(), reverse(), rotateAround(), rotateAtP1(), and sub().
Position2D Line2D::myP2 [private] |
Definition at line 76 of file Line2D.h.
Referenced by add(), atan2Angle(), atan2DegreeAngle(), extrapolateBy(), extrapolateFirstBy(), extrapolateSecondBy(), getPositionAtDistance(), intersects(), intersectsAt(), intersectsAtLength(), intersectsAtLengths(), length(), move2side(), p2(), reverse(), rotateAround(), rotateAtP1(), and sub().
1.5.6