I\'m coding renderer for road network, which based on the RoadXML format.
Road curves from this format has four types:
Let's see. Your data is:
start curvature = 0, straight line, R=INF
end curvature = -0.0165407, circular arc, R_c = 1/k_c = 60.4569335
length = 45.185. distance along clothoid, s_c = 45.185
according to Wikipedia article,
R s = const = R_c s_c ( s ~ k = 1/R by definition of clothoid )
d(s) = R d(theta)
d(theta) = k d(s)
d(theta) / d(s) = 1 / R = k = s / R_c s_c
theta = s^2 / 2 R_c s_c = (s/a)^2 = s / 2 R = k s / 2
where ___________________
a = sqrt(2 R_c s_c) (... = 73.915445 )
~~~~~~~~~~~~~~~~~~~
and so theta_c = k_c s_c / 2 (... = 0.37369576475 = 21.411190 degrees )
( not so flat after all !! )
(note: I call a
here a reciprocal of what WP article calls a
). Then,
d(x) = d(s) cos(theta)
d(y) = d(s) sin(theta)
x = INT[s=0..s] cos(theta) d(s)
= INT[s=0..s] cos((s/a)^2) a d(s/a)
= a INT[u=0..(s/a)] cos(u^2) d(u) = a C( s/a )
y = a INT[u=0..(s/a)] sin(u^2) d(u) = a S( s/a )
where C(t)
and S(t)
are Fresnel integrals.
So that's how you do the scaling. Not just t = s
, but t = s/a
= sqrt(theta)
. Here, for the end point, t_c = sqrt( k_c s_c / 2) = sqrt( 0.0165407 * 45.185 / 2) = 0.6113066
.
Now, WolframAlpha says, {73.915445 Sqrt[pi/2] FresnelC[0.6113066/Sqrt[pi/2]], 73.915445 Sqrt[pi/2] FresnelS[0.6113066/Sqrt[pi/2]]} =
{44.5581, 5.57259}
. (Apparently Mathematica uses a definition scaled with the additional Sqrt[pi/2] factor.)
Testing it with your functions, x
~= t --> a*(s/a)
= 45.185
, y
~= t^3/3 --> a*(s/a)^3/3 = 73.915445 * 0.6113066^3 / 3
= 5.628481
(sic! /3
not /6
, you have an error there).
So you see, using just the first term from the Taylor series representation of Fresnel integrals is not enough - by far. You have to use more, and stop only when desired precision is reached (i.e. when the last calculated term is less than your pre-set precision value in magnitude).
Note, that if you'll just implement general Fresnel integral functions for one-off scaled clothoid calculation, you'll lose additional precision when you'll multiply the results back by a
(which is on the order of 102 ... 103 normally, for roads and railways).