Parametric lines.

Processing Experiments

COMPUTATIONAL DESIGN
1.9 – ? 2016

 

EXPERIMENT 07 – Grasshopper + Processing

Sending the object with fitness 100% into into Grasshopper. In this example the height with the highest fitness was the number 178. -when the GA have evolved an object with this height is get sent into GH.

The object with the highest fitness. In this case the number 178 in height.
The object with the highest fitness. In this case the number 178 in height.

 

EXPERIMENT 06 – Grasshopper + Processing

Send multiple lists from Processing into Grasshopper. This enables me to create different objects and send them as individual lists into GH. The most important was to delay the computation between the first sending process and the second. With no delay, the first list didn’t have time to be fully transfered before the second sending process overwrote it.

Send multiple lists into GH.
Send multiple lists into GH.

 

EXPERIMENT 05 – Grasshopper + Processing

I am sending 3D points into Grasshopper from Processing. Every time the script is called, it creates new random points in 3D space. I worked much with how to modify the list that is transfered from Processing to Grasshopper. It is transfered as one long string and you then need to split it on the right places and delete some characters.

Random points in 3D space. The spheres are created in GH.
Random points in 3D space. The spheres are created in GH.
 List modification. The goal is to represent points as GH does normally
List modification. The goal is to represent points as GH does normally

 

EXPERIMENT 04 – Grasshopper + Processing

I successfully managed to send an ellipse into Grasshopper from Processing. Every time the script is called, it creates a new random ellipse. You create the ellipse in Processing and package it as a list of strings. In Grasshopper you convert this string list into numbers.

From Processing into Grasshopper
From Processing into Grasshopper

 

EXPERIMENT 03 – Parametric lines

I learned this from Alexander Miller’s youtube video on vintage computer art.

Inspirational film called “Experiments in Motion Graphics” from 1968 featuring the computer generated art of John Whitney. https://archive.org/details/experimentsinmotiongraphics

Parametrics lines moving dynamically.
Parametrics lines moving dynamically.
// Variables
static final int NUM_LINES = 50;
float t;

void setup() {
    size(640, 640);
    background(0);
}


// saving frames for animation
//int x = 0;
void draw() {
    background(0);
    stroke(255);
    strokeWeight(2);
    
    translate(width/2, height/2);
    for (int i = 0; i < NUM_LINES; i++) {
        line(x1(t + i), y1(t + i), x2(t + i), y2(t + i)); 
    }
    t += 0.1;
    /*if ( (x % 30) == 0 ) {
        saveFrame("GA-####.png");
    }
    x++;*/
}

// Methods

float x1(float t){
     return sin(t/10) * 100 + sin(t/5) * 20; 
}

float y1(float t){
     return cos(t/10) * 100; 
}

float x2(float t){
     return sin(t/10) * 200 + sin(t) * 2; 
}

float y2(float t){
     return cos(t/20) * 200 + cos(t/12) * 20;
}

 

EXPERIMENT 02 – Processing + Grasshopper

  1. Download gHowl for Grasshopper and activate it in Grasshopper. http://www.food4rhino.com/project/ghowl?etx
  2. Download the Processing and Grasshopper files for this example. http://www.grasshopper3d.com/forum/topics/processing-to-grasshopper-real-time-communication
  3. Download the oscP5 library and put place it in the right folder. http://www.sojamo.de/libraries/oscP5/#installation
    “Unzip and put the extracted oscP5 folder into the libraries folder of your processing sketches. Reference and examples are included in the oscP5 folder.”
  4. Run program. (For more information see: http://www.grasshopper3d.com/group/ghowl)
  5. You can now learn to send different types of geometry.

Processing communicating with Grasshopper. Sending a 2D array.
Processing communicating with Grasshopper. Sending a 2D array.

 

EXPERIMENT 01 – Random 3D boxes

Experiment - Random boxes randomly place.
Experiment – Random boxes randomly place.
/*
23-09-16

Random 3D boxes randomly placed.

*/
void setup() {
size(640, 640, P3D);
background(255);

}

void draw() {

    translate(random(width), random(height), 0 ); 
    rotateY( random(PI) );
    rotateX( random(PI) );
    box( random(20,100), random(20,100), random(20,100) );
    fill(random(255));
    stroke(10);
    
  /*
    noStroke();
    lights();
    translate(random(width), random(height), random(100) );
    sphere( random(100) );
    
  */
}