# PolyBoolean

The main purpose of PolyBoolean is numerically robust and efficient implementation of Boolean operations on 2D polygonal regions. The coordinates of vertices are represented as signed integers (floating point values can simply be scaled to integers).

For additional information see Publications, PolyBoolean implementation restrictions, FAQ and PolyBoolean Comparison pages.

## PolyBoolean C++ Library

The PolyBoolean C++ Library includes Boolean operations, basic polygon construction routines and polygon triangulation routines. The coordinates of vertices are represented as **20-bit** signed integers (floating point values can simply be scaled to integers).

For a brief description of the library refer to the brief user's guide.

## PolyBoolean.NET Class Libraries

The PolyBoolean.NET class library is a library of classes and interfaces types that are included in the PolyBoolean.NET component. The class library is designed to be used in Microsoft .NET Framework applications, components, and controls. PolyBoolean.NET includes Boolean operations and polygon triangulation routines.

Available PolyBoolean.NET class library editions listed below:

- PolyBoolean.c20.NET Class Library
- In PolyBoolean.c20.NET coordinates of vertices are represented as
**20-bit**signed integers. That provides relative error = 2^{-20 }for calculation coordinates of intersection points. - If coordinates of any points on the Earth will be represented with such relative error then absolute error will be ±19.07m (62.5').
- PolyBoolean.c30.NET Class Library
- In PolyBoolean.c30.NET Coordinates of vertices are represented as
**30-bit**signed integers. That provides relative error = 2^{-30 }for calculation coordinates of intersection points. - If coordinates of any points on the Earth will be represented with such relative error then absolute error will be ±18.63mm (±0.73").

From version 1.1 PolyBoolean.NET implements an improved algorithm for Boolean operations on 2D polygonal regions.

The improved algorithm allows collect correct result regions even if one of input regions or even both of them have an overlapped (*not a crossing!*) segment chains. So the restriction on Boolean Operations (Implementation Restrictions page) is avoided.

### Speed

For testing we used PC with Intel Celeron processor (660 MHz) and 128Mb RAM running Microsoft Windows 2000 Professional SP4. Sample polygons were extracted from True Type Font contours using different levels of Bézier curves polygonal approximation. The test program was executed for every Boolean operation. The results are summarized in the table below (**N** denotes the total number of vertices in input polygons, all timings are measured in milliseconds):

Class Library | Relative error | N | ||||
---|---|---|---|---|---|---|

3885 | 7076 | 20190 | 69839 | 174239 | ||

PolyBoolean.c20.NET v1.1 | 2^{-20} | 220 | 385 | 1020 | 5103 | 15793 |

PolyBoolean.c30.NET v1.1 | 2^{-30} | 587 | 813 | 1727 | 8274 | 27329 |

For test program details see Visual C# sample projects on PolyBoolean.NET download page. Sample polygons files used for test also can be found there.