I'm looking for a way to find all segments of a polygon that is divided by lines between some of its points.
Here are two examples to illustrate what I'm trying to achieve:
So my data and desired output looks like this:
Example A:
Outline: [P1, P2, P3, P4]
Divisions: [P1, P3]
Expected Result:
Segment A [P1, P2, P3]
Segment B [P1, P3, P4]
Example B:
Outline: [P1, P2, P3, P4, P5, P6, P7]
Divisions: [P1, P3] and [P1, P6] and [P3, P6]
Expected Result:
Segment A [P1, P2, P3]
Segment B [P1, P3, P6]
Segment C [P1, P6, P7]
Segment D [P3, P4, P5, P6]
Please note that there will never be any crossing lines.
Question: What kind of algorithm would return the desired output? I'm using JS/Typescript, but Python, pseudocode or any other language or even just an idea would highly be appreciated!