DISTANCEPOLYLINES Compute the shortest distance between 2 polylines. DIST = distancePolylines(POLY1, POLY2) POLY1 and POLY2 should be two polylines represented by their list of vertices. See also polygons2d, distancePolygons, distancePointPolyline
0001 function dist = distancePolylines(poly1, poly2) 0002 %DISTANCEPOLYLINES Compute the shortest distance between 2 polylines. 0003 % 0004 % DIST = distancePolylines(POLY1, POLY2) 0005 % POLY1 and POLY2 should be two polylines represented by their list of 0006 % vertices. 0007 % 0008 % 0009 % See also 0010 % polygons2d, distancePolygons, distancePointPolyline 0011 % 0012 0013 % ------ 0014 % Author: David Legland 0015 % e-mail: david.legland@grignon.inra.fr 0016 % Created: 2009-06-17, using Matlab 7.7.0.471 (R2008b) 0017 % Copyright 2009 INRA - Cepia Software Platform. 0018 0019 % compute distance of each vertex of a polyline to the other polyline 0020 dist1 = min(distancePointPolyline(poly1, poly2)); 0021 dist2 = min(distancePointPolyline(poly2, poly1)); 0022 0023 % keep the minimum of the two distances 0024 dist = min(dist1, dist2);