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 pCount > 0 then
>     pNearest = 0
>     repeat with y = 1 to pCount
>       pVector = vector(pList[y][1],pList[y][2],0)
>       pTemp = pVector.distanceTo(pStartVector)
>       if pTemp < pDistance then
>         pNearest = y
          pDistance = pTemp
>       end if
>     end repeat
>
>     return pNearest
>   --end if
> End
>

or


> on getNearest pList,pCenter
>   pStartVector = vector(pCenter[1],pCenter[2],0)
    pDistance = 99999999999
>     repeat with y in pList
>       pVector = vector(y[1],y[2],0)
>       pTemp = pVector.distanceTo(pStartVector)
>       if pTemp < pDistance then
>         pNearest = pVector
          pDistance = pTemp
>       end if
>     end repeat
>
>     return pNearest
> End

- Ken
[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