Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg80390] Re: [mg80382] Interpolation of data to form a parametric curve
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Tue, 21 Aug 2007 05:00:35 -0400 (EDT)
  • References: <19665037.1187606685838.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

Starting where you left off:

dfx = Derivative[1][fx]; dfy = Derivative[1][fy];
toArcLength =
   s /. First@
     NDSolve[{s'[t] == Sqrt[dfx[t]^2 + dfy[t]^2], s[1] == 0}, {s}, {t,
       1, nn}];
plot = Plot[toArcLength[n], {n, 1, nn}, PlotPoints -> 500]

pts = Reverse /@ Cases[plot, Line[_], Infinity][[1, 1]];
pts[[1, 1]] = 0;
max = pts[[-1, 1]]

2.18121

fromArcLength = Interpolation[pts];
Plot[fromArcLength[s], {s, 0, max}]

If the inverse (fromArcLength) isn't accurate enough, increase the  
PlotPoints option.

Bobby

On Mon, 20 Aug 2007 05:06:05 -0500, Hugh <h.g.d.goyder 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}];
>
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: Similar matrices->similar eigenvectors?
  • Next by Date: getting data for Histogram
  • Previous by thread: Re: Interpolation of data to form a parametric curve
  • Next by thread: Missing information in Mathematica 6.0 Documentation