BOUNDINGBOX Bounding box of a set of points.
BOX = boundingBox(POINTS)
Returns the bounding box of the set of points POINTS. POINTS can be
either a N-by-2 or N-by-3 array. The result BOX is a 1-by-4 or 1-by-6
array, containing:
[XMIN XMAX YMIN YMAX] (2D point sets)
[XMIN XMAX YMIN YMAX ZMIN ZMAX] (3D point sets)
Example
% Draw the bounding box of a set of random points
points = rand(30, 2);
figure; hold on;
drawPoint(points, '.');
box = boundingBox(points);
drawBox(box, 'r');
% Draw bounding box of a cubeoctehedron
[v e f] = createCubeOctahedron;
box3d = boundingBox(v);
figure; hold on;
drawMesh(v, f);
drawBox3d(box3d);
set(gcf, 'renderer', 'opengl')
axis([-2 2 -2 2 -2 2]);
view(3)
See also
polygonBounds, drawBox
Package: matgeom