Click here to Skip to main content
16,016,527 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
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:
VB
''' <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
Posted
Comments
Richard C Bishop 18-Apr-13 15:24pm    
I don't have any input to help you, but would you mine briefly explaining why you would even need something like this? I am curious as I have no idea.
Kenneth Haugland 18-Apr-13 16:06pm    
It is a little expantion of this:
http://www.codeproject.com/Articles/457985/WPF-Drawing-Canvas-Control

It is normally used to draw roads and trainstreaches, so I thought Id use it and try it out. IT basically creates a smooth increse in acclereration along the curve, so it is a preferred construction technique.
Richard C Bishop 18-Apr-13 16:54pm    
Nice article, even though it is beyond me at this point in my understanding.
Kenneth Haugland 19-Apr-13 1:23am    
To be hounest I would change a ting or two if you should want to use it. So, Im thinking of updating it in sutch a way that it is easily expandable, which it is currently not.

1 solution

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
 
Share this answer
 
v2
Comments
Kenneth Haugland 18-Apr-13 16:19pm    
It looks good, I'll read through it first, then I'll mark it as the answer if I succseed :) Oh, I 5'ed it :)
Espen Harlinn 18-Apr-13 16:32pm    
Thanks Kenneth - it should work well enough since it seems that you should be able to visualize the clothoid in terms of path primitive elements like lines, arcs and splines.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900