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: [mg80407] Re: [mg80382] Interpolation of data to form a parametric curve
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Tue, 21 Aug 2007 05:09:24 -0400 (EDT)
  • References: <200708201006.GAA04997@smc.vnet.net>

Hugh 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}];
>
>  
>
sol gives you a function of distance per node, n[t]. You are interested 
in the function t[n]. Now, for a given distance s, we have:

n[t[s]] == s

so,

n'[t[s]] t'[s] == 1

So, plug this equation into NDSolve, using n'[t[s]] == 
Sqrt[dfx[t[s]]^2+dfy[t[s]]^2]:

NDSolve[{Sqrt[dfx[t[s]]^2 + dfy[t[s]]^2] t'[s] == 1, t[0] == 1}, t, {s, 
0, 2.18121}]

Carl Woll
Wolfram Research


  • Prev by Date: Re: Iteratively determing successive values from previous values....
  • Next by Date: Re: Manipulate with Wrapping SetterBars
  • Previous by thread: Interpolation of data to form a parametric curve
  • Next by thread: Re: Interpolation of data to form a parametric curve