Jump to content

How to find closest point that hasn't already been found


j00ey

Recommended Posts

Can anyone give me a pointer as to how to approach this.

I have two point clouds with the same number of points. I want to pair the points based on proximity so that each point in each cloud is paired. The sticking point of course is that if I just do a point cloud look up and pick the closest point I get multiple points in point cloud A paired with the same point in point cloud B.

My vague idea, which sounds very clumsy and slow is to do something like this in a solver:

1 - group all points in both point clouds, say unpaired_A_grp and unpaired_B_grp

2 - For each point in unpaired_A_grp find the distance to the closest point in unpaired_B_grp and store them in an array, also store the point numbers

3 - get the indices for the distance array using argsort

4 - reorder the point numbers with the indices, set an integer nearest_point attribute on the relevant point in point cloud A and move it from unpaired_A_grp to paired_grp_A.

5 - from point cloud B look up points in paired_grp_A and if ptnum is found in nearest_point set the same attribute and move point from unpaired_B_grp to paired_grp_B.

6 - clear 

7 - repeat until all points are paired.

--

I think this would work with a small number of points but if I have a million I have to run it a million times and it sounds very slow... Any ideas greatly appreciated

Link to comment
Share on other sites

Idk if you've already solved this, but it should be relatively easy and super duper fast to do in VOPs. I haven't looked through that other thread, but off the top of my head you could do the following:

1. Give all your B points an attribute initialized to 0 (let's say "matched"=0).
2. In VOPs, find the closest B point to the current A point, and measure it against your "matched" attribute (eg, 'And "matched" < 1').
3. Then just set the closest B point's "matched" attribute to 1, so it will fail the logic test in step 2 the next time around and won't get paired again.

Hope that helps :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...