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 |
angleThreshold |
a threshold angle in degrees, typically |
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 |
bias , interpolate |
if |
g |
a function defined on [0, 1] and taking its values in [0, 1]; it is
composed with the function created by |
facesColor |
the color(s) for the faces; this argument is ignored if
the argument |
edgesColor |
the color for the edges |
tubesRadius |
the radius of the tubes when |
spheresRadius |
the radius of the spheres when
|
spheresColor |
the color of the spheres when
|
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
)