isosurface
Extracts the surface where 3-D volume data equals a chosen value, as faces and vertices.
Category: Graphics > 2-D and 3-D Plots
Syntax
fv = isosurface(X, Y, Z, V, isovalue)
Returns a structure with faces and vertices for the surface V = isovalue on the grid (X, Y, Z).
fv = isosurface(V, isovalue)
Uses the grid 1:n in each direction.
[f, v] = isosurface(___)
Returns faces and vertices as two arrays.
Description
The function is the 3-D analog of a contour line. It walks through the cells of the volume and builds triangles wherever the data crosses the isovalue. The vertex positions are linearly interpolated between grid points.
Draw the result with patch(fv, 'FaceColor', 'r'), then add view(3) and camlight for a lit 3-D look.
Input arguments
X, Y, Z- Coordinate arrays, as from
meshgrid. V- 3-D array of scalar data.
isovalue- The level at which to cut the data.
Output arguments
fv- Structure with
vertices(n-by-3) andfaces(m-by-3 triangles indexing the vertices), ready forpatch. f, v- The faces and the vertices as separate arrays.
Example
Sphere from a distance field
[x, y, z] = meshgrid(-1:0.5:1);
v = x.^2 + y.^2 + z.^2;
fv = isosurface(x, y, z, v, 0.5);
size(fv.faces)
size(fv.vertices)
max(fv.vertices)
Output
ans = 1×2
96 3
ans = 1×2
74 3
ans = 1×3
0.6667 0.6667 0.6667