参照Using Mathematical Formulas to Draw Butterflies
buter <- matrix(NA,40000,3)
for (k in 1:40000) {
buter[k,1] = (6/5) * (cos(141 * pi * k/40000))^9 * (1 - (1/2) *
(sin(pi * k/40000))^3) * (1 - (1/4) * (cos(2 * pi * k/40000))^30 *
(1 + (2/3) * (cos(30 * pi * k/40000))^20) - (sin(2 *
pi * k/40000))^10 * (sin(6 * pi * k/40000))^10 * ((1/5) +
(4/5) * (cos(24 * pi * k/40000))^20))
buter[k,2] = cos(2 * pi * k/40000) * (cos(141 * pi * k/40000))^2 *
(1 + (1/4) * (cos(pi * k/40000))^24 * (cos(3 * pi * k/40000))^24 *
(cos(19 * pi * k/40000))^24)
buter[k,3] = (1/100) + (1/40) * ((cos(2820 * pi * k/40000))^6 +
(sin(141 * pi * k/40000))^2) * (1 - (cos(pi * k/40000))^16 *
(cos(3 * pi * k/40000))^16 * (cos(12 * pi * k/40000))^16)
}
buter <- buter %>% as.data.frame %>% setNames(c("X","Y","R"))
g <- ggplot(buter, aes(X,Y))
g+geom_count(size=buter$R)+theme_bw()
butterfly.png
网友评论