Skip to content

Latest commit

 

History

History
32 lines (28 loc) · 948 Bytes

Readme.md

File metadata and controls

32 lines (28 loc) · 948 Bytes

Bayazit.h

This is a polygon decomposer using the Bayazit algorithm. It is ported from the Farseer Physics C# code base into a single-header file library.

Exmaple usage:

Bayazit::Polygon poly;
poly.push_back(Bayazit::Point(20, -30));
poly.push_back(Bayazit::Point(10, -10));
poly.push_back(Bayazit::Point(30, -20));
poly.push_back(Bayazit::Point(30, 20));
poly.push_back(Bayazit::Point(10, 10));
poly.push_back(Bayazit::Point(20, 30));
poly.push_back(Bayazit::Point(-20, 30));
poly.push_back(Bayazit::Point(-10, 10));
poly.push_back(Bayazit::Point(-30, 20));
poly.push_back(Bayazit::Point(-30, -20));
poly.push_back(Bayazit::Point(-10, -10));
poly.push_back(Bayazit::Point(-20, -30));

Bayazit::Decomposer dec;
auto polys = dec.Decompose(poly);

for (auto p : polys)
{
	printf("poly: (%d points)\n", p.size());
	for (auto v : p)
		printf("  %f %f\n", v.x, v.y);
}