poly2fv - Convert polygonal region to patch faces and vertices

Syntax

[F, V] = poly2fv(x, y)

[F, V] = poly2fv(x, y) converts the polygonal region represented by the contours (x, y) into a faces matrix, F, and a vertices matrix, V, that can be used with the patch function to display the region. The contour vertices can be represented either in NaN-separated vector format or cell array format.

Individual contours in x and y are assumed to be external contours if their vertices are arranged in clockwise order; otherwise they are assumed to be internal contours. Use poly2cw or poly2ccw, if necessary, to achieve the desired vertex ordering.

Example

Display a rectangular region with two holes using a single patch object.

% External contour, rectangle, clockwise ordered.
x1 = [0 0 6 6 0];
y1 = [0 3 3 0 0];

% First hole contour, square, counterclockwise ordered.
x2 = [1 2 2 1 1];
y2 = [1 1 2 2 1];

% Second hole contour, triangle, counterclockwise ordered.
x3 = [4 5 4 4];
y3 = [1 1 2 1];

% Compute face and vertex matrices.
[f, v] = poly2fv({x1, x2, x3}, {y1, y2, y3});

% Display the patch.
patch('Faces', f, 'Vertices', v, 'FaceColor', 'r', ...
 'EdgeColor', 'none');
axis off, axis equal

See the documentation for polybool for additional examples illustrating poly2fv.

See also

ispolycw, patch, poly2cw, poly2ccw, polybool

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS