Created
October 5, 2014 15:17
-
-
Save jacobjoaquin/749f50640a4b8527025c to your computer and use it in GitHub Desktop.
Radial Recursion Experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
size(500, 500); | |
noLoop(); | |
} | |
void draw() { | |
background(255); | |
translate(width / 2, height / 2); | |
stroke(0, 96); | |
rc(new PVector(0, 0), 0, PI, 24, 14); | |
rc(new PVector(0, 0), PI, PI, 24, 14); | |
} | |
void rc(PVector p, float angle, float rot, float distance, int iter) { | |
rot *= 0.5; | |
PVector p2 = PVector.fromAngle(angle); | |
p2.mult(distance); | |
p2.add(p); | |
PVector p3 = p2.get(); | |
p3.rotate(rot); | |
line(p.x, p.y, p2.x, p2.y); | |
line(p2.x, p2.y, p3.x, p3.y); | |
if (iter-- > 0) { | |
rc(p2, angle, rot, distance, iter); | |
rc(p3, angle + rot, rot, distance, iter); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment