递归树
yihui opened this issue · comments
Yihui Xie commented
http://cos.name/cn/topic/105708
drawTree <- function(x1, y1, angle, n, lwd, len, col) {
if (n >= 1) {
x2 <- x1 + cos(angle) * len[n] * 10
y2 <- y1 + sin(angle) * len[n] * 10
lines(c(x1, x2), c(y1, y2), lwd = lwd[n], col = col[n])
drawTree(x2, y2, angle - pi/9, n - 1, lwd, len, col)
drawTree(x2, y2, angle + pi/9, n - 1, lwd, len, col)
}
}
par(mar = c(0, 0, 0, 0))
plot(0, xlim = c(-260, 260), ylim = c(0, 450), type = "n", axes = F)
drawTree(0, 0, angle = pi/2, n = 9, lwd = 1:9, len = 1:9,
col = rev(terrain.colors(16)[1:9]))
Taiyun commented
主动承认是我的马甲。。。
Yihui Xie commented
切,马甲好玩吗?
Taiyun commented
不太好玩,帮同学申请小间时候有用~
Yanping Chen commented
你们居然在这里版聊 太有害身心健康了