Skip to content

wsilva32/poly_decomp.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poly_decomp.py: Decompose 2D polygons into convex pieces

Installation

$ pip install poly_decomp

Usage

import poly_decomp as pd

polygon = [[0, 0], [5, 0], [5, 5], [2.5, 2.5], [0, 5]]
#           |\    /|
#           | \  / |
#           |  \/  |
#           |      |
#           |------|

print pd.polygonDecomp(polygon)
# --> [[[0, 0], [2.5, 2.5], [0, 5]], [[0, 0], [5, 0], [5, 5], [2.5, 2.5]]]
#           |\   /|
#           | \ / |
#           |  /  |
#           | /   |
#           |/----|

print pd.polygonQuickDecomp(polygon)
# --> [[[5, 0], [5, 5], [2.5, 2.5]], [[2.5, 2.5], [0, 5], [0, 0], [5, 0]]]
#           |\   /|
#           | \ / |
#           |  \  |
#           |   \ |
#           |----\|

About

Implementation based on Schteppe's poly-decomp.js.

Algorithms based on Mark Bayazit's Poly Decomp.

About

Decompose 2D polygons into convex pieces.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages