From 798a3d66fc6111daf0fb5f90de25471145f55cfa Mon Sep 17 00:00:00 2001 From: Pierre Abbat Date: Sun, 9 Sep 2018 22:51:20 +0000 Subject: [PATCH] Add functions to format curvature and clothance (untested) These need to be outside the Measure class because, when using feet, curvature and clothance are expressed as angle, a different quantity. Also add curvature and clothance to measure.{h,cpp}. --- arc.cpp | 33 ++++++++++++++++ arc.h | 4 +- measure.cpp | 112 ++++++++++++++++++++++++++++------------------------ measure.h | 6 +++ spiral.cpp | 30 ++++++++++++++ spiral.h | 2 + 6 files changed, 134 insertions(+), 53 deletions(-) diff --git a/arc.cpp b/arc.cpp index ea7a49e7..ea15306d 100644 --- a/arc.cpp +++ b/arc.cpp @@ -26,6 +26,8 @@ #include "vcurve.h" #include "spiral.h" +using namespace std; + arc::arc() { start=end=xyz(0,0,0); @@ -197,3 +199,34 @@ double arc::in(xy pnt) interpolation and calong(). Then use parabolic interpolation to find the closest point on the circle. */ + +string formatCurvature(double curvature,Measure ms) +/* The coherent unit of curvature is the diopter (not an SI unit, but coherent + * with SI). For roads, the millidiopter is closer to the size. When roads + * are measured in feet, however, curvature is expressed not in per feet, + * but by stating the angle subtended by a 100-foot arc. Railroads use + * a 100-foot chord, which I may add later (it'll require a flag somewhere). + */ +{ + double hundredFeet=ms.parseMeasurement("100 ft",LENGTH).magnitude; + bool isFoot; + string hundredFeetString=ms.formatMeasurement(hundredFeet,LENGTH); + int i; + for (i=0;i1 || dist(mid,lastmid)>1e-6) cur=clo=len=NAN; } + +string formatClothance(double clothance,Measure ms) +/* The coherent unit of clothance is the square diopter (not an SI unit, but + * coherent with SI). For roads, the square millidiopter is closer to the size. + * When roads are measured in feet, however, clothance is expressed not in per + * square feet, but by stating the change in degree of curve over a 100-foot arc. + */ +{ + double hundredFeet=ms.parseMeasurement("100 ft",LENGTH).magnitude; + bool isFoot; + string hundredFeetString=ms.formatMeasurement(hundredFeet,LENGTH); + int i; + for (i=0;i