joulejang2012 Posted August 20, 2016 Share Posted August 20, 2016 Hey everyone! First time posting I have a variable number of groups of points, and I want each point to find its nearest neighbor in every group that is not its own. I know pcopen() takes in either an Opinput or a filename, so I was wondering if there is a way to somehow dynamically set inputs to take in groups or if there is a way to export groups of points to a file without manually having to delete non-selected on each group and exporting them individually with the file sop. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted August 21, 2016 Share Posted August 21, 2016 If groups don't overlap, convert groups to name attribute using Name node and then use nearpoint function: // Point wrangle. i@near = nearpoint(0, "!" + s@pt_group_name, @P); // Test. int prim = addprim(0, "polyline"); addvertex(0, prim, @ptnum); addvertex(0, prim, @near); Effect is pretty nice on clustered geo. exclude_itself_group.hipnc Quote Link to comment Share on other sites More sharing options...
joulejang2012 Posted August 21, 2016 Author Share Posted August 21, 2016 Is there no way to do this using point clouds? Quote Link to comment Share on other sites More sharing options...
f1480187 Posted August 21, 2016 Share Posted August 21, 2016 (edited) Here is pcfind signature accepting a group. I think it is an equivalent of the nearpoints function, which also return an array. int [] pcfind(int inputnum, string ptgroup, string Pchannel, vector P, float radius, int maxpoints); If you really meant pure VEX solution, without converting stuff, use something like this: // Point wrangle. string groups[] = detailintrinsic(0, "pointgroups"); foreach (string group; groups) { if (inpointgroup(0, group, @ptnum)) { i@near = pcfind(0, "!" + group, "P", @P, 1e10, 1)[0]; // Test. int prim = addprim(0, "polyline"); addvertex(0, prim, @ptnum); addvertex(0, prim, @near); // Exit loop. break; } } It will act similar. Just a bit more code. exclude_itself_group_pcloud.hipnc Edited August 21, 2016 by f1480187 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.