surf2patch

Converts surface data into patch faces and vertices.

Category: Graphics > 2-D and 3-D Plots

Syntax

fv = surf2patch(X, Y, Z)

Returns a struct with quadrilateral faces and vertices.

fv = surf2patch(Z)

Uses array indices for X and Y.

fv = surf2patch(___, 'triangles')

Splits each quadrilateral into two triangles.

Description

A grid of m-by-n points gives (m-1)*(n-1) quadrilateral faces and m*n vertices. The struct can be passed to patch or reducepatch, which is how a surface gets simplified or exported to a mesh format.

Input arguments

X, Y, Z
Matrices of the same size describing the surface.

Output arguments

fv
Struct with faces (one row of vertex indices per face) and vertices (one row of x, y, z per vertex).

Example

Faces and vertices of a 5-by-5 grid

[X, Y, Z] = peaks(5);
fv = surf2patch(X, Y, Z);
disp(size(fv.faces))
disp(size(fv.vertices))
Output
    16     4
    25     3

See also

patch surf reducepatch isosurface