This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Compute normals of isosurface vertices


n = isonormals(X,Y,Z,V,vertices)
n = isonormals(V,vertices)
n = isonormals(V,p)
n = isonormals(X,Y,Z,V,p)
n = isonormals(...,'negate')


n = isonormals(X,Y,Z,V,vertices) computes the normals of the isosurface vertices from the vertex list, vertices, using the gradient of the data V. The arrays X, Y, and Z define the coordinates for the volume V. The computed normals are returned in n.

n = isonormals(V,vertices) assumes the arrays X, Y, and Z are defined as [X,Y,Z] = meshgrid(1:n,1:m,1:p) where [m,n,p] = size(V).

n = isonormals(V,p) and n = isonormals(X,Y,Z,V,p) compute normals from the vertices of the patch identified by the handle p.

n = isonormals(...,'negate') negates (reverses the direction of) the normals.

isonormals(V,p) and isonormals(X,Y,Z,V,p) set the VertexNormals property of the patch identified by the handle p to the computed normals rather than returning the values.


collapse all

Compare the effect of different surface normals on the visual appearance of lit isosurfaces. In one case, the triangles used to draw the isosurface define the normals. In the other, the isonormals function uses the volume data to calculate the vertex normals based on the gradient of the data points. The latter approach generally produces a smoother-appearing isosurface.

Define a 3-D array of volume data.

data = cat(3,[0 .2 0; 0 .3 0; 0 0 0],...
    [.1 .2 0; 0 1 0; .2 .7 0],...
    [0 .4 .2; .2 .4 0;.1 .1 0]);
data = interp3(data,3,'cubic');

Draw an isosurface from the volume data and add lights. This isosurface uses triangle normals.

fv = isosurface(data,.5);
p1 = patch(fv,'FaceColor','red','EdgeColor','none');
axis tight
lighting gouraud
title('Triangle Normals')

Draw the same lit isosurface using normals calculated from the volume data.

fv = isosurface(data,.5);
p2 = patch(fv,'FaceColor','red','EdgeColor','none');
daspect([1 1 1])
axis tight
lighting gouraud
title('Data Normals')

These isosurfaces illustrate the difference between triangle and data normals.

Extended Capabilities

Introduced before R2006a