Divide curve by equal distance

Sorry for bumping up this old thread, but I had this problem and started to code a solution, then I found this thread but I’m not sure of if the problem was solved already?

For my own part I have need for a single simple component since I often need these straight segments, so I coded a single component for this, and no surprise, I also encountered all the tricky cases discussed in this thread. I have not tried all the solutions posted here but I post mine as well.

My single component finds the segments of a set length using circles (most common strategy I guess) and optionally it auto-extends the segment length (input Extend = true) to cover the full length of the curve (within document tolerance).

Fig 1. The component.
bild

Fig 2. Dividing the curve segements using circles (from left to right). It avoids getting messed up at self intersections. Here the segments are not extended.

Fig 3. Here the curve segments are extended to cover the entire base curve. The numerous circles indicates that the component iterates extending the circle radius until it ends up within tolerance distance from the end of the curve. Red and green points indicate the different segments landing points after extending.

Sometimes it happens that the algorithm goes bananas when it extends too much (the radius inflates more than needed to consume the rest-distance to the curve end), then the Refine option fixes it by iterating with smaller increments when extending. This seems to work in most cases (haven’t seen it fail in my testcase):

Fig 4. Here the circles has “inflated/extended too much” (this problem was fixed above by activating the Refine option) because it missed the tolerance +/- interval at the curve-end, and therefore the iterator didn’t stop until it reached a max_iterations guard in the algorithm (I have yet to figure out how to detect a miss so I can revert it, but at least the Refine option can handle it after the fact.

Fig 5. Here the end segment which reached the end of the base curve.

Fig 6. One of the tricky things was to avoid “jumps” over selfintersections or “shortcuts” at tight loops. Here the segments attach to the curve without shortcutting, as long as the segment lengths fits into the loop:

The component:
DivideCurveByStraightSegments.gh (24.1 KB)

// Rolf

4 Likes