Function File: spoly = simplifyPolygon_geometry (poly)

Simplify a polygon using the Ramer-Douglas-Peucker algorithm.

poly is a N-by-2 matrix, each row representing a vertex.

See also: simplifyPolyline_geometry, shape2polygon.

Demonstration 1

The following code


  P = [0 0; 1 0; 0 1];
  P2 = [0 0; 0.1 0; 0.2 0; 0.25 0; 1 0; 0 1; 0 0.7; 0 0.6; 0 0.3; 0 0.1];
  Pr = simplifyPolygon_geometry (P2);

  cla
  drawPolygon(P,'or;Reference;');
  hold on
  drawPolygon(P2,'x-b;Redundant;');
  drawPolygon(Pr,'*g;Simplified;');
  hold off

 # --------------------------------------------------------------------------
 # The two polygons describe the same figure, a triangle. Extra points are
 # removed from the redundant one.

Produces the following figure

Figure 1

Package: geometry