plotConvexHull3d {cxhull}R Documentation

Plot triangulated 3d convex hull

Description

Plot a triangulated 3d convex hull with rgl.

Usage

plotConvexHull3d(
  hull,
  angleThreshold = NULL,
  edgesAsTubes = TRUE,
  verticesAsSpheres = TRUE,
  palette = NULL,
  bias = 1,
  interpolate = "linear",
  g = identity,
  facesColor = "navy",
  edgesColor = "gold",
  tubesRadius = 0.03,
  spheresRadius = 0.05,
  spheresColor = edgesColor,
  alpha = 1
)

Arguments

hull

an output of cxhull applied to 3d points and with the option triangulate=TRUE

angleThreshold

a threshold angle in degrees, typically 179, to get rid of edges between coplanar faces: edges whose corresponding dihedral angle is greater than this threshold are removed; NULL to use another method (see the Leonardo example)

edgesAsTubes

Boolean, whether to draw the edges as tubes

verticesAsSpheres

Boolean, whether to draw the vertices as spheres

palette

a vector of colors to make a color gradient for the faces; if NULL, the colors of the faces are controlled by the facesColor argument

bias, interpolate

if palette is not NULL, these arguments are passed to colorRamp

g

a function defined on [0, 1] and taking its values in [0, 1]; it is composed with the function created by colorRamp, based on palette

facesColor

the color(s) for the faces; this argument is ignored if the argument palette is not NULL; otherwise there are three possibilities for facesColor: a single color, a vector of colors with length the number of triangles, in which case one color is assigned per triangle, or a vector of colors with length the number of faces, after merging the triangles, in which case one color is assigned per face; use hullSummary to know the number of faces

edgesColor

the color for the edges

tubesRadius

the radius of the tubes when edgesAsTubes=TRUE

spheresRadius

the radius of the spheres when verticesAsSpheres=TRUE

spheresColor

the color of the spheres when verticesAsSpheres=TRUE

alpha

number between 0 and 1 controlling the opacity of the faces

Value

No value.

Examples

library(cxhull)
library(rgl)
cuboctahedron <- t(cuboctahedron3d()$vb[-4L, ])
hull <- cxhull(cuboctahedron, triangulate = TRUE)
# single color ####
open3d(windowRect = c(50, 50, 562, 562))
plotConvexHull3d(hull)
# gradient ####
open3d(windowRect = c(50, 50, 562, 562))
if(getRversion() < "4.1.0"){
  palette <- "Viridis"
}else{
  palette <- "Rocket"
}
plotConvexHull3d(hull, palette = hcl.colors(256, palette), bias = 0.5)


library(cxhull)
library(rgl)
# Leonardo da Vinci's 72-sided sphere ####
hull <- cxhull(daVinciSphere, triangulate = TRUE)
# there are some undesirable edges:
plotConvexHull3d(
  hull, tubesRadius = 0.07, spheresRadius = 0.1
)
# => use `angleThreshold` to get rid of these edges:
plotConvexHull3d(
  hull, angleThreshold = 179,
  tubesRadius = 0.07, spheresRadius = 0.1
)


[Package cxhull version 0.7.4 Index]