How do I insert/add points to a line.

   8264   10   0
User Avatar
Member
27 posts
Joined: Oct. 2015
Offline
I want to split an line/edge based on point attributes.
How would I add points to an existing line/edge?
I want to do it in VEX, but if If there are other non-VEX methods I would love to learn about those aswell.
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
I know of two ways you can do that, but I can't show you based on not knowing what are your attributes you plan on using and how you want to apply them specifically.

Provide a hip with your attempt or as far as you can get with your intention.

Because you could create a new polyline between each point, or do you want to keep the original polyline and only place new points on that line ( not having any affinity with the primitive polyline except by location ).

There may be different reasons why you might want to do it one way or the other, depending on your plans downstream.
User Avatar
Member
27 posts
Joined: Oct. 2015
Offline
Ok, this is my situation. I have lines with uniformly distributed points. I must raycast the point positions onto a landscape along the y axis. At the landscape slopes, the distance between the points increases, therefore I would like to sortoff subdivide that part of the line.



I would like the new point to actually be part of the line, if posible.
Edited by soma wheels - Aug. 15, 2018 15:43:04
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
You don't need to run that through a vex wrangler as you haven't said what the condition/s are for when to add the point and where ( halfway/some ratio of distance).

Otherwise you could just simply create the initial projected line and run it through a resample node - that's the most simplest.

I will do a vex for you later just for your curiosity; Unless someone else does.
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
yeah - resample then re-project…
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
27 posts
Joined: Oct. 2015
Offline
Thanks for your awnswers. I had attempted to use the resample node before, but it did not work the way I wanted. After fidling with the settings, it is working now.
I am certainly still interested to learn how I add points to line in vex though. In my case the condition would the line legth.
Edited by soma wheels - Aug. 15, 2018 18:13:18
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
Ok..so in the attached hip…two examples - one in the red colored netbox and one in the green.

For the red netbox:

One the most simplest of showing some steps to get a new point for a line.

With this method you basically have to remove the line and keep the points, then add the new points and create a new line out of them all.

In this example it's never something you want to do as I have it - but there might be some steps you could use in other workflows.

Keep in mind too that the steps shown could be mixed with sop nodes; like delete and if you need to order your points the sort node.

So just remember that the example is just to show some workings of the various vex functions and not the whole workflow.

For the green netbox:

In this example adding a point to the line is not necessary because your determining what the final ‘line’ is going to be first.

And perhaps this is a good example when working with vex - that doing things upstream can save you steps downstream. Like in this example if I created the new projected line first and then added new points afterward - I'm creating uneccessary work.

In this example I've created a parameter called “Distance Threshold” which is on the vex wrangle node “Projected_Lines_via_Vex”.

This will only add a new point between two points of the anticipated projected line if the distance is greater than a certain distance.

And it doesn't use the ray sop - instead making use of the intersect function.

Attachments:
Adding points to projection.hiplc (125.3 KB)

User Avatar
Member
27 posts
Joined: Oct. 2015
Offline
Thanks very much BabaJ. Its amazingly fast - works really well in that regard. Although, its not very accurate on the steep slopes; I am pretty new to programming and houdini so il need to spend some time studying this to realy understand it.
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
What do you mean that it's not very accurate on the steep slopes? When the points are added on the slopes that pass the threshold they are exactly midpoint.

So what is it that you want to be more ‘accurate’?
User Avatar
Member
27 posts
Joined: Oct. 2015
Offline
Ah, it is acurate, sorry, My bad. It looked like something was wrong because when the slope is so steep that it requires 2 or 3 points to be added to one edge, the vex wrangle still only cretaes one point.
Edited by soma wheels - Aug. 16, 2018 10:23:26
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
“..because when the slope is so steep that it requires 2 or 3 points to be added to one edge, the vex wrangle still only cretaes one point…”

Hopefully there is enough going on in the vex wrangle/hip file to show you that if only adding a midpoint under a certain condition is not enough and you need something more ‘elaborate’ you could do so;

Just takes a bit more coding.
Edited by BabaJ - Aug. 16, 2018 11:28:27
  • Quick Links