A fractal is “a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole,”a property called self-similarity. Roots of mathematical interest in fractals can be traced back to the late 19th Century; however, the term “fractal” was coined by Benoît Mandelbrot in 1975 and was derived from the Latin fractus meaning “broken” or “fractured.” A mathematical fractal is based on an equation that undergoes iteration, a form of feedback based on recursion.
(form Wikipedia)
分形几何是几何学中的新分支,其维数可以是任意值。分形图形的一个重要特点是自相似性,据此性质可以人工构造出很多养眼的图片,这里给出四种常见的分形图。更多代码和讨论请移步COS论坛。
1. 树叶
plot.leaf <- function(n=50000, col="green",cex=2){
x <- c(.5, .5);
plot(x[1], x[2], xlim=c(-3, 3), ylim =c(0, 10),type="n",xlab="",ylab="")
p <- c( .85, .92, .99, 1.00);
A <- rbind(c(.85, .04), c(-.04,.85), c(.20,-.26), c(.23,.22),
c(-.15,.28), c(.26,.24), c(0, 0), c(0, .16))
B <- cbind(c(0, 1.6), c(0, 1.6), c(0,.44), c(0,0))
for (i in 1:n){
ran <- runif(1);
ind <- rank(c(p, ran), ties.method="min")[5]
x <- A[(2*ind-1):(2*ind),]%*%x + B[,ind]
points(x[1],x[2], pch=".", cex=cex, col=col)
}
}
#library(Cairo)
#CairoPNG()
par(mar=c(0,0,0,0)+0.1)
plot.leaf(cex=1.6)
box()
#dev.off()

2. 树

3. 三角

4. 雪花

近期评论