forum.alglib.net
http://forum.alglib.net/

Spline1d Calc question
http://forum.alglib.net/viewtopic.php?f=2&t=3
Page 1 of 1

Author:  esebsal [ Fri May 07, 2010 8:12 pm ]
Post subject:  Spline1d Calc question

Hi community!,
I'm new on spline algorithm. I don't have enough experience.
I'm developing an application in VB6 that should interpolate some specific points entered by the user (click with mouse) on a picture control.
The point entered should respect the same order that they have been marked.
i.e. on the images attached the user enter 4 points (P1,P2,P3,P4) marked in order, means first mark P1, second mark P2 and so on..
I tried to use Akima interpolation , so I'm using the VBA function Spline1DBuildAkima(X, Y, N, C).
I plot the curve starting from P1 and ending to P4.

I attached two examples depending on the position of P4. In the example1 everything goes OK, no errors.
But in the example2 I got an error. From P1 to P3 the plot is OK, when I tried to plot the segment P3 to P4 I got an error divided by zero.

I have dubs respect the spline. Should I use 2 differts splines from P1 to P3 , and from P3 to P4 use anothe spline.
is it posible to interpolate a close circle with Akima interpolation

thanks for all.
Sebasti?n.

Attachments:
File comment: example2 got error division by zero whe trying to calc P4
spline1d_example2.jpg
spline1d_example2.jpg [ 4.25 KiB | Viewed 6288 times ]
File comment: example1 everything goes ok. no erros
spline1d_example1.jpg
spline1d_example1.jpg [ 4.16 KiB | Viewed 6288 times ]

Author:  Sergey.Bochkanov [ Sat May 08, 2010 8:07 am ]
Post subject:  Re: Spline1d Calc error

esebsal wrote:
I have dubs respect the spline. Should I use 2 differts splines from P1 to P3 , and from P3 to P4 use anothe spline.
is it posible to interpolate a close circle with Akima interpolation

Cubic splines implemented in ALGLIB aren't suited for problems with overlapping segments, i.e. for problems where interpolant is circle-like (example2). Example1, from the other side, is perfect illustration for the kind of problems which may be solved with cubic splines.

What you need is parametric cubic spline, i.e. spline where two separate interpolants are constructed: one for points on the X-axis, another for the Y-axis. You may find more info on parametric spline in the good online book by Tom Lyche and Knut Morken: http://folk.uio.no/in329/nchap1.pdf and http://folk.uio.no/in329/nchap6.pdf

P.S. I think that I'll include parametric splines in the next release of ALGLIB.

Author:  esebsal [ Sat May 08, 2010 2:28 pm ]
Post subject:  Re: Spline1d Calc error

thank you very much Sergey.
Rgds. Sebasti?n.

Author:  Doug Jenkins [ Thu May 27, 2010 11:33 pm ]
Post subject:  Re: Spline1d Calc question

Sergey - thanks for the book link. Very interesting. For anyone wanting the whole book, it is available here:
http://folk.uio.no/in329/komp.html

Esebsal - you might be interested in some VBA code on my blog, which should do what you want:

http://newtonexcelbach.wordpress.com/20 ... l-splines/

The cardinal spline will work for curves where the x values are not all increasing.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/