Main Content

addVertices

Add vertices to surface mesh

Since R2022b

    Description

    example

    addVertices(mesh,vertices) adds the specified vertices to the surfaceMesh object mesh.

    addVertices(___,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments from the previous syntax. For example, VertexNormals=[8 -4 4; 4 4 8; -6 6 3; -3 -6 6; 3 -6 -6; 6 6 -3] specifies the normal vectors for the mesh vertices.

    Examples

    collapse all

    Define mesh vertices for a surface mesh.

    vertices = [1 -1  1; 1 1 1; -1 1 1; -1 -1 1; ...
                1 -1 -1; 1 1 -1; -1 1 -1; -1 -1 -1];

    Define the mesh faces using the vertices.

    faces = [6 2 1; 1 5 6; 8 4 3; 3 7 8; 6 7 3; 3 2 6; ...
             5 1 4; 4 8 5; 4 1 2; 2 3 4; 7 6 5; 5 8 7];

    Create and display the surface mesh.

    mesh = surfaceMesh(vertices,faces);
    surfaceMeshShow(mesh,Title="Original Mesh")

    Add a new vertex to the surface mesh.

    addVertices(mesh,[0 0 2])

    Add new faces to surface mesh and display the updated mesh.

    faces = [1 4 9; 2 3 9];
    addFaces(mesh,faces);
    surfaceMeshShow(mesh,Title="Modified Mesh")

    Input Arguments

    collapse all

    Surface mesh, specified as a surfaceMesh object.

    Mesh vertices, specified as an M-by-3 matrix. Each row of the matrix is of the form [x y z], specifying the coordinates of a vertex. Each vertex has a vertex ID equal to N + Mrow, where N is the ID of the last vertex in mesh and Mrow is the row number of the vertex in vertices. M is the total number of vertices to add to the mesh.

    Data Types: single | double

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: mesh(vertices,faces,VertexNormals=[8 -4 4; 4 4 8; -6 6 3; -3 -6 6; 3 -6 -6; 6 6 -3]) specifies the normal vectors for the mesh vertices.

    Normal vectors for the mesh vertices, specified as an M-by-3 matrix. Each row of the matrix is of the form [x y z], specifying the normal vector for a vertex. M is the total number of vertices to add to the mesh.

    Data Types: single | double

    Color values for the mesh vertices, specified as an M-by-3 matrix. Each row of the matrix is of the form [R G B], specifying the color value for a vertex. Each values must be in the range [0,1]. M is the total number of vertices to add to the mesh.

    Data Types: single | double

    Version History

    Introduced in R2022b