Re: How can I find the closest distance between a specified point and an interpolation curve?

• To: mathgroup at smc.vnet.net
• Subject: [mg27283] Re: How can I find the closest distance between a specified point and an interpolation curve?
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Sun, 18 Feb 2001 02:52:16 -0500 (EST)
• References: <96is0i\$dg6@smc.vnet.net> <pRIj6.5848\$Rl5.43715@ralph.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Erich,
Unfortunately, the use of the interpolation function spoils this approach.
Even if the interpolation is linear -- when we will be looking for the
nearest point on the line joining the points.

Example:

pt = {0,0}
PointSet = {{-1,0}, {1,0}}

But the FindMinimum method (Seth Chandler, Rasmus Debitsch) works:

bestpoint[ptset_,pt_]:=
With[{fc=Interpolation[ptset]},
ffc=fc;
FindMinimum[With[{d={x,fc[x]}-pt},Sqrt[d.d]],
Join[{x},{Min[First/@ptset],Max[First/@ptset]}]]]

bestpoint[PointSet, pt]

Interpolation::inhr: Requested order is too high; order has been
reduced to {1}.

{0., {x -> 0.}}

Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Erich Mueller" <emuelle1 at uiuc.edu> wrote in message
news:pRIj6.5848\$Rl5.43715 at ralph.vnet.net...
> Here is a brute force way:  First calculate the square of the distance
> from each point in "Pointset" to the given point
>
> distset = (# - pt).(# - pt) & /@ Pointset
>
> The result is
>
> {50, 52, 85, 101, 170, 293, 409, 1274}
>
> So the closest point is {0,0}.
>
> Erich
>
> On 16 Feb 2001, liwen liwen wrote:
>
> > Dear friends,
> > Here is a curve that is produced by
> > Interpolation[PointSet] function,
> > Pointset={{0,0},{1,1},{3,4},{4,5},{6,8},{7,12},{8,15},{12,30}}.
> >
> > Fc=Interpolation[PointSet].
> > the specified point is:
> > pt={5,-5}
> > I want to find the closest distance between the point
> > of pt and Fc ?
> >
> >
> > Best regards,
> >              Liwen    2/15/2001
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail - only \$35
> > a year!  http://personal.mail.yahoo.com/
> >
> >
>
>

```

• Prev by Date: Out of Memory. Exiting.
• Next by Date: Re: numerics
• Previous by thread: Re: How can I find the closest distance between a specified point and an interpolation curve?
• Next by thread: Q: How to plot field lines?