EXPANDPOLYGON Expand a polygon by a given (signed) distance.

   POLY2 = expandPolygon(POLY, DIST);
   Associates to each edge of the polygon POLY the parallel line located
   at distance DIST from the current edge, and compute intersections with
   neighbor parallel lines. The input polygon POLY must be oriented
   counter-clockwise. Otherwise, distance is computed inside the polygon.
   The resulting polygon is simplified to remove inner "loops", and can
   eventually be disconnected. 
   The result POLY2 is a cell array, each cell containing a simple linear
   ring. 
   
   This is a kind of dilation, but behaviour on corners is different.
   This function keeps angles of polygons, but there is no direct relation
   between the lengths of each polygon.

   It is also possible to specify negative distance, and get all points
   inside the polygon. If the polygon is convex, the result equals
   morphological erosion of polygon by a ball with radius equal to the
   given distance.

   Example:
   % Computes the negative offset of a non-convex polygon
     poly = [10 10;30 10;30 30;20 20;10 30];
     poly2 = expandPolygon(poly, -3);
     figure;
     drawPolygon(poly, 'linewidth', 2);
     hold on; drawPolygon(poly2, 'm')
     axis equal; axis([0 40 0 40]);

   See also:
   polygons2d, polygonLoops, polygonSelfIntersections 

Package: matgeom