Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mergeVertices

Merge duplicate vertices in mesh object


Description

A mesh object can have the same vertex listed twice. Each copy is allowed to have separate normals, texture coordinates, and color. However, it is more efficient to have just a single copy if those differences aren't needed. For automatic smoothing using addNormals, triangles and quads need to share vertices. This function merges identical (or similar) vertices to achieve this.

Usage

mergeVertices(mesh, 
              notEqual = NULL, 
              attribute = "vertices", 
              tolerance = sqrt(.Machine$double.eps))

Arguments

mesh

A mesh3d object.

notEqual

A logical matrix indicating that certain pairs should not be merged even if they appear identical.

attribute

Which attribute(s) should be considered in comparing vertices? A vector chosen from c("vertices", "colors", "normals", "texcoords"))

tolerance

When comparing vertices using all.equal, this tolerance will be used to ignore rounding error.

Value

A new mesh object.

Author(s)

Duncan Murdoch

See Also

as.mesh3d.rglId, which often constructs mesh objects containing a lot of duplication.

Examples

open3d()
(mesh1 <- cuboctahedron3d(col = rainbow(14), meshColor = "face"))
id <- shade3d(mesh1)
(mesh2 <- as.mesh3d(id))
shade3d(translate3d(mesh2, 3, 0, 0))
(mesh3 <- mergeVertices(mesh2))
shade3d(translate3d(mesh3, 6, 0, 0))

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.