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(mesh, triangulate = TRUE)

Arguments

mesh

either a list containing the fields vertices and faces, otherwise a rgl mesh (i.e. a mesh3d object)

triangulate

Boolean, whether to triangulate the convex parts

Value

A list of cgalMesh lists (see Mesh), each corresponding to a convex part.

Examples

# a non-convex polyhedron ####
library(MeshesTools)
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])
}

# pentagrammic prism ####
library(MeshesTools)
library(rgl)
library(randomcoloR)
data(pentagrammicPrism, package = "PolygonSoup")
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])
}

MeshesTools documentation built on Oct. 29, 2022, 9:05 a.m.