参数化功能回旋 [英] Parameterized function for clothoid
问题描述
我编码渲染路网,其中基础上, RoadXML 格式。
I'm coding renderer for road network, which based on the RoadXML format.
这是这种格式公路曲线有四种类型:
Road curves from this format has four types:
- 段,
- 圆弧,
- 在多行,
- 克洛索弧。
和我有问题,最后一个。
And I have problem with the last one.
回旋是相同的欧拉和螺旋大角螺旋。在RoadXML克洛索弧是由三个参数给出:
Clothoid is the same with Euler spiral and Cornu spiral. In the RoadXML clotho arc is given by three parameters:
- 在开始弯曲,
- 在结束曲,
- 的长度。
有关弧线三角,我需要类似foo(T),它返回(X,Y)COORDS在t = 0..length功能。我创建了类似的方法圆弧没有问题,但我不能做它克洛索弧。
For arc triangulation I need a function like foo(t), which returns (x, y) coords for t = 0..length. I created similar methods for circle arc without problems, but I can't do it for clotho arc.
问题的部分原因是,我并不完全了解如何应用标准回旋公式开始和结束曲参数。
Part of the problem is that I not totally understand how to apply start and end curvature parameters in standard clothoid formulas.
例如,样本RoadXML道路。
For example, sample RoadXML road.
这是在红色椭圆克洛索曲线项目。它的参数:
This is clotho curve item in the red ellipse. It's parameters:
- 在开始曲率= 0,
- 在年底曲率= -0.0165407,
- 长度= 45.185。
我不知道如何实现这些参数,因为回旋的曲率从0至-0.0165是非常简单。
I don't know how to implement these parameters, because clothoid curvature from 0 to -0.0165 is very straight.
我会高兴,如果你给我这个函数的code(在C ++,C#,Java和Python或伪code)或只是一个公式,我可以code。
I will happy, if you give me a code of this function (in C++, C#, Java, Python or pseudocode) or just a formula, which I can code.
下面是我的公式:
x(t) ≈ t,
y(t) ≈ (t^3) / 6,
where length = t = s = curvature.
x(-0.0165) = -0.0165,
y(-0.0165) = -7.48688E-07.
Clotho length = 0.0165,
Source length = 45.185.
缩放坐标:
x'(l) = x / clotho_length * source_length = 45.185,
y'(l) = y / clotho_length * source_length = 5.58149E-07 ≈ 0.
x'(0) = 0,
y'(0) = 0.
因此我得到(0,0)(45,0)点,这是非常简单。
Thus I get (0, 0)...(45, 0) points, which is very straight.
在哪里是我的错?我究竟做错了什么?
Where is my mistake? What am I doing wrong?
推荐答案
让我们来看看。您的数据是:
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
根据维基百科的文章,
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 !! )
(注:我叫 A
这里的WP文章所称的倒数 A
)。然后,
(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 )
其中, C(T)
和 S(T)
是菲涅耳积分的。
所以这就是你怎么办缩放。不仅仅是 T = S
,而 T = S / A
= SQRT(THETA)
。在这里,终点, T_C =开方(k_c s_c / 2)=开方(0.0165407 * 45.185 / 2)= 0.6113066
。
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
.
现在,<一个href="http://www.wolframalpha.com/input/?i=%7B73.915445+Sqrt%5Bpi%2F2%5D+FresnelC%5B0.6113066%2FSqrt%5Bpi%2F2%5D%5D%2C+73.915445+Sqrt%5Bpi%2F2%5D+FresnelS%5B0.6113066%2FSqrt%5Bpi%2F2%5D%5D%7D"相对=nofollow> WolframAlpha的说, {73.915445的Sqrt的π/ 2] FresnelC [0.6113066 /的Sqrt的π/ 2],73.915445的Sqrt的π/ 2]菲涅尔[0.6113066 /开方的π/ 2]} =
{44.5581,5.57259}
。 (显然Mathematica使用比例与其他的Sqrt [PI一个定义/ 2]
因素。)
你的功能测试它, X
〜= T - &GT; A *(S / A)
= 45.185
是
〜= T ^ 3/3 - &GT; A *(S / A)^ 3/3 = 73.915445 * 0.6113066 ^ 3月3日
= 5.628481
(原文如此! / 3
不是 / 6
,你必须有一个错误)。
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).
所以你看,只使用第一项菲涅耳积分的泰勒级数重新presentation是不够的 - 迄今为止。你必须使用更多的,停止只有当达到所希望的precision(即当最后核算的长期低于你的pre-设置precision的幅度值)。
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).
请注意,如果你只是实现一般的菲涅耳积分功能为一次性规模回旋计算,你将失去更多的precision时,你会被乘后面的结果
(这是10的顺序 2 ... 10 3 通常,对于公路和铁路)。
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).
这篇关于参数化功能回旋的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!