duveil Posted June 19, 2017 Share Posted June 19, 2017 Hello , I try to create polyline between "source" points to "destination" points.I created a point group and gave selected points a color attribute value @Cd.x= 1.Then unselected points @Cd.x = 0 .I created a poly line and add vertex to the points whose srcID = 1. But I can't specify "destination" vertex to create polyline.Here is vex code I tried to put together.I appreciate if someone point me to the right direction.I couldn't figure out where I messed up. Thank in advance int ingroup = inpointgroup(0, "group1", @ptnum); if(ingroup == 1) {@Cd = set(1,0,0);} else {@Cd = set(0,0,0);} i@srcID = @Cd.x > 0.5; i@destID= @Cd.x < 0.5; i@id = @ptnum; //int dest_array[] = array(@destID < 1); int line = addprim(0,"polyline"); if (@srcID == 1){ addvertex(0,line,@id); // addvertex(0,line,0); } GeometryCreateTest_02.hiplc Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 19, 2017 Share Posted June 19, 2017 (edited) There is 4 source and 6 destination points. Is it correct? If yes, how do you want to connect them? Each source to all destinations? Source to nearest destination? Source to it's unique destination? The posted snippet can be stripped down and in terms of geometry creation it will be equivalent to: @id = @ptnum; int line = addprim(0, "polyline"); if (@group_group1) { addvertex(0, line, @id); } At this moment, it creates degenerate primitives only. Edited June 19, 2017 by f1480187 Quote Link to comment Share on other sites More sharing options...
duveil Posted June 19, 2017 Author Share Posted June 19, 2017 float srchrad = ch("searchradius"); int maxpts = chi("maxpoints"); int points[]; points = pcfind(1, "P", @P, srchrad, maxpts); foreach(int ptsphere; points) { int prim = addprim(geoself(), "polyline"); vector newpos = point(1, "P", ptsphere); int newpt = addpoint(geoself(), newpos); addvertex(geoself(), prim, @ptnum); addvertex(geoself(), prim, newpt); } Hi,thanks again man.I have worked on these settings and recreated the scene with the help of some entegma tutorial.Now I can create polyline between source and destination points. And now I am trying to filter the distance.Like if they are too close I don`t want a polyline. I guess I need to edit this line /// int newpt = addpoint(geoself(), newpos); I want to add point if the distance is more then some number which is controlled by a number on a slider.I guess I need to use pcfind again .That`s me talking to myself sorry.I stuck in this part GeometryCreateTest_05.hiplc Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 20, 2017 Share Posted June 20, 2017 (edited) You can check if the distance between @P and new position it's large enough. // Point wrangle. foreach(int pt; nearpoints(1, @P, ch("max_distance"), chi("max_points"))) { vector pos = point(1, "P", pt); if (distance(@P, pos) > ch("min_distance")) { int prim = addprim(0, "polyline"); addvertex(0, prim, @ptnum); addvertex(0, prim, addpoint(0, pos)); } } connect_point_sets.hipnc Edited June 20, 2017 by f1480187 1 Quote Link to comment Share on other sites More sharing options...
duveil Posted June 20, 2017 Author Share Posted June 20, 2017 And I owe you another beer I guess .Thanks a lot. 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.