Convert surface grids into face-vertex mesh.

   [V, F] = surfToMesh(X, Y)
   [V, F] = surfToMesh(X, Y, Z)
   Converts the surface grid given by two or three coordinate arrays into
   a face-vertex quad mesh.

   Example
     % transform a surface into a mesh
     [X, Y] = meshgrid(-2:.2:2, -2:.2:2);                                
     Z = X .* exp(-X.^2 - Y.^2);
     [V, F] = surfToMesh(X, Y, Z);
     figure;
     drawMesh(V, F); view(3);

     % Transform surface of a cylinder as a mesh
     [x, y, z] = cylinder(5*ones(1, 10));
     [v, f] = surfToMesh(x, y, z, 'xPeriodic', true);
     figure;
     drawMesh(v, f);
     view(3); axis equal;

   See also
     meshes3d, meshgrid, drawMesh, torusMesh, sphereMesh

Package: matgeom