MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Interpolation of data to form a parametric curve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80386] Re: Interpolation of data to form a parametric curve
  • From: Januk <ggroup at sarj.ca>
  • Date: Tue, 21 Aug 2007 04:58:30 -0400 (EDT)
  • References: <fabp69$5p4$1@smc.vnet.net>

Hi Hugh,

Personally I find it easier to create a table of point number to
distance and then use that to create an interpolating function that
gives you point number for a given distance.  In other words, I'd use
something like:

fx = Interpolation[d[[All, 1]]]
fy = Interpolation[d[[All, 2]]]
arcLengthTable = Table[{nt, NIntegrate[ Sqrt[(fx'[n])^2 + (fy'[n])^2],
{n, 1, nt}]},  {nt, 1, Length[d], 1}];
ns = Interpolation[RotateRight[arcLengthTable, {0, 1}]];
Show[
 ParametricPlot[{fx[ns[s]], fy[ns[s]]}, {s, 0,
Max[arcLengthTable[[All, 2]]]}],
 ListPlot[d]
 ]

Hope that helps,
Januk

On Aug 20, 6:08 am, Hugh <h.g.d.goy... at cranfield.ac.uk> wrote:
> Below I give some example data for a 2D curve. I then interpolate the
> x and y data to give a parametric version of the curve. This works
> well as the plot shows, and I could also use the Spline package.
> However, this data is parameterized with respect to point number while
> I need the data parameterized with respect to distance along the curve
> or alternatively as a distance going from 0 to 1. I can see how to get
> distance in terms of point number, by using NDSolve, but how do I get
> the inverse -point number in terms of distance? If I have point number
> in terms of distance then presumably I can rework the interpolation as
> a new function. Any suggestions?
> Thanks
> Hugh Goyder
>
> d = {{0., 1.2}, {0.180347569987808,
>     1.1598301273032612}, {0.31554453682333494,
>     1.0539181001894673}, {0.37759261784475534, 0.9204838518536992},
>        {0.3662469376233495, 0.8067797622536416}, {0.3090169943749474,
>     0.7510565162951535}, {0.2505675022261833, 0.767973087013262},
>        {0.23556798830604195,
>     0.8430236535910302}, {0.2915423708426846,
>     0.938110078918853}, {0.418269744520502, 1.0061313243770045},
>        {0.5877852522924731, 1.0090169943749474}, {0.7549810402071845,
>     0.9323166416507785}, {0.8747584091877195, 0.7907720262964009},
>        {0.9191799306804422, 0.6227437070536992}, {0.8880702932342837,
>     0.4756205908737}, {0.8090169943749471, 0.387785252292473},
>        {0.7267708750435204, 0.37402339610400703}};
>
> nn = Length[d];
>
> fx = Interpolation[d[[All, 1]]];
> fy = Interpolation[d[[All, 2]]];
>
> ParametricPlot[{fx[n], fy[n]}, {n, 1, nn},
>  Epilog -> {Point[#] & /@ d}, AspectRatio -> Automatic]
>
> (* Get distance in terms of point number *)
>
> dfx = Derivative[1][fx]; dfy = Derivative[1][fy];
>
> sol = NDSolve[{Derivative[1][n][t] == Sqrt[dfx[t]^2 + dfy[t]^2],
>     n[1] == 0}, {n}, {t, 1, nn}];




  • Prev by Date: Re: Intensive numerical calculations
  • Next by Date: Re: Similar matrices->similar eigenvectors?
  • Previous by thread: Re: Interpolation of data to form a parametric curve
  • Next by thread: Re: Interpolation of data to form a parametric curve