polybool

Octave and MATLAB mex interfaces to the General Polygon Clipper (GPC) and Clipper libraries for Boolean set algebra with planar polygons. Also included are mex functions to compute the orientation of planar polygons, and to test if points are inside a polygon. These functions are not compatible with similarly named functions of the MATLAB Mapping Toolbox. They are, in fact, more capable because they can work with cell arrays of polygons.

Polygon clipping:

[pc, hc] = polybool({pa1,pa2,pa3,...}, {pb1,pb2,pb3,...}, op, ha, hb);

Compute polygon orientation:

cw = iscw({pa,pb,pc,...});

Make polygon orientation clockwise:

P = polycw({pa,pb,pc,....});

Check if points are inside a polygon:

inp = isinpolygon(pa, xy);

Polygon area:

A = polyarea(pa);

Polygon centroid:

A = polycentr(pa);

Polygon segment intersections:

pc = polyinters(pa,pb);