Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
Get segments of a polygon divided by lines

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:

enter image description here

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!