15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Interpolation<br />

In this example, V is a 13-by-3 matrix, the 13 rows are the coordinates <strong>of</strong> the 13<br />

Voronoi vertices. The first row <strong>of</strong> V is a point at infinity. C is a 9-by-1 cell array,<br />

where each cell in the array contains an index vector into V corresponding to<br />

one <strong>of</strong> the 9 Voronoi cells. For example, the 9th cell <strong>of</strong> the Voronoi diagram is<br />

C{9} = 2 3 4 5 6 7 8 9 10 11 12 13<br />

If any index in a cell <strong>of</strong> the cell array is 1, then the corresponding Voronoi cell<br />

contains the first point in V, a point at infinity. This means the Voronoi cell is<br />

unbounded.<br />

To view a bounded Voronoi cell, i.e., one that does not contain a point at<br />

infinity, use the convhulln function to compute the vertices <strong>of</strong> the facets that<br />

make up the Voronoi cell. Then use patch and other plot functions to generate<br />

the figure. For example, this code plots the Voronoi cell defined by the 9th cell<br />

in C:<br />

X = V(C{9},:); % View 9th Voronoi cell.<br />

K = convhulln(X);<br />

figure<br />

hold on<br />

d = [1 2 3 1]; % <strong>Index</strong> into K<br />

for i = 1:size(K,1)<br />

j = K(i,d);<br />

h(i)=patch(X(j,1),X(j,2),X(j,3),i,'FaceAlpha',0.9);<br />

end<br />

hold <strong>of</strong>f<br />

view(3)<br />

axis equal<br />

title('One cell <strong>of</strong> a Voronoi diagram')<br />

2-33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!