Jump to content

Placing points on a curve with even vertical spacing


Recommended Posts

I'm trying to place points on specific edges of input polygons. These edges are not necessarily linear, some have bends in them. However, the edges are guaranteed to not overlap themselves horizontally. If you start at one end of the edge and proceed to the other end, the y value of your position will always go up or always go down. In other words, the specific edges I'm working with can be shaped like "l", "<", or "/", but not "V", "^", "_", or "N". They will also never be more than 45 degrees away from vertical. I would like to place points on these edges so that there is a point on the top, on the bottom, and evenly spaced vertically in between. As in, if you proceed from point to point along the edge, the difference in the y value of the position of the current and previous point is always equal, regardless of how far each point moves laterally.

You might be thinking, "Just use resample with 'Even Y Segments'," but that takes the points where the edge bends into account. For example, if I have an edge made of a segment that goes 1 unit up and to the left, followed by another segment going two units up to the right, and I try to put 3 points on it, I get 5 points total: the top and bottom, the point where the curve happens, and one each halfway from the curve point to the top and bottom. What I would want instead is one at the top, one at the bottom, and one halfway up the total distance, placed on the longer segment half a unit up from the bend point.

Currently I'm putting my target edges in a group, then using a Dissolve SOP targeting all edges not in that group, with "Create Curves When Dissolving Boundary" checked. That makes a curve matching my edges. I then loop through those curves, where I have a primitive VOP that does all the math determining how many points I want along the edge and makes that minus one the "num_segments" attribute of the primitive. Then I run it through a Resample SOP with "Allow Primitive Attributes to Override Parameters" checked. If I checked "Remove Inline Points" on my Dissolve, it gives me a straight line from the start to the end of the edges, albeit one with all the points I need spaced out correctly. If I could somehow snap those points to the original curve again in a way that only allowed them to move horizontally when snapping, that would solve my problem. Alternately, if I leave "Remove Inline Points" unchecked on my Dissolve SOP, I get a curve matching the edge exactly, but each segment of the edge is divided into my target number of points instead of the complete edge. If I could get that to use the whole collection of edges instead of each edge segment individually, that could also solve my problem. Or, maybe there's a really easy solution to my problem and I'm way off base. Any ideas?

Link to comment
Share on other sites

Hey Ellyfish!

I think I have a solution for ya!

First I grouped the original points to delete later, then got the max Y by attrib promoting to detail.

The bulk of the work is happening in the loop, where I use the clip sop linked to the iteration of the loop to make the evenly spaced points.

The # of iterations is controlled by the max Y / clip distance.

Finish up by deleting the old points.

I hope this is what you were looking for!

curveYslice.hip

(The exact shape of the original curve isn't preserved as we're blasting those points away, if you want to keep that shape just omit that part)

Edited by coltonmil
Link to comment
Share on other sites

bit late to the party....but wasn't that hard...

You control how many 'segments' you want in the copy node.

(haven't bothered to line up the cutters with the bottom of the curve, I assume it starts at 0....but I'm sure you can adjust this if your curve doesn't start at origin...this is just a proof of concept)

evenspacedY.hipnc

Edited by Noobini
Link to comment
Share on other sites

ok @Ellyfish,

I know where you gone wrong...

You were on the right track all along...ie. simply resample with even Y segsments....but you forgot one tiny detail....and that is to untick the Resample by Polygon Edge.

Once you do that...all you need is.........nothing else...

(space+4 in viewport to go to Right view, then dial in to your heart's content the number of segments...they remain even....space+1 to go back to perps)

evenspacedY3.hipnc

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...