Forgot password?

Create an account!

Forum

« back

RhinoScript – nearest neighbor

Messages

Please log in to write a message.

  • 2. Hanno (Oct 17, 2009 12.34):

    Hi,

    there is a method called rhino.PointArrayClosestPoint which does exactly what you need.

    Regards

    Hanno

  • 1. moos_7 (Oct 16, 2009 00.00):

    hi all,

    I have for example 10 point, with a testpoint x. I want to know for each point the closest neighbor, without using Voronoi. I did some research in Algorithms in Nutshell, but I can't translate it to vbs script. Can someone help me.

    How can I use the code below in rhinoscript, I cant make the translation.

    thank you.

    gr.
    moos

    nearest (node,min,x)
    d=distance from x to node.point
    if (d<min) then
    result=node.point
    min=d
    dp=perpendicular distance from x to node
    if (dp<min) then
    pt=nearest(node.above,min,x)
    if (distance from pt to x<min) then\
    result=pt
    min=distance from pt to x
    else
    if(node is above x) then
    pt=nearest(node.below,min,x)
    if (pt exist) then return pt
    return result
    end
Recommend

Why are these buttons gray?