Reputation: 21
Do you know how to programm Shepard-Metzler-figures with R? I would interested in a step-by-step guide on how write the code. As you can see on the picture, these figures consist of ten cubes formed into a snake-like structure. Thank you so much for your help!
I am not used to R, so writing the code for those figures is quite hard.
Upvotes: 2
Views: 57
Reputation: 1603
You can use the {rgl} package. Here is a simple code:
library(rgl)
x <- c(1, 1, 3, 3, 5, 5)
y <- c(1, 3, 5, 7, 9, 11)
z <- c(1, 1, 1, 3, 3, 3)
for (i in seq_along(x)) {
a_cube <- cube3d(col = "darkgreen")
shifted_cube <- translate3d(a_cube, x[i], y[i], z[i])
wire3d(shifted_cube)
}
Check the package help for much more info on how to make the figures neater.
Upvotes: 1