Learn R Programming

MeshesTools (version 1.0.0)

convexParts: Decomposition into convex parts

Description

Decomposition of a mesh into convex parts.

Usage

convexParts(mesh, triangulate = TRUE)

Value

A list of cgalMesh lists (see

Mesh), each corresponding to a convex part.

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

Examples

Run this code
# 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])
}

Run the code above in your browser using DataLab