Re: distance between two 2D curves
- From: Dave Bell <dbell@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 26 Aug 2007 21:24:49 -0700
Sven wrote:
KC <kc_news@xxxxxxxxx> wrote in message
<x_pAi.5842$u21.742@trnddc08>...
KC wrote:point on oneI need to calculate the shortest distance from a (known)column vectors ofcurve, to another curve. Each curve is defined by twopoints, whichdata.
Any ideas? All I can think of is a distance between twopoint which isis easy, but how to define the second point to be thechecking each pointclosest to the first (known) point?Oh, and each curve is made up of ~1000 points... so
Thanks,
-KCin curve2 with some sort of for/if loop seems quiteinefficient.
Well, if your first point is known, you can ignore that it
comes from a curve and just think about finding the closest
point in a set to your test point (its x and y coordinates).
You're right that this will be slightly inefficient in a
loop, but I think you can do it with just some vector
calculations. I'll assume that you're working in 2d (just x
and y vectors representing coordinates of your set of points).
Then the distance (using Pythagora's) would just be
something like:
distVector = sqrt((xVec-ptx).^2 + (yVec-pty).^2);
And then you can just find the minimum of this vector.
[minDist, ptIndex] = min(distVector);
2 lines and no loop required.
Cheers,
Sven.
Straight-forward, simple, and fast, I agree.
But that finds the closest point out of a predetermined set.
How would he find the closest point on a curve (fit to some TBD equation) through those (x,y) points?
Then the next step would be to find the closest pair of arbitrary points on the two (TBD fit) curves.
Dave
.
- Follow-Ups:
- Re: distance between two 2D curves
- From: Sven
- Re: distance between two 2D curves
- References:
- distance between two 2D curves
- From: KC
- Re: distance between two 2D curves
- From: KC
- Re: distance between two 2D curves
- From: Sven
- distance between two 2D curves
- Prev by Date: Re: dicominfo error
- Next by Date: Body Sensor Position Output x-coord. Only
- Previous by thread: Re: distance between two 2D curves
- Next by thread: Re: distance between two 2D curves
- Index(es):
Relevant Pages
|
Loading