# ITERATIVE DESIGN (II)_##3rd round##____ STAGE 3 (CONSTRUCTION)

INDEX

I have followed a couple of tutorials to make some of the most famous fractal shapes.

THE SIERPINSKI TRIANGLE

It is one of the most famous fractal figures, the name was coined by the Polish mathematician in 1915. Although he only described it, since the triangle had been used from long before. It can be found in Italian cathedrals from the XIII century. It is a triangle which is filled with three triangles, forming thus, a white inverted triangle in the middle. Each triangle in the main triangle can be filled with the same pattern. It can be done infinitely.  (Westein, 2015)

IMAGE

CODE::

```
void setup(){
size(640,600);
}

void draw(){
background(255);
drawCircle(width/2, height/2, 300);
}

void drawCircle(float x, float y, float d){
stroke(0);
noFill();
ellipse(x, y, d, d);
if (d &amp;amp;amp;gt; 2){
drawCircle(x+d/2, y, d/2);
drawCircle(x-d/2, y, d/2);
drawCircle(x, y+d/2, d/2);
}
}

```

THE KOCH LINE

The Koch line was first described by Koch in 1905. Is is built from an equilateral triangle, or from a line. It is cut in thirds, and the one in the middle is removed. Then another equilateral triangle is drawn where the third has been removed. In the case of the line, two lines with the same size of the one which has been removed are added, forming a kind of triangle without base. The process is repeated which each new line of the drawing.  (Westein, 2015)

IMAGE::

CODE::

```ArrayList &amp;amp;amp;lt;KochLine&amp;amp;amp;gt; lines;

void setup(){
size(800, 400);
background(255);
lines = new ArrayList&amp;amp;amp;lt;KochLine&amp;amp;amp;gt;();
PVector start = new PVector(0, height-50);
PVector end = new PVector(width, height-50);
}

void keyPressed(){
if (key == 'b'){
generate();
}
}

void draw(){
background(255);
for(KochLine l : lines){
l.display();
}
saveFrame(&amp;amp;amp;quot;koch_line#.png&amp;amp;amp;quot;);
}

void generate(){
ArrayList next = new ArrayList&amp;amp;amp;lt;KochLine&amp;amp;amp;gt;();
for (KochLine l : lines) {
PVector a = l.kochA();
PVector b = l.kochB();
PVector c = l.kochC();
PVector d = l.kochD();
PVector e = l.kochE();

}
lines = next;
}

```
```
class KochLine {
PVector start;
PVector end;

KochLine(PVector a, PVector b) {
start = a.get();
end = b.get();
}

void display() {
stroke(0);
line(start.x, start.y, end.x, end.y);
}

PVector kochA() {
return start.get();
}
PVector kochB() {
PVector v = PVector.sub(end, start);
v.div(3);
return v;
}

PVector kochC() {
PVector a = start.get();

PVector v = PVector.sub(end, start);
v.div(3);

return a;
}

PVector kochD() {
PVector v = PVector.sub(end, start);
v.mult(2/3.0);
return v;
}

PVector kochE() {
return end.get();
}
}

```

REFERENCES::

Shiffman, D., 2013. 8.2 Fractal Recursion (The Nature of Code) [online] Vimeo. Available on:http://vimeo.com/64424402

Shiffman, D., 2013. 8.3 Recursion with ArrayList of Objects (The Nature of Code). [online] Vimeo. Available on: http://vimeo.com/64424401

Weisstein, Eric W. Sierpiński SieveMathWorld— [online] Available on: http://mathworld.wolfram.com/SierpinskiSieve.html

Weisstein, Eric W. Koch Snowflake. MathWorld— [online] Available on: http://mathworld.wolfram.com/KochSnowflake.html

INDEX