MeshesDifference: Meshes difference

View source: R/operations.R

MeshesDifferenceR Documentation

Meshes difference

Description

Computes the difference between two meshes.

Usage

MeshesDifference(mesh1, mesh2, clean = TRUE, normals = FALSE)

Arguments

mesh1, mesh2

two meshes, each being given as either a rgl mesh, or a list with (at least) two fields: vertices and faces; the vertices matrix can be a numeric matrix or a matrix of bigq rational numbers (from the gmp package)

clean

Boolean, whether to clean the meshes (merging duplicated vertices, duplicated faces, removing isolated vertices); set to FALSE if you know your meshes are clean

normals

Boolean, whether to return the per-vertex normals of the output mesh

Value

A triangle mesh given as a list with fields vertices, faces, edges, exteriorEdges, gmpvertices if using gmp meshes, and normals if normals=TRUE.

Examples

library(Boov)
library(rgl)

# mesh one: a cube
mesh1 <- cube3d() # (from the rgl package)

# mesh two: another cube
mesh2 <- translate3d( # (from the rgl package)
  cube3d(), 1, 1, 0
)

# compute the difference
differ <- MeshesDifference(mesh1, mesh2)

# plot
rgldiffer <- toRGL(differ)
open3d(windowRect = c(50, 50, 562, 562))
shade3d(mesh1, color = "yellow", alpha = 0.2)
shade3d(mesh2, color = "cyan", alpha = 0.2)
shade3d(rgldiffer, color = "red")
plotEdges(
  vertices = differ[["vertices"]], edges = differ[["exteriorEdges"]],
  edgesAsTubes = TRUE, verticesAsSpheres = TRUE
)

Boov documentation built on Oct. 31, 2022, 5:05 p.m.