CLIPGRAPHPOLYGON Clip a graph with a polygon.
[NODES2, EDGES2] = clipGraphPolygon(NODES, EDGES, POLY)
Clips the graph defined by nodes NODES and edges EDGES with the polygon
given in POLY. POLY is a N-by-2 array of vertices.
The result is a new graph containing nodes inside the polygon, as well
as nodes created by the intersection of edges with the polygon.
Example
elli = [50 50 40 20 30];
figure; hold on;
drawEllipse(elli, 'k');
poly = ellipseToPolygon(elli, 200);
box = polygonBounds(poly);
germs = randomPointInPolygon(poly, 100);
drawPoint(germs, 'b.');
[n, e, f] = boundedVoronoi2d(box, germs);
[n2, e2] = clipGraphPolygon(n, e, poly);
drawGraphEdges(n2, e2);
See also
graphs, drawGraph, clipGraph
Package: matgeom