Created
February 9, 2015 11:02
-
-
Save NSDesign/a8e2046c8fb45cd5d7ce to your computer and use it in GitHub Desktop.
Vex : Random Walker
This file contains hidden or 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
// User parameters added to attribute wrangle parameter interface | |
int walkers = chi("walkers"); | |
int steps = chi("steps"); // Placing $F in steps, each walker will grow during playback | |
vector step = chv("step"); | |
int connectPoints = chi("connect"); | |
vector direct = {0,1,0}; | |
vector offset = 0.5; | |
vector rand = 0.0; | |
vector stepinc = 0.0; | |
for (int j = 0; j < walkers; j++){ | |
rand = 0.0; | |
for(int i = 0; i < steps; i++){ | |
direct = rand(i) - offset; | |
stepinc = rand(i) + step; | |
rand += direct * (random(i+j) - offset) * stepinc; | |
vector newPos = rand; | |
i@pt = addpoint(geoself(), newPos); | |
if(connectPoints && i > 0){ | |
int prim = addprim(geoself(), "polyline"); | |
addvertex(geoself(), prim, @pt-1); | |
addvertex(geoself(), prim, @pt); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment