Create Polyline From Source To Destination

Recommended Posts

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.

```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);

if (@srcID == 1){
} ```

GeometryCreateTest_02.hiplc

Share on other sites

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;

if (@group_group1)
{
}```

At this moment, it creates degenerate primitives only.

Edited by f1480187
Share on other sites

```float srchrad = ch("searchradius");
int maxpts = chi("maxpoints");
int points[];

points = pcfind(1, "P", @P, srchrad, maxpts);

foreach(int ptsphere; points)
{
vector newpos = point(1, "P", ptsphere);
}```

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

Share on other sites

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"))
{
}
}```

Edited by f1480187
Share on other sites

And I owe you another beer I guess .Thanks a lot.

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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×