sessionbeer Posted November 21, 2019 Share Posted November 21, 2019 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. Quote Link to comment Share on other sites More sharing options...
jimeng20 Posted November 21, 2019 Share Posted November 21, 2019 (edited) 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 November 21, 2019 by jimeng20 More accurate Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted November 21, 2019 Share Posted November 21, 2019 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 Quote Link to comment Share on other sites More sharing options...
sessionbeer Posted November 22, 2019 Author Share Posted November 22, 2019 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: https://bl.ocks.org/mbostock/1893974 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted November 22, 2019 Share Posted November 22, 2019 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.