Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2009-03-30 09:56:11

safra
Member
Registered: 2005-12-03
Posts: 41

splines

Hi,

I have a set of points in 3D space and want to interpolate through them smoothly over a specific timespan. I searched for spline interpolation code and found some info (http://en.wikipedia.org/wiki/Cubic_Hermite_spline) and also on this forum (http://www.mathisfunforum.com/viewtopic.php?id=4092) but can't get the grasps of it.

Anyone knows of a source with code examples?

Thanks

Offline

#2 2009-03-30 12:52:25

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: splines

I think this is 2-D, but
might be a good source of info:
http://online.redwoods.cc.ca.us/instruct/darnold/laproj/Fall98/SkyMeg/Proj.PDF
It's over my head.
Also MATLAB's  interp3  is used for 3-D.
Here is something else I found in C++:
http://elonen.iki.fi/code/tpsdemo/
You can download more code on the page.


igloo myrtilles fourmis

Offline

#3 2009-03-31 00:24:02

safra
Member
Registered: 2005-12-03
Posts: 41

Re: splines

Thanks John, I quickly looked at the examples and it seems like a good start. But after thinking more about it I am not sure if typical spline interpolation is what I need?

Please look at the example below. Connecting 3 points results in something like in figure 1 with spline interpolation. Connecting 4 points results in something like figure 2 below. This is not what I need. In my case I am adding points constantly and I do not want the tangent (this is what it is called if I am right?) of the last added point to change (C in figure 2) . The angle at point C should remain the same like in figure 3. The rotation at point D should probably depend on the angle between BC and BD and the distance between CD. Then while interpolation over a timespan I need to find the points on the curve between each 2 points.

Is this indeed a type of Spline interpolation or is there another way to do this?

splines.jpg

Last edited by safra (2009-03-31 00:25:46)

Offline

#4 2009-03-31 04:28:51

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

Re: splines

You can very easily get a spline which will not effect any of the rest of the spline when adding a new point, but it is nigh impossible to get it form a continous smooth curve that would be acceptible.

However, if you allow for two extra control points around the spline, it is very simple using the catmull-rom or a generalisation of it, wherein adding an extra control point will draw one more segment with the rest of it being untouched


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#5 2009-03-31 20:29:59

safra
Member
Registered: 2005-12-03
Posts: 41

Re: splines

Thanks luca-deltodesco! Found some nice code about all of this at http://actionsnippet.com/?p=1042.

Offline

Board footer

Powered by FluxBB