Re: distance between two 2D curves
- From: KC <kc_news@xxxxxxxxx>
- Date: Mon, 27 Aug 2007 14:30:37 GMT
Sven wrote:
Dave Bell <dbell@xxxxxxxxxxxxxxxxxxxx> wrote in message
<lmsAi.287$Sd4.281@xxxxxxxxxxxxxxxxxxxx>...
Sven wrote:points).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
some TBDThen the distance (using Pythagora's) would just beStraight-forward, simple, and fast, I agree.
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.
But that finds the closest point out of a predetermined set.
How would he find the closest point on a curve (fit toequation) through those (x,y) points?arbitrary points
Then the next step would be to find the closest pair ofon the two (TBD fit) curves.
Oh, that's easy. No, wait, sorry, it's not. ;)
LOL.
Sven, thanks for the suggestion. I really need to learn to think in vectors more for Matlab. I think in vectors on paper, but somehow haven't made the transition to vectorized code.
Sorry, I hadn't considered the 'curve fitted from points'
aspect of any of this either... I haven't really worked
much with fitted curves in matlab, but would it be possible
to just resample the fitted curve and generate 'X' new
points on the line? This way you could just use the method
above, and your accuracy would be a function of how large
you made X.
That's kind of how I was thinking of it originally. For my specific situation, I don't think I'll need the precision that would require multiple interpolations (resampling) of the curve data. I think I have enough data points already that I could just find the closest pre-existing point.
Cheers,
Sven.
-KC
.
- References:
- distance between two 2D curves
- From: KC
- Re: distance between two 2D curves
- From: KC
- Re: distance between two 2D curves
- From: Sven
- Re: distance between two 2D curves
- From: Dave Bell
- Re: distance between two 2D curves
- From: Sven
- distance between two 2D curves
- Prev by Date: Re: Errors about getting MLE when you have a lot of censoring data
- Next by Date: Re: finding distance between two points
- Previous by thread: Re: distance between two 2D curves
- Next by thread: Problem of mexw32 file
- Index(es):
Relevant Pages
|
Loading