Gummy Worms
[This article was first published on Ripples, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Just keep swimming (Dory in Finding Nemo)
Inspired by this post, I decided to create gummy worms like this:
Or these:
When I was young I used to eat them.
Do you want to try? This is the code:
library(rgl) library(RColorBrewer) t=seq(1, 6, by=.04) f = function(a, b, c, d, e, f, t) exp(-a*t)*sin(t*b+c)+exp(-d*t)*sin(t*e+f) v1=runif(6,0,1e-02) v2=runif(6, 2, 3) v3=runif(6,-pi/2,pi/2) open3d() spheres3d(x=f(v1[1], v2[1], v3[1], v1[4], v2[4], v3[4], t), y=f(v1[2], v2[2], v3[2], v1[5], v2[5], v3[5], t), z=f(v1[3], v2[3], v3[3], v1[6], v2[6], v3[6], t), radius=.3, color=sample(brewer.pal(8, "Dark2"),1))
To leave a comment for the author, please follow the link and comment on their blog: Ripples.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.