forked from PROGR-2324/01_git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsierpinski.Rmd
29 lines (24 loc) · 883 Bytes
/
sierpinski.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
title: "R Notebook"
output:
html_document:
df_print: paged
---
```{r, echo=FALSE}
if (!require("gifski", quietly=TRUE)) install.packages("gifski")
depth = 15
```
# Sierpiński triangle
> The **Sierpinski triangle** (also with the original orthography Sierpiński), also called the **Sierpinski gasket** or **Sierpinski sieve**, is a fractal attractive fixed set with the overall shape of an equilateral triangle, subdivided recursively into smaller equilateral triangles.
```{r}
sierpinski.df <- generateSierpinski(rows = 2^depth)
```
```{r, animation.hook="gifski", interval = 0.2, fig.asp=sqrt(0.75)}
par(mar=c(0.2, 0.2, 1.5, 0.2))
for (draw.depth in seq(1, 2^depth, length = 20)) {
plot(sierpinski.df[seq_len(draw.depth), ],
ylim=c(0, sqrt(.75)), xlim=c(0, 1), pch=".",
xlab="", ylab="", xaxt="n", yaxt="n",
main="Sierpinski Triangle")
}
```