Home > matGeom > polygons2d > resamplePolygonByLength.m

resamplePolygonByLength

PURPOSE ^

RESAMPLEPOLYGONBYLENGTH Resample a polygon with a fixed sampling step.

SYNOPSIS ^

function poly2 = resamplePolygonByLength(poly, step)

DESCRIPTION ^

RESAMPLEPOLYGONBYLENGTH  Resample a polygon with a fixed sampling step.

   RES = resamplePolygon(POLY, STEP)
   Resample the input polygon POLY by distributing new vertices on the
   original polygon such that the (curvilinear) distance between the new
   vertices is approximately equal to STEP. 

   Example
     % creates a polygon from an ellipse
     elli = [20 30 40 20 30];
     poly = ellipseToPolygon(elli, 500);
     figure; drawPolygon(poly, 'b');
     poly2 = resamplePolygonByLength(poly, 10);
     hold on; 
     drawPolygon(poly2, 'm');
     drawPoint(poly2, 'mo');
     axis equal; axis([-20 60 0 60]);
     legend('Original polygon', 'Resampled polygon', 'Location', 'NorthWest');

   See also
     polygons2d, simplifyPolygon, resamplePolygon,
     resamplePolylineByLength

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function poly2 = resamplePolygonByLength(poly, step)
0002 %RESAMPLEPOLYGONBYLENGTH  Resample a polygon with a fixed sampling step.
0003 %
0004 %   RES = resamplePolygon(POLY, STEP)
0005 %   Resample the input polygon POLY by distributing new vertices on the
0006 %   original polygon such that the (curvilinear) distance between the new
0007 %   vertices is approximately equal to STEP.
0008 %
0009 %   Example
0010 %     % creates a polygon from an ellipse
0011 %     elli = [20 30 40 20 30];
0012 %     poly = ellipseToPolygon(elli, 500);
0013 %     figure; drawPolygon(poly, 'b');
0014 %     poly2 = resamplePolygonByLength(poly, 10);
0015 %     hold on;
0016 %     drawPolygon(poly2, 'm');
0017 %     drawPoint(poly2, 'mo');
0018 %     axis equal; axis([-20 60 0 60]);
0019 %     legend('Original polygon', 'Resampled polygon', 'Location', 'NorthWest');
0020 %
0021 %   See also
0022 %     polygons2d, simplifyPolygon, resamplePolygon,
0023 %     resamplePolylineByLength
0024 %
0025 
0026 % ------
0027 % Author: David Legland
0028 % e-mail: david.legland@inra.fr
0029 % Created: 2011-12-09,    using Matlab 7.9.0.529 (R2009b)
0030 % Copyright 2011 INRA - Cepia Software Platform.
0031 
0032 poly2 = resamplePolylineByLength(poly([1:end 1],:), step);
0033 poly2(end, :) = [];

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019