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 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.

here a simple speed comparison:

on test
 p1 = point(1,2)
 p2 = point(6,10)
 put "points:"
 ms = the milliseconds
 repeat with i = 1 to 50000
   dq = (p1[1]-p2[1])*(p1[1]-p2[1]) + (p1[2]-p2[2])*(p1[2]-p2[2])
 end repeat
 put the milliseconds-ms

 v1 = vector(1,2,0)
 v2 = vector(6,10,0)
 put "vectors:"
 ms = the milliseconds
 repeat with i = 1 to 50000
   d = v1.distanceto(v2)
 end repeat
 put the milliseconds-ms
end

result:
-- "points:"
-- 86
-- "vectors:"
-- 30

valentin
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[email protected]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to