Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda