绘制一个回旋样条 [英] Drawing a clothoid spline

查看:91
本文介绍了绘制一个回旋样条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个相当奇怪的问题,但无论如何,我需要一个算法,在A和B之间存在一条直线,并且在C之间的线的左边或右边的点C内插值。我想要实现的算法通常称为G2插值,使用欧拉螺旋。



我发现了一篇文章,概述了我想要使用的算法:

http://www.ams.org/journals/mcom/1992-59-199/S0025- 5718-1992-1134736-8 / home.html [ ^ ]



但是实现它似乎非常复杂。我的问题很简单,是否有人知道是否有更复杂的(或者如果你愿意的话,是假想的)探索这个(或可能是一些代码)可以解释实际做什么。我是否必须选择一些值或者它是一个独特的实现?



到目前为止,我刚刚找到了菲涅耳积分的算法:

This is a rather strange question but here goes anyway, I need an algorithm that interpolate values given that there is a straigth line between A and B, and the point C that is either to the left or right of the line between A and B. The algorithm I want to implement is often called a G2 interpolation, using an Euler spiral.

I found an article that outlines the algorithm that I want to use:
http://www.ams.org/journals/mcom/1992-59-199/S0025-5718-1992-1134736-8/home.html[^]

However it seems to be extremely complicated to implement. My question is simply, does anybody know if there either exists a more elaborate (or for dummies if you''d like) explination of this (or possibly some code) that could explain what to actually do. Do I have to choose some of the values or is it a unique implementation?

So far I have just found an algorithm for the Fresnel integrals:

''' <summary>
       ''' Source code is converted from Michael Moser given in "Engineering Acoustics - An introduction to noise control" pages 342 - 343, 10.11 Appendix: Matlab program for Fresnel integrals
       ''' </summary>
       ''' <param name="xarg">The x argument of the Sin and Cos functions inside the Fresnl integrals</param>
       ''' <returns>A Double(2), were Double(0) is the Cos_Fresnel and Double(1) is the Sin_Fresnel integrals</returns>
       ''' <remarks></remarks>
       Public Function FresnelIntegral(ByVal xarg As Double) As Double()
           Dim result(2) As Double
           Dim x, arg, s, c, cfrenl, sfrenl As Double

           x = Math.Abs(xarg) / Math.Sqrt(Math.PI / 2)
           arg = Math.PI * (x ^ 2) / 2

           s = Math.Sin(arg)
           c = Math.Cos(arg)

           If x > 4.4 Then
               Dim x4, x3, x2, x1 As Double
               x4 = x ^ 4
               x3 = x ^ 3
               x2 = 0.10132 - 0.154 / x4
               x1 = 0.3183099 - 0.0968 / x4

               cfrenl = 0.5 + x1 * s / x - x2 * c / x3
               sfrenl = 0.5 - x1 * c / x - x2 * s / x3

               If xarg < 0 Then
                   cfrenl *= -1
                   sfrenl *= -1
               End If

           Else
               Dim a0, sum, xmul, an, nend, xnenn, an1 As Double
               a0 = x
               sum = x
               xmul = -((Math.PI / 2) ^ 2) * (x ^ 4)
               an = a0
               nend = (x + 1) * 20

               For n As Integer = 0 To nend
                   xnenn = (2 * n + 1) * (2 * n + 2) * (4 * n + 5)
                   an1 = an * (4 * n + 1) * xmul / xnenn
                   sum += an1
                   an = an1
               Next


               cfrenl = sum
               a0 = (Math.PI / 6) * x ^ 3
               sum = a0
               an = a0
               nend = (x + 1) * 20

               For n As Integer = 0 To nend
                   xnenn = (2 * n + 2) * (2 * n + 3) * (4 * n + 7)
                   an1 = an * (4 * n + 3) * xmul / xnenn
                   sum += an1
                   an = an1
               Next

               sfrenl = sum

               If xarg < 0 Then
                   cfrenl *= -1
                   sfrenl *= -1

               End If

           End If

           result(0) = cfrenl
           result(1) = sfrenl

           Return result
       End Function

推荐答案

尝试DJ的受控的回旋样条 Waltona和DS Meek。



与许多关于回旋物的其他论文相比,它实际上相当可读:



通过用在其最高曲率点处连接的一对回旋曲线替换每个抛物线段来引入回旋花键的控制折线,以便在连接处保持单位切向量和曲率的连续性。回旋曲线比多项式曲线灵活性差,因此在某些情况下,直线段沿着相应控制顶点的较长相邻边缘附加到回旋线对上。



等......



发布于Computers&图形29,第353-363页。



你也可以看看Raph Leviens'' Spiro [ ^ ]将平行线转换为béziers。 (我知道我以前见过这样的东西,我记得在那里花了一段时间......)



祝你好运

Espen Harlinn
Try "A controlled clothoid spline" by D.J. Waltona and D.S. Meek.

It''s actually fairly readable compared to many of the other papers on clothoids:

A control polyline for a clothoid spline is introduced by replacing each parabolic segment by a pair of clothoids joined at their point of highest curvature such that continuity of the unit tangent vector and curvature are preserved at the join. The clothoid is less flexible
than a polynomial curve, so in some cases a straight line segment is appended to the clothoid pair along the longer adjacent edge of its corresponding control vertex.

and so on ...

It was published in Computers & Graphics 29, pages 353–363.

You could also have a look at Raph Leviens'' Spiro[^] which converts clothoids into béziers. (I knew I had seen something like this before, it just took a while before I remembered where ... )

Best regards
Espen Harlinn


这篇关于绘制一个回旋样条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆