CLIPPOINTS Clip a set of points by a box. CLIP = clipPoints(POINTS, BOX); Returns the set of points which are located inside of the box BOX. See also points2d, boxes2d, clipLine, drawPoint ------ Author: David Legland e-mail: david.legland@grignon.inra.fr Created: 2008-10-13, using Matlab 7.4.0.287 (R2007a) Copyright 2010 INRA - Cepia Software Platform.
0001 function points = clipPoints(points, box) 0002 %CLIPPOINTS Clip a set of points by a box. 0003 % 0004 % CLIP = clipPoints(POINTS, BOX); 0005 % Returns the set of points which are located inside of the box BOX. 0006 % 0007 % 0008 % See also 0009 % points2d, boxes2d, clipLine, drawPoint 0010 % 0011 % 0012 % ------ 0013 % Author: David Legland 0014 % e-mail: david.legland@grignon.inra.fr 0015 % Created: 2008-10-13, using Matlab 7.4.0.287 (R2007a) 0016 % Copyright 2010 INRA - Cepia Software Platform. 0017 0018 % get bounding box limits 0019 xmin = box(1); 0020 xmax = box(2); 0021 ymin = box(3); 0022 ymax = box(4); 0023 0024 % compute indices of points inside visible area 0025 xOk = points(:,1)>=xmin & points(:,1)<=xmax; 0026 yOk = points(:,2)>=ymin & points(:,2)<=ymax; 0027 0028 % keep only points inside box 0029 points = points(xOk & yOk, :);