plotConvexHull3D | R Documentation |
Plot a 3D convex hull with rgl.
plotConvexHull3D( hull, color = "distinct", hue = "random", luminosity = "light", alpha = 1, edgesAsTubes = FALSE, tubeRadius, tubeColor )
hull |
the output of |
color |
controls the colors of the faces, either
|
hue, luminosity |
if |
alpha |
opacity, number between 0 and 1 |
edgesAsTubes |
Boolean, whether to plot the edges as tubes |
tubeRadius |
if |
tubeColor |
if |
No value, just renders a 3D plot.
library(RCGAL) library(rgl) # blue dodecahedron with edges as tubes #### dodecahedron <- t(dodecahedron3d()$vb[-4, ]) hull <- convexhull(dodecahedron) open3d(windowRect = c(50, 50, 562, 562)) plotConvexHull3D( hull, color = "navy", edgesAsTubes = TRUE, tubeRadius = 0.03, tubeColor = "gold" ) # the dodecahedron with multiple colors #### hull <- convexhull(dodecahedron, faceFamilies = TRUE) open3d(windowRect = c(50, 50, 562, 562)) plotConvexHull3D(hull, color = "random", luminosity = "bright") # a strange convex hull #### pt <- function(x){ c( sin(x) * cos(2 * x), sin(x) * sin(2 * x), cos(x) ) } pts <- t(vapply(seq(0, pi, length.out = 50), pt, numeric(3L))) hull <- convexhull(pts) open3d(windowRect = c(50, 50, 562, 562)) plotConvexHull3D(hull, color = "random", hue = "purple", luminosity = "dark") # Leonardo da Vinci's 72-sided sphere: the `epsilon` parameter #### # the points of da Vinci's 72 sided sphere: pts <- rbind( c(1.61352, -0.43234, 1.1862), c(1.18118, -1.18118, 1.1862), c(0.43234, -1.61352, 1.1862), c(-0.43234, -1.61352, 1.1862), c(-1.18118, -1.18118, 1.1862), c(-1.61352, -0.43234, 1.1862), c(-1.61352, 0.43234, 1.1862), c(-1.18118, 1.18118, 1.1862), c(-0.43234, 1.61352, 1.1862), c(0.43234, 1.61352, 1.1862), c(1.18118, 1.18118, 1.1862), c(1.61352, 0.43234, 1.1862), c(1.61352, -0.43234, -1.1862), c(1.61352, 0.43234, -1.1862), c(1.18118, 1.18118, -1.1862), c(0.43234, 1.61352, -1.1862), c(-0.43234, 1.61352, -1.1862), c(-1.18118, 1.18118, -1.1862), c(-1.61352, 0.43234, -1.1862), c(-1.61352, -0.43234, -1.1862), c(-1.18118, -1.18118, -1.1862), c(-0.43234, -1.61352, -1.1862), c(0.43234, -1.61352, -1.1862), c(1.18118, -1.18118, -1.1862), c(2.0102, 0.53863, 0), c(1.47157, 1.47157, 0), c(0.53863, 2.0102, 0), c(-0.53863, 2.0102, 0), c(-1.47157, 1.47157, 0), c(-2.0102, 0.53863, 0), c(-2.0102, -0.53863, 0), c(-1.47157, -1.47157, 0), c(-0.53863, -2.0102, 0), c(0.53863, -2.0102, 0), c(1.47157, -1.47157, 0), c(2.0102, -0.53863, 0), c(0.89068, 0.23866, 1.77777), c(0.89068, -0.23866, 1.77777), c(0.65202, -0.65202, 1.77777), c(0.23866, -0.89068, 1.77777), c(-0.23866, -0.89068, 1.77777), c(-0.65202, -0.65202, 1.77777), c(-0.89068, -0.23866, 1.77777), c(-0.89068, 0.23866, 1.77777), c(-0.65202, 0.65202, 1.77777), c(-0.23866, 0.89068, 1.77777), c(0.23866, 0.89068, 1.77777), c(0.65202, 0.65202, 1.77777), c(0.65202, -0.65202, -1.77777), c(0.89068, -0.23866, -1.77777), c(0.89068, 0.23866, -1.77777), c(0.65202, 0.65202, -1.77777), c(0.23866, 0.89068, -1.77777), c(-0.23866, 0.89068, -1.77777), c(-0.65202, 0.65202, -1.77777), c(-0.89068, 0.23866, -1.77777), c(-0.89068, -0.23866, -1.77777), c(-0.65202, -0.65202, -1.77777), c(-0.23866, -0.89068, -1.77777), c(0.23866, -0.89068, -1.77777), c(0, 0, 2.04922), c(0, 0, -2.04922) ) # with the default `epsilon`, some triangular faces are not merged: hull <- convexhull(pts, faceFamilies = TRUE) open3d(windowRect = c(50, 50, 562, 562)) plotConvexHull3D(hull, color = "random", hue = "pink") # so one has to increase `epsilon`: hull <- convexhull(pts, faceFamilies = TRUE, epsilon = 1e-5) open3d(windowRect = c(50, 50, 562, 562)) plotConvexHull3D(hull, color = "random", hue = "orange", luminosity = "bright")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.