Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: How to Calculatelength of an Spline curve between two

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104830] Re: [mg104819] How to Calculatelength of an Spline curve between two
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Wed, 11 Nov 2009 04:27:17 -0500 (EST)
  • References: <200911101104.GAA20038@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

Here's an example:

xvals = Flatten@{0, Sort@RandomReal[{0, 2 Pi}, 30], 2 Pi};
tbl = Table[{x, Sin@x + .05 RandomReal[]}, {x, xvals}];
sp = Interpolation[tbl, Method -> "Spline"];
Show[ListPlot@tbl, Plot[sp@x, {x, 0, 2 Pi}], PlotRange -> All]

(Warning: splines can have VERY wild fluctuations.)

Next solve for the curve length, from 0 to any x:

Clear[x, len]
len = len /.
   First@NDSolve[{len'[x] == Sqrt[1 + sp'[x]^2], len[0] == 0},
     len, {x, 0, 2 Pi}];

Plot[len@x, {x, 0, 2 Pi}]

Compute the arc length between two points:

len[.7] - len[.2]

1.00597

Bobby

On Tue, 10 Nov 2009 05:04:30 -0600, alfaeco <alfaeco at gmail.com> wrote:

> I need some help.
>
> Given an Interpolating function with method-> Spline.
>
> sp = Interpolation[tbl, Method -> "Spline"];
>
> How can I calculate the distance between two arbitrary points of the
> splines?
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: strange behavior
  • Next by Date: Re: How to Calculatelength of an Spline curve between two
  • Previous by thread: How to Calculatelength of an Spline curve between two points?
  • Next by thread: Re: How to Calculatelength of an Spline curve between two