convexParts: Decomposition into convex parts

View source: R/convexPartsR.R

convexPartsR Documentation

Decomposition into convex parts

Description

Decomposition of a mesh into convex parts.

Usage

convexParts(vertices, faces, mesh = NULL, triangulate = TRUE)

Arguments

vertices

a numeric matrix with three columns, or a bigq matrix with three columns if numbersType="gmp"

faces

either an integer matrix (each row provides the vertex indices of the corresponding face) or a list of integer vectors, each one providing the vertex indices of the corresponding face

mesh

if not NULL, this argument takes precedence over vertices and faces, and must be either a list containing the fields vertices and faces (objects as described above), otherwise a rgl mesh (i.e. a mesh3d object)

triangulate

Boolean, whether to triangulate the convex parts

Value

A list of cgalMesh lists, each corresponding to a convex part.

Examples

# a non-convex polyhedron ####
library(MeshesOperations)
library(rgl)
library(randomcoloR)
meshes <- convexParts(mesh = NonConvexPolyhedron)
ncp <- length(meshes)
colors <- randomColor(ncp, hue = "random", luminosity = "bright")
open3d(windowRect = c(50, 50, 562, 562), zoom = 0.8)
for(i in seq_len(ncp)){
  shade3d(toRGL(meshes[[i]]), color = colors[i])
}
plotEdges(
  NonConvexPolyhedron[["vertices"]],
  NonConvexPolyhedron[["edges"]]
)

# pentagrammic prism ####
library(MeshesOperations)
library(rgl)
library(randomcoloR)
meshes <- convexParts(mesh = pentagrammicPrism)
ncp <- length(meshes)
colors <- randomColor(ncp, hue = "random", luminosity = "bright")
open3d(windowRect = c(50, 50, 562, 562), zoom = 0.8)
for(i in seq_len(ncp)){
  shade3d(toRGL(meshes[[i]]), color = colors[i])
}
plotEdges(
  pentagrammicPrism[["vertices"]],
  pentagrammicPrism[["edges"]],
  tubesRadius = 0.01,
  spheresRadius = 0.02
)

stla/MeshesOperations documentation built on Oct. 23, 2022, 8:23 a.m.