0

What is the most efficient algorithm for generating a set of line segments that represent the minimum of a group of line segments (see image)?

The resulting line segments should have following properties:

  1. Do not overlap
  2. Each segment must fall within one segment of the original set
  3. No point on any segment of the original set can fall beneath it

enter image description here

9
  • Looks like you're looking for the bottom half of a convex hull? Try sorting your points based on their angle off the horizontal and connecting lines like that? If that's not it, try being more clear in your description. Commented Aug 14, 2020 at 19:24
  • @JacobSteinebronn this is not a convex hull (but a convex hull will work for the requirement) Commented Aug 14, 2020 at 19:24
  • The provided result isn't one, but by all restrictions it looks like a convex hull is correct. Commented Aug 14, 2020 at 19:25
  • 1
    Why does the resulting line not move upwards between X=250 and 300, to follow the segment that is up there? Commented Aug 14, 2020 at 20:39
  • 1
    @trincot. That was a drawing error on my part. I will fix it. Commented Aug 14, 2020 at 21:12

1 Answer 1

1

Seems like a good candidate for a sweepline algorithm.

Create a list of the segment endpoints and tag them with a begin/end flag as well as a reference to the segment. Sort the list by increasing abscissa.

Now scan the list from left to right, while you maintain an active list of segments. Any "begin" point creates a segment entry in the list, an "end" point discards it. At any time, the active list will contain a subset of the segments that are in overlapping configuration between the previous and current "event" points.

By interpolation, evaluate the ordinates at these endpoints and sort them vertically. This allows you to

  • detect the intersections (which correspond to re-orderings in the vertical list),
  • find the lowest ordinates.

Finally, you will have to sort the intersections from left to right and in the end you will have a list of subsegments that do not intersect and which are in a total order vertically.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry that I can't make a more detailed description. I can't do better without a complete implementation. I hope this will be helpful anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.