Finding nearest neighbour in point cloud?

   24128   8   0
User Avatar
Member
36 posts
Joined: 10月 2007
Offline
Hi,

I'm looking for a way to find the nearest neighbour to a point in a point cloud. As far as I understand the getneighbour() VEX function only works for points in geometry?

Thanks,
Fredrik
User Avatar
Member
192 posts
Joined: 11月 2008
Offline
Hi Fredrik. If you set the number of points to open to be 1 and the search radius to a really huge number (to ensure you'll always open one point) you'll return a handle containing only the nearest neighbor to the point position you're searching from.
User Avatar
スタッフ
2631 posts
Joined: 7月 2005
Offline
brianBurke
Hi Fredrik. If you set the number of points to open to be 1 and the search radius to a really huge number (to ensure you'll always open one point) you'll return a handle containing only the nearest neighbor to the point position you're searching from.

Brian is talking of the pcopen() function.
User Avatar
Member
36 posts
Joined: 10月 2007
Offline
Thank you for the tip.

Is there any example of how to implement this somewhere? I'm just starting to get into the vop/vex business (and Houdini help files seem pretty thin on the subject…)

Fredrik
User Avatar
Member
192 posts
Joined: 11月 2008
Offline
Yo dude. Here's two examples of finding nearest neighbors with VOPs. The first uses pcfilter() to filter the position of the nearest point in an external point cloud. The second uses pciterate(), a function which loops over the points in the handle, to return whatever neighbor you specify within the same point cloud you're in.

Be sure to check out the docs on these functions, the documentation is very good.

Attachments:
nearestpoints.hip (77.2 KB)

User Avatar
Member
58 posts
Joined: 9月 2009
Offline
Nice example, but I still cant get whats the “point in an external point cloud.”
how to connect the point node to an an external point cloud node via VOP. I check the point Normal, it seems point to no where. could you specify that more ? thank you so much.
User Avatar
Member
36 posts
Joined: 10月 2007
Offline
brianBurke
The first uses pcfilter() to filter the position of the nearest point in an external point cloud. The second uses pciterate(), a function which loops over the points in the handle, to return whatever neighbor you specify within the same point cloud you're in.

Thanks a lot for the examples. I must admit though that I'm not sure exactly how to use it, either… Say I wanted to, as a basic example, draw a line between a point in a pointcloud and its nearest neighbour, how would I make use of those Vop Sops of yours?

Sorry if this is super basic questions, but Vop is a bit tricky to get in to (just when I thought I started to get my head around those SOP nodes…)

Thanks,
F
User Avatar
Member
2 posts
Joined: 11月 2016
Offline
Hi Guys,
how could we translate this to a Vex wrangler Attribute node?

Thank you
User Avatar
Member
495 posts
Joined: 7月 2005
Offline
Hi,

check out the attached file, it is a modified version of “nearestpoints.hip” from brian.

Attachments:
nearestpointsX.hipnc (118.8 KB)

  • Quick Links