|
@@ -186,6 +186,9 @@ void RoadGeometry::GetCoords(double s_check, double &retX, double &retY)
|
|
|
void RoadGeometry::GetCoords(double s_check, double &retX, double &retY, double &retHDG)
|
|
|
{}
|
|
|
|
|
|
+double RoadGeometry::GetRoadCurvature(double s_check)
|
|
|
+{return 0.0;}
|
|
|
+
|
|
|
|
|
|
|
|
|
//***********************************************************************************
|
|
@@ -234,7 +237,10 @@ void GeometryLine::GetCoords(double s_check, double &retX, double &retY, double
|
|
|
retHDG=mHdg;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+double GeometryLine::GetRoadCurvature(double s_check)
|
|
|
+{
|
|
|
+ return 0.0;
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
@@ -340,7 +346,14 @@ void GeometryArc::GetCoords(double s_check, double &retX, double &retY, double &
|
|
|
retHDG=endAngle+M_PI_2;
|
|
|
}
|
|
|
|
|
|
+double GeometryArc::GetRoadCurvature(double s_check)
|
|
|
+{
|
|
|
+ double currentLength = s_check - mS;
|
|
|
+ if(currentLength<0)return 0.0;
|
|
|
+ if(currentLength>mLength)return 0.0;
|
|
|
|
|
|
+ return fabs(mCurvature);
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
@@ -432,6 +445,31 @@ RoadGeometry* GeometrySpiral::Clone() const
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+double GeometrySpiral::GetRoadCurvature(double s_check)
|
|
|
+{
|
|
|
+ double currentLength = s_check - mS;
|
|
|
+ if(currentLength<0)return 0.0;
|
|
|
+ if(currentLength>mLength)return 0.0;
|
|
|
+
|
|
|
+ if(mLength < 0.1)return 0.0;
|
|
|
+ if(currentLength<0.05)return fabs(mCurvatureStart);
|
|
|
+ if(currentLength>(mLength-0.05))return fabs(mCurvatureEnd);
|
|
|
+
|
|
|
+ double fx1,fy1,fhdg1;
|
|
|
+ double fx2,fy2,fhdg2;
|
|
|
+ GetCoords(s_check-0.05,fx1,fy1,fhdg1);
|
|
|
+ GetCoords(s_check+0.05,fx2,fy2,fhdg2);
|
|
|
+ if(fhdg1 == fhdg2)
|
|
|
+ {
|
|
|
+ return 0.0;
|
|
|
+ }
|
|
|
+ double fhdgdiff = fabs(fhdg2 - fhdg1);
|
|
|
+ while(fhdgdiff>=2.0*M_PI)fhdgdiff = fhdgdiff - 2.0*M_PI;
|
|
|
+
|
|
|
+ if(fhdgdiff > M_PI)fhdgdiff = 2.0 * M_PI - fhdgdiff;
|
|
|
+ double fcurv = fhdgdiff/0.1;
|
|
|
+ return fcurv;
|
|
|
+}
|
|
|
|
|
|
//-------------------------------------------------
|
|
|
|
|
@@ -782,6 +820,52 @@ void GeometryPoly3::GetCoords(double s_check, double &retX, double &retY, double
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+double GeometryPoly3::GetRoadCurvature(double s_check)
|
|
|
+{
|
|
|
+ double currentLength = s_check - mS;
|
|
|
+ if(currentLength<0)return 0.0;
|
|
|
+ if(currentLength>mLength)return 0.0;
|
|
|
+
|
|
|
+ if(mLength < 0.1)return 0.0;
|
|
|
+ double fmove1;
|
|
|
+ double fmove2;
|
|
|
+ if(currentLength<0.05)
|
|
|
+ {
|
|
|
+ fmove1 = 0;
|
|
|
+ fmove2 = 0.05;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(currentLength>(mLength-0.05))
|
|
|
+ {
|
|
|
+ fmove1 = -0.05;
|
|
|
+ fmove2 = 0.0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fmove1 = -0.05;
|
|
|
+ fmove2 = 0.05;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ double fx1,fy1,fhdg1;
|
|
|
+ double fx2,fy2,fhdg2;
|
|
|
+ GetCoords(s_check+fmove1,fx1,fy1,fhdg1);
|
|
|
+ GetCoords(s_check+fmove2,fx2,fy2,fhdg2);
|
|
|
+ if(fhdg1 == fhdg2)
|
|
|
+ {
|
|
|
+ return 0.0;
|
|
|
+ }
|
|
|
+ double fhdgdiff = fabs(fhdg2 - fhdg1);
|
|
|
+ while(fhdgdiff>=2.0*M_PI)fhdgdiff = fhdgdiff - 2.0*M_PI;
|
|
|
+
|
|
|
+ if(fhdgdiff > M_PI)fhdgdiff = 2.0 * M_PI - fhdgdiff;
|
|
|
+ double fcurv = fhdgdiff/0.1;
|
|
|
+ return fcurv;
|
|
|
+}
|
|
|
+
|
|
|
//***********************************************************************************
|
|
|
//Cubic Polynom geometry. Has to be implemented. Added By Yuchuli
|
|
|
//***********************************************************************************
|
|
@@ -945,6 +1029,52 @@ void GeometryParamPoly3::GetCoords(double s_check, double &retX, double &retY, d
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+double GeometryParamPoly3::GetRoadCurvature(double s_check)
|
|
|
+{
|
|
|
+ double currentLength = s_check - mS;
|
|
|
+ if(currentLength<0)return 0.0;
|
|
|
+ if(currentLength>mLength)return 0.0;
|
|
|
+
|
|
|
+ if(mLength < 0.1)return 0.0;
|
|
|
+ double fmove1;
|
|
|
+ double fmove2;
|
|
|
+ if(currentLength<0.05)
|
|
|
+ {
|
|
|
+ fmove1 = 0;
|
|
|
+ fmove2 = 0.05;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(currentLength>(mLength-0.05))
|
|
|
+ {
|
|
|
+ fmove1 = -0.05;
|
|
|
+ fmove2 = 0.0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fmove1 = -0.05;
|
|
|
+ fmove2 = 0.05;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ double fx1,fy1,fhdg1;
|
|
|
+ double fx2,fy2,fhdg2;
|
|
|
+ GetCoords(s_check+fmove1,fx1,fy1,fhdg1);
|
|
|
+ GetCoords(s_check+fmove2,fx2,fy2,fhdg2);
|
|
|
+ if(fhdg1 == fhdg2)
|
|
|
+ {
|
|
|
+ return 0.0;
|
|
|
+ }
|
|
|
+ double fhdgdiff = fabs(fhdg2 - fhdg1);
|
|
|
+ while(fhdgdiff>=2.0*M_PI)fhdgdiff = fhdgdiff - 2.0*M_PI;
|
|
|
+
|
|
|
+ if(fhdgdiff > M_PI)fhdgdiff = 2.0 * M_PI - fhdgdiff;
|
|
|
+ double fcurv = fhdgdiff/0.1;
|
|
|
+ return fcurv;
|
|
|
+}
|
|
|
+
|
|
|
//***********************************************************************************
|
|
|
//Base class for Geometry blocks
|
|
|
//***********************************************************************************
|
|
@@ -1198,6 +1328,22 @@ short int GeometryBlock::GetCoords(double s_check, double &retX, double &retY,
|
|
|
|
|
|
}
|
|
|
|
|
|
+double GeometryBlock::GetRoadCurvature(double s_check)
|
|
|
+{
|
|
|
+ // go through all the elements
|
|
|
+ for (unsigned int i=0;i<mGeometryBlockElement.size();i++)
|
|
|
+ {
|
|
|
+ //if the s_check belongs to one of the geometries
|
|
|
+ if (mGeometryBlockElement.at(i)->CheckInterval(s_check))
|
|
|
+ {
|
|
|
+ //get the x,y coords and return the type of the geometry
|
|
|
+ return mGeometryBlockElement.at(i)->GetRoadCurvature(s_check);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //if nothing found, return -999
|
|
|
+ return -1.0;
|
|
|
+}
|
|
|
+
|
|
|
//-------------------------------------------------
|
|
|
/**
|
|
|
* Destructor
|