Re: lingo-l Finding the closest point from a list of points in lingo

2006-04-16 Thread Carl West
A little slow out of the blocks but maybe useful to someone anyway: For lists up to a certain size, doing the arithmetic using whole lists instead of individual elements is faster. On my machine, the first method is _way_ faster on lists with 500 or fewer items, and roughly 10% faster on

lingo-l Finding the closest point from a list of points in lingo

2006-04-11 Thread Tim Welford
Hi Guys, I'm hoping someone can help me out with a quick pointer, I've got a tight deadline and my minds gone a bit blank. I have a list of points [point(112,456), point(12,485), ...] list goes to about 50 These are actually co-ordinates of certain pixels on my stage. I need to find the

Re: lingo-l Finding the closest point from a list of points in lingo

2006-04-11 Thread Rob Romanek
Hi Tim, Just off the top of my head this might get you started (email lingo, watch for typos) on getNearestPoint aListOfPoints, aRefPoint d = the maxInteger tWhichPoint = 0 repeat with i in aListOfPoints a = aRefPoint[1] - i[1] b = aRefPoint[2] - i [2] c = a*a + b*b if

Re: lingo-l Finding the closest point from a list of points in lingo

2006-04-11 Thread Valentin Schmidt
on getNearestPoint aListOfPoints, aRefPoint ... end depending on the exact characteristics of your project, you might be able to speed up the process of finding the minimal distance (as proposed by rob) by using vectors (with z=0) instead of points, and their distanceto method. but this

RE: lingo-l Finding the closest point from a list of points in lingo

2006-04-11 Thread Pedja
Just had a bet in the pub I can get the previous script shorter:))) It's using vector maths (not sure how quick it is but it's shorter code) on getNearest pList,pCenter pStartVector = vector(pCenter[1],pCenter[2],0) pCount = pList.count if pCount 0 then pNearest = 0 repeat with y

Re: lingo-l Finding the closest point from a list of points in lingo

2006-04-11 Thread Rob Romanek
On Tue, 11 Apr 2006 21:41:33 +0200, Valentin Schmidt [EMAIL PROTECTED] wrote: but this means you first have to convert your poibnts to vectors, so it doesn't make sense if all of the points change all the time. Hey, I took Valentin's code and threw in the point to vector conversion just

RE: lingo-l Finding the closest point from a list of points in lingo

2006-04-11 Thread ken . hubbell
Quoting Pedja [EMAIL PROTECTED]: Just had a bet in the pub I can get the previous script shorter:))) It's using vector maths (not sure how quick it is but it's shorter code) on getNearest pList,pCenter pStartVector = vector(pCenter[1],pCenter[2],0) pCount = pList.count -- if