# X-Mas Tree with 10 Lines of R Code
# Credits: Michael Mayer
# Posted on December 20, 2021 by Michael Mayer in "R bloggers"
# https://bit.ly/3H2gWP9
#
library(rgl)
t <- seq(0, 100, by=0.7)^0.6
x <- t * c(sin(t), sin(t + pi))
y <- t * c(cos(t), cos(t + pi))
z <- -2 * c(t, t)
color <- rep(c("darkgreen", "gold"), each=length(t))
open3d(windowRect=c(100, 100, 600, 600), zoom=0.9)
bg3d("red")
spheres3d(x, y, z, radius=0.3, color=color)
#
# On screen (skip if Export)
play3d(spin3d(axis=c(0,0,1), rpm=4), duration=30)
#
# Export (requires 3rd party tool "ImageMagick" resp. magick-package)
# movie3d(spin3d(axis=c(0,0,1), rpm=4), duration=30, dir=getwd())
#
Per riavviare l'animazione chiudere e riaprire la pagina web.
Nessun commento:
Posta un commento