Growth systems
in
Programming Questions
•
1 year ago
Hi everyone,
I am very new to processing but very keen to get through this problem and will be working through it all of tonight and tomorrow however I have become stuck already and would appreciate some guidelines or pointers for the best way to approach my problem. Essentially I am trying to recreate a growth script only in 2 dimensions for now, possibly moving on to 3 dimensions in the future if I have time. It is best illustrated by these diagrams which is a very simple set of diagrams explaining step by step my aims. They are not my diagrams but from a research paper by Adam Runions. Nervous systems design group have also produced work based on these rules and they have posted a very useful video explaining each step on vimeo: http://vimeo.com/25604611.
I appreciate this is potentially quite a large piece of code and I am not asking for anyone to simply do it for me but if anyone can offer any advice and pointers this would be really really helpful. I have a basic understanding of for loops, and general syntax but as I am a beginner I feel there may be shortcuts or functions I don't know about yet.
Thanks for your time
- //VARIABLES
- float nPoints;
- float r=10;
- //SETUP
- void setup(){
- size(700,700);
- stroke(0);
- smooth();
- background(255);
- }
- //DRAW
- void draw(){
- background(255);
- // Define boundary geometry
- ellipse(width/2, height/2, width-5, height-5);
- noFill();
- // Define root point[s] on boundary geometry (this will become the first vein node)
- float x = (width/2) + (((width-5)/2) * cos(PI));
- float y = (height/2) + (((width-5)/2) * sin(PI));
- ellipse (x,y,r,r);
- // I have commented the next step out and used a simpler version below as the random points generator won't return static values, constantly changing, I was hoping the for loop would fix this. Then I would need to know how to call each point?
- // Define random points within boundary geometry to become sources
- // nPoints=10;
- // for (int i=0; i<nPoints; i++){
- // float radius = random((width/2)-2.5);
- // float a = random(TWO_PI);
- // float x = width/2+cos(a )*radius;
- // float y = height/2+sin( a )*radius;
- // ellipse(x,y,3,3);
- // }
- // Three fixed points for testing sources - remove when random point distribution works
- translate (x,y);
- ellipse (500,40,3,3);
- ellipse (100, -200, 3,3);
- ellipse (350,200,3,3);
- // All sources need to be linked with closest vein node (in the first instance all sources are linked with the root)
- // Average vectors and normalise
- // Multiply averaged vector by radius of new vein node and place a new node in this position (the ellipse)
- PVector v1 = new PVector(500, 40);
- PVector v2 = new PVector(100, -200);
- PVector v3 = new PVector(350, 200);
- PVector va = PVector.add(v1, v2, v3);
- va.normalize();
- va.mult(r);
- ellipse (va.x,va.y,r,r);
- //I now need to make this an iterative process. Not sure of the best way of repeating the above steps as the initial conditions change each time with the creation of new vein nodes.
- //how do I make each vector link to each source point without typing the x and y coordinates manually (this is inefficent with many points)(can the sources become a class object that i can call or get the centre points for?
- //how do I make sure it only averages the vectors for sources to their nearest node poitn only
- //how, by doing the above can this then trigger secondary branches etc.
- //Apologies for all the questions, I am quite new to this but need some pointers to get me started
- }
1