library(RCGAL)
library(rgl)
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)
)
hull <- convexhull(pts, faceFamilies = TRUE, epsilon = 1e-5)
open3d(windowRect = c(50, 50, 562, 562))
bg3d("seashell")
view3d(zoom = 0.7)
plotConvexHull3D(
hull, color = "random", hue = "red", luminosity = "bright",
edgesAsTubes = TRUE, tubeRadius = 0.05, tubeColor = "darkmagenta"
)
# animation ####
M <- par3d("userMatrix")
movie3d(
par3dinterp(
time = seq(0, 1, len = 9),
userMatrix = list(
M,
rotate3d(M, pi, 1, 0, 0),
rotate3d(M, pi, 1, 1, 0),
rotate3d(M, pi, 1, 1, 1),
rotate3d(M, pi, 0, 1, 1),
rotate3d(M, pi, 0, 1, 0),
rotate3d(M, pi, 1, 0, 1),
rotate3d(M, pi, 0, 0, 1),
M
)
),
fps = 120,
duration = 1,
dir = ".",
frames = "zzzpic",
convert = "echo \"%d %s %s %s\"",
clean = FALSE
)
pngs <- list.files(".", pattern = "^zzzpic", full.names = TRUE)
library(gifski)
gifski(pngs, "Leonardo.gif",
width = 512, height = 512, delay = 1/10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.