Function Repository Resource:

LeeInterpolatingNodes

Source Notebook

Generate interpolating nodes from points on a curve

Contributed by: Jan Mangaldan

ResourceFunction["LeeInterpolatingNodes"][{{x1,y1,},{x2,y2,},}]

yields centripetal interpolating nodes suitable for use with Interpolation from points assumed to be lying on a space curve.

ResourceFunction["LeeInterpolatingNodes"][{{x1,y1,},{x2,y2,},},a]

yields Lee's interpolating nodes with parameter a.

Details

The parameter a is usually taken to be between 0 and 1.
Typical values of a used are:
0uniform parametrization
1/2centripetal parametrization
1chord length parametrization

Examples

Basic Examples (3) 

Generate centripetal interpolating nodes from a given set of points:

In[1]:=
pts = {{1., 2.}, {0., 1.}, {2., 0.}, {2., 2.}, {3., 3.}, {5., 2.}};
tval = ResourceFunction["LeeInterpolatingNodes"][pts]
Out[1]=

Use Interpolation to get an interpolating curve:

In[2]:=
cc = Interpolation[Transpose[{tval, pts}], Method -> "Spline"]
Out[2]=

Plot the curve along with the original points:

In[3]:=
ParametricPlot[cc[t], {t, 0, 1}, Epilog -> {Directive[AbsolutePointSize[5], ColorData[97, 4]], Point[pts]}]
Out[3]=

Scope (3) 

A set of 3D points:

In[4]:=
pts = CompressedData["
1:eJx1lHs01Hkchn/GbcY1Y2RsyShKV9V2Ia3PV1K6iFTDKkS0JdXmkkgpE5WS
UJvjFlYu1ZaQUpnvb5SuYqZk5DJjzIymQSvDFKXdzp49+98+57zn/fs57zmv
dfB+71AKQRDoezSJ/yCv/oPev63EXh9jLnzoV+GjVg+SQnP1SRtxxeacAx/w
Ku+MT27xEtxfGBns4UgjI5aar/RKHcCfIbg3X/MKzOcfPHG/VYtslQRs1aUo
sG9v6uO5yV3QYrdGYu3wF75eu3qQa96Fl5zzd2kwlcOPkxLuWsuG8Ya87Kpo
/TuY2k7ElOX0gJlLANM9XIHPpLcvrZcIIEjDU+Tl8AI0gjkg/CLAqiOs0oar
3RAXPVtAu9qJLdIcy3ZO4YNd7sz0wwNd8NTA9aw9ZwQH2SgX1Kr7oSBEOGu0
owr8Z+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LNrMHvPItc9/oaIN5k
z2S/hx1YmFtxzDZNgFu0boTdF+khwqVLUf6sF4yqwL1ujxjr3Dqivu6oi+ZT
D6QcuzcOxf5lD2Ql3ZiSo6w96UFB3YXrndZ90UV+IY3d+d3PcAU913ja+ChM
nTZptMRvAqrxkDd2/sEHNJY9MHP7IMQxW4tc1zMQxfbpJy+WBBQxFj+cD5DA
7xCcwokyR+cN3hJe9Z0Q5VNwLbOEB2VF7BdqewtUFOjs8WYvDyrGVmyX5zTj
bJY/JaiHiQa+dMSe39aEuRmcza1b5bhX16hp782JyO1S8w4Ny258dLbWSa5o
CM85mpdRBqbIvE4mpdSK8Qmb1+VbB7/iHsM+w75NRqgmcvr+Sf48fIFF+B+q
1yTHsv/kBEZoI/nwjIvJCS2wIK6fOrqbShZwojRZlz5DC9/1XkqwBLJ832iH
pXzfaf/T2wLtt+DU9uSAfnw7OEZLjiWBAcm6xNq4z06BF+XQhKXCanB/XF3g
9JpG7kgafzpk9Q3b8DjU9wOvcO+ErJLCYS1S7Zurtr+hQ04/pecXMU2G/+/n
/wakyv8F
"];

Generate an interpolating curve with uniform parametrization:

In[5]:=
c1 = Interpolation[
   Transpose[{ResourceFunction["LeeInterpolatingNodes"][pts, 0], pts}], Method -> "Spline"];
ParametricPlot3D[c1[t], {t, 0, 1}]
Out[5]=

Generate an interpolating curve with chord length parametrization:

In[6]:=
c1 = Interpolation[
   Transpose[{ResourceFunction["LeeInterpolatingNodes"][pts, 1], pts}], Method -> "Spline"];
ParametricPlot3D[c1[t], {t, 0, 1}]
Out[6]=

Applications (3) 

A set of 3D points:

In[7]:=
cpts = CompressedData["
1:eJx1lPs70wscgGfjLHUeCdXpPBVKUul0kUvE59sZorvSRTno4lJiiuQpRbqI
qFglp9ZFcktMW+Ekn68kUxK2sZWzuaZGmjEMrdPT7+d9nvd5/4PXdC9ziz+V
QqEQP6T9MO8nSnz4s1SS8hMSx3x8DHOeynHipEUrS8toZMaExTMKE9/ikkov
vaATbdikX5q4K5h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8xuuF6wz
Jcuk4JOQ6swOfAxRSvrY36kUsvJOxj3ZCxnILn6QGi4XQpHh/cC5W6lkm3sL
58O0Fkh47dNqHNkOhg8sFubH0Uj3B5VO+adEcCrSi/VQ0ANLL2cuxCIaybVx
Da2RvQHzRc31sZsHIMi4dJ8qjErmTwPj9JjncOZsdeesQDUMPHH19zD6jkUv
4wrrFuQAGluuZDC/g+Zb7SxR0xBS9pbMPzbsjpoAvU1UFyphdL/Oyz5Wjg+H
+ZldFrlozRH32/fSiL4dGH7e5g36i/vCF7uW41PVNV7Eem3i/bAZg93XBD1h
XIWJfS2aGDTOPL+RRtRmDfgej+uBCPnkKu8xIf7utUcnREkhHMP4UcuODIK8
rk8LL0uQfi2+ZUvYKJjrOhjXXFfDOYnjnSOOEkw/4B6dtE0BE3c47B8eHYeD
yarJJk0N+Iz/jr9H2ABixunG0CQNrMho5R2I4aHjS9az6ksyzC9v7aGu08B7
zeyjLZoKOKI28w0LGMBz1V4crs042KXVTmbdEkLezCy/d2/H8f5z+XWaxwiw
I0sti9USWCSKCdFFLXLT5YbxkmIlJNvRspU5Yjj66nsepZRGbl+xTdeP0Q1s
TeATuaUA3Nobg956apMlG2IEs6xfw5k84l21Mx/0gif2rGHRyJsv6bZasWI8
UTvvvunxElDPeRLpcVeLZAUITpZTFTgaXyJOTL8Hpy7dGpLWfsM9CoG83lON
e6JDMrjLLmC3lGW6NG8Yq3PDLPkxFPKZufvs3XYc/L/P/wdogDkU
"];

Generate the corresponding knots and control points for a B-spline curve:

In[8]:=
With[{deg = 3, n = Length[cpts]},
  tvals = ResourceFunction["LeeInterpolatingNodes"][cpts];
  kp = Join[ConstantArray[0, deg + 1], MovingAverage[ArrayPad[tvals, -1], deg], ConstantArray[1, deg + 1]];
  cp = LinearSolve[
    Table[BSplineBasis[{deg, kp}, j - 1, tp], {tp, tvals}, {j, n}], cpts]] // Short
Out[8]=

Visualize the B-spline curve and the points:

In[9]:=
Graphics3D[{{Directive[ColorData[97, 1], AbsoluteThickness[2]], BSplineCurve[cp, SplineDegree -> 3, SplineKnots -> kp]}, {Directive[ColorData[97, 4], AbsolutePointSize[6]], Point[cpts]}}, PlotRange -> All]
Out[9]=

Neat Examples (1) 

Demonstrate the effect of varying the parameter for the Lee interpolating nodes:

In[10]:=
Manipulate[
 With[{iF = Interpolation[
     Transpose[{ResourceFunction["LeeInterpolatingNodes"][pex, a], pex}], Method -> "Spline"]},
  ParametricPlot[iF[t], {t, 0, 1}, Epilog -> {Directive[AbsolutePointSize[5], ColorData[97, 4]], Point[pex]}, Sequence[
   Frame -> True, PlotRange -> {{0, 31}, {0, 31}}, PlotRangePadding -> Scaled[0.05]]]], {{a, 1/2}, 0, 1}, Initialization :> (pex = {{0., 0.}, {1.34, 5.}, {5., 8.66}, {10., 10.}, {10.6, 10.4}, {10.7, 12.}, {10.7, 28.6}, {10.8, 30.2}, {
     11.4, 30.6}, {19.6, 30.6}, {20.2, 30.2}, {20.3, 28.6}, {20.3, 12.}, {20.4, 10.4}, {21., 10.}, {26., 8.66}, {29.66, 5.}, {31., 0.}};), SaveDefinitions -> True]
Out[10]=

Version History

  • 1.0.0 – 05 April 2021

Source Metadata

License Information