15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2 Polynomials and Interpolation<br />

7 3 1<br />

5 7 1<br />

7 4 3<br />

4 7 8<br />

2 6 1<br />

6 5 1<br />

4 6 2<br />

6 4 8<br />

6 7 5<br />

7 6 8<br />

Because the data is three-dimensional, the facets that make up the convex hull<br />

are triangles. The 12 rows <strong>of</strong> C represent 12 triangles. The elements <strong>of</strong> C are<br />

indices <strong>of</strong> points in X. For example, the first row, 3 1 5, means that the first<br />

triangle has X(3,:), X(1,:), and X(5,:) as its vertices.<br />

For three-dimensional convex hulls, you can use trisurf to plot the output.<br />

However, using patch to plot the output gives you more control over the color<br />

<strong>of</strong> the facets. Note that you cannot plot convhulln output for n > 3.<br />

This code plots the convex hull by drawing the triangles as three-dimensional<br />

patches:<br />

figure, hold on<br />

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

for i = 1:size(C,1) % Draw each triangle.<br />

j= C(i,d); % Get the ith C to make a patch.<br />

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

end<br />

% 'FaceAlpha' is used to make it transparent.<br />

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

view(3), axis equal, axis <strong>of</strong>f<br />

camorbit(90,-5); % To view it from another angle<br />

title('Convex hull <strong>of</strong> a cube')<br />

2-28

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

Saved successfully!

Ooh no, something went wrong!