# Given two point clouds, what is the individual furthest point from them?

## Recommended Posts

With 5 scattered points in group A, and 5 scattered points in group B, what is the furthest point in group B from group A, not as an average, but the individually furthest point?

Sounded like an easy problem but I'm spinning wheels here. I would really appreciate some help/teachings.

##### Share on other sites

If you isolate two group of points, you can use pcfind, make the search radius like 999, and the last array element is your furthest point.

```int closept[] = pcfind(1, "P", @P, 999, 10);

i@fartestPt = closept[-1];```

Hope this could help.

Jie

Edited by jimeng20
More accurate

##### Share on other sites

Try pcfarthest() if you want. Set point group to 'B' in a point wrangle and use a sort node reversed on attribute 'dist'. It's going to be point 0 then.

```int num = npointsgroup(0, 'A');
int pc = pcopen(0, 'P', v@P, 1e5, num);
f@dist = pcfarthest(pc);```

Or if you want a detail attribute with the furthest point number try this in a point wrangle:

```int num = npointsgroup(0, grp_to);
int pts_near[] = nearpoints(0, grp_from, v@P, num);
i@pt_far = pts_near[-1];
vector pos_far = point(0, 'P', i@pt_far);
f@dist = distance(v@P, pos_far);```

Next point wrangle for evaluating maximum distance:

`setdetailattrib(0, 'dist_max', f@dist, 'max');`

Identifying furthest point by comparing against maximum distance in another point wrangle:

```if(@dist == detail(0, 'dist_max', 0)){
setdetailattrib(0, 'farthest_point', i@ptnum, 'set');
}```

pcs_dist_max.hipnc

##### Share on other sites

Thanks for the tips! These are actually really useful.

Where I’m running into a problem now is that I think I’m understanding the algorithm behind Mitchell’s Best-Candidate. I thought I was looking for the furthest point between two sets of points, once I find that point in group B, I remove the rest and repeat the process. Somehow I don’t thinks that’s actually the right approach and instead it’s to do with radius?

If you’re interested, this is what I’m trying to replicate:

##### Share on other sites

Hi, we have had a discussion on dart throwing algorithms here:

You could wrap a for loop around @anim's solution and use another pcfind_radius() to identify the furthest point among k guesses.

## Create an account

Register a new account