Skip to content

An algorithm to combine a set of polygons with crossing boundaries and find the faces they produce in the plane

License

Notifications You must be signed in to change notification settings

TarVK/faces-in-plane

Repository files navigation

faces-in-plane

This repository contains a typescript implementation of an algorithm I came up with to get the intersection of multiple polygons. It calculates what faces would result from adding multiple simple polygons to the same plane.

A demo of the algorithm can be found at tarvk.github.io/faces-in-plane/demo/build/. There is also a pdf that explains how the algorithm works.

Banner

Results

Robustness

The algorithm does suffer from some robustness issues, which I did not manage to solve. Solving these probably requires some changes to the core algorithm, rather than patches to the implementation. Since I now know what dangers to look out for, I may try to redesign the algorithm in the future so it doesn't suffer from these robustness issues.

Complexity

If a immutable set instead of an array was used to store the sources of all output polygons, the algorithm could run in O((n + k) * log n) time where n is the number of vertices in the input and k is the number of polygons in the output. Currently it runs in O((n + k) * (s + log n)) where s is the maximum number of overlapping polygons in the input.

About

An algorithm to combine a set of polygons with crossing boundaries and find the faces they produce in the plane

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published