# NOT RUN {
if (requireNamespace("alphashape3d", quietly = TRUE)) {
set.seed(123)
n <- 400 # 1000 gives a nicer result, but takes longer
xyz <- rbind(cbind(runif(n), runif(n), runif(n)),
cbind(runif(n/8, 1, 1.5),
runif(n/8, 0.25, 0.75),
runif(n/8, 0.25, 0.75)))
ash <- suppressMessages(alphashape3d::ashape3d(xyz, alpha = 0.2))
m <- as.mesh3d(ash, smooth = TRUE)
open3d()
mfrow3d(1, 2, sharedMouse = TRUE)
plot3d(xyz, size = 1)
plot3d(m, col = "red", alpha = 0.5)
points3d(xyz, size = 1)
}
# }
Run the code above in your browser using DataLab