Week 09 :: Recursion and Form
<< back to Procedural Morphology homepage
Class notes
Concept of Recursion
void setup() {
size(200, 200);
noStroke();
smooth();
noLoop();
}
void draw() {
drawCircle(126, 170, 6);
}
void drawCircle(int x, int radius, int level) {
float tt = 126 * level/4.0;
fill(tt);
ellipse(x, 100, radius*2, radius*2);
if (level > 1) {
level = level - 1;
drawCircle(x - radius/2, radius/2, level);
drawCircle(x + radius/2, radius/2, level);
}
}
myObj[] objs = new myObj[1000];
int objCount = 1;
int endCount;
void setup() {
size (500,300);
for (int i=0; i<objCount; i++) {
objs[i] = new myObj(30, 150, 1);
}
frameRate(1);
}
void draw() {
endCount = objCount;
for (int i=0; i<endCount; i++) {
objs[i].update();
}
}
class myObj {
// fields...
float x, x1, x2;
float y, y1, y2;
float s;
boolean dead = false;
// constructor...
myObj(float _x, float _y, float _s) {
x = _x;
y = _y;
s = _s;
x1 = random(20,30);
y1 = random(10,15);
x2 = random(20,30);
y2 = random(-10,-15);
}
// methods...
void update() {
if (!dead) {
drawMe();
begetMe();
dead = true;
}
}
void drawMe() {
fill(255,50);
pushMatrix();
translate(x,y);
scale(s);
beginShape();
vertex(x1, y1);
vertex(0, 0);
vertex(x2, y2);
endShape();
popMatrix();
}
// here the object creates more copies of the same object.
void begetMe() {
if (objCount < 444) {
objCount++;
objs[objCount-1] = new myObj(x+s*x1, y+s*y1, s*random(0.7,1.3));
objCount++;
objs[objCount-1] = new myObj(x+s*x2, y+s*y2, s*random(0.7,1.3));
}
}
}
Fractals
Daniel Shiffman's examples on using recursion to create fractal shapes in processing.
Mandelbrot
http://www.ddewey.net/mandelbrot/
Thorsten Fleisch
fleischfilm.com
Particularly his film gestalt
Julia Sets
Theory of Quaterion Fractals from Chaos Pro documentation
Quaternion Julia Fractals
Julia Sets implemented in processing
Buddhabrot Set
Iterated function system
Eric Green's Computer Science Thesis has some very understandable algorithms for IFS
Iterated Function Systems (a.k.a. Multiple Reduction Copy Machine Algorithms -- MRCMs)
Chaos and Randomness to Generate IFS
Paule Bourke explains how the IFS system can create the types of images below
Scott Draves
Flame
electric sheep screen saver
Dave Bollinger's IFS renders
Diffusion limited aggregation
wiki entry on Diffusion-limited_aggregation
Diffusion-Limited Aggregation and its Simulation
Diffusion limited aggregation in processing source sample
Andy Lomas
AndyLomas.com
Once a Mathematician, Always an Artist
Lindenmayer system (L-Systems)
Algorithmic Botany, University of Calgary
Geraldine Sarmiento's L-Systems in Processing
Voronoi Systems
Voronoi Description, java source code and applet
Mesh library for voronoi in processing
Brute force version in processing
voronoi.com
Flight 404's Voronoi Experiments
Voronoi Morphologies by Andrew Kudless
Voromuro project write up on form_ula
Assignment for next week.
Work on your final sketch from Part 3 of the class.