NBHelpers Class Reference

#include <NBHelpers.h>


Detailed Description

Some mathmatical methods for the computation of angles

Definition at line 49 of file NBHelpers.h.


Static Public Member Functions

static SUMOReal angle (SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2)
static SUMOReal distance (NBNode *node1, NBNode *node2)
static std::string normalIDRepresentation (const std::string &id)
static SUMOReal normRelAngle (SUMOReal angle1, SUMOReal angle2)
static SUMOReal relAngle (SUMOReal angle1, SUMOReal angle2)
static SUMOReal relAngle (SUMOReal angle, SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2)

Member Function Documentation

SUMOReal NBHelpers::angle ( SUMOReal  x1,
SUMOReal  y1,
SUMOReal  x2,
SUMOReal  y2 
) [static]

computes the angle of the straight which is described by the two coordinates

Definition at line 49 of file NBHelpers.cpp.

References PI, and SUMOReal.

Referenced by NBEdge::init(), and relAngle().

00049                                                                    {
00050     SUMOReal angle = (SUMOReal) atan2(x1-x2, y1-y2) * (SUMOReal) 180.0 / (SUMOReal) PI;
00051     if (angle<0) {
00052         angle = 360 + angle;
00053     }
00054     return angle;
00055 }

SUMOReal NBHelpers::distance ( NBNode node1,
NBNode node2 
) [static]

returns the distance between both nodes

Definition at line 97 of file NBHelpers.cpp.

References Position2D::distanceTo(), and NBNode::getPosition().

00097                                                 {
00098     return node1->getPosition().distanceTo(node2->getPosition());
00099 }

std::string NBHelpers::normalIDRepresentation ( const std::string &  id  )  [static]

SUMOReal NBHelpers::normRelAngle ( SUMOReal  angle1,
SUMOReal  angle2 
) [static]

normalises angle <-170 and >170 to 180 after the computation with "relAngle"

Definition at line 77 of file NBHelpers.cpp.

References relAngle(), and SUMOReal.

Referenced by NBContHelper::same_connection_edge_sorter::getMinMaxRelAngles(), NBNode::getMMLDirection(), NBEdge::connections_relative_edgelane_sorter::operator()(), and NBContHelper::relative_edge_sorter::operator()().

00077                                                         {
00078     SUMOReal rel = relAngle(angle1, angle2);
00079     if (rel<-170||rel>170)
00080         rel = -180;
00081     return rel;
00082 }

SUMOReal NBHelpers::relAngle ( SUMOReal  angle1,
SUMOReal  angle2 
) [static]

computes the relative angle between the two angles

Definition at line 66 of file NBHelpers.cpp.

00066                                                     {
00067     angle2 -= angle1;
00068     if (angle2>180)
00069         angle2 = (360 - angle2) * -1;
00070     while (angle2<-180)
00071         angle2 = 360 + angle2;
00072     return angle2;
00073 }

SUMOReal NBHelpers::relAngle ( SUMOReal  angle,
SUMOReal  x1,
SUMOReal  y1,
SUMOReal  x2,
SUMOReal  y2 
) [static]

computes the angle between the first angle and the straigth which is described by her coordinates (parameter 2-5)

Definition at line 59 of file NBHelpers.cpp.

References angle(), and SUMOReal.

Referenced by NBEdge::acceptBeingTurning(), NBEdge::computeTurningDirections(), normRelAngle(), and NBEdge::setTurningDestination().

00059                                                                                       {
00060     SUMOReal sec_angle = NBHelpers::angle(x1, y1, x2, y2);
00061     return relAngle(angle, sec_angle);
00062 }


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

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