Saturday, 29 September 2012

Interactive Hypotrochoid


I've just written an Interactive Hypotrochoid program to play with here:

http://www.dareinteractive.com/hypo/index.html

Looks like this:



Code:



/**
 Dare 2012 Interactive Hypotrochoids, 
 move mouse around to experiment with the
 parameters of this equation, press mouse to re-set.
 very much derived from Archim v2.1
 code here:
 http://www.archimy.com/examples/2d-ellipse.html
 **/

//z must be zero
float z = 0.0;

//t-parameter
float tmin = 0.0;
float tmax = 3.0*PI;//6.0*PI;
float tgrid =120.0;//400.0;

//Constant
float a;// = 5.0;
float b;// = 3.0;
float d;// = 5.0;
float k, m;

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

void draw() {

  translate(width/2, height/2);
  tmin++;
  tmax++;

  a = mouseX%width/3;
  d = mouseX%height/3;
  b = d/6;
  k = a - b;
  m = (a - b) / b;

  //Calculations
  float x = k * cos(tmin) + d * cos(m * tmin);
  float y = k * sin(tmax) - d * sin(m * tmax);
  noStroke();
  fill(120+mouseY%255, mouseY%255, 120+mouseX%255, 220);
  ellipse(x, y, 5, 5);
}

void mousePressed() {
  setup();
}



Hypotrochoids again

Hypotrochoid is a curve traced by a point attached to a circle of radius r rolling around the inside of a fixed circle of radius R, where the point is a distance d from the center of the interior circle...








Processing code:

/**
 adapted from some 

Archim v2.1

code here:
 http://www.archimy.com/examples/2d-ellipse.html

 change a, b, d for dramatic changes in scale, try
 float a = 5.0; //5.0 original values
 float b = 3.0;//3.0
 float d = 5.0;//5.0

 try:
 float a = 15.0*2; //5.0
 float b = 1.0*2;//3.0
 float d = 15.0*2;//5.0

 */
//z must be zero
float z = 0.0;

//t-parameter
float tmin = 0.0;
float tmax = 6.0*PI;//6.0*PI; /*try differant values here */
float tgrid = 400.0;//400.0;

/*Constants, affect scale and form hugely */
float a = 70.0; //5.0
float b =  -6.0;//3.0
float d = 70.0;//5.0
float k, m;

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

void draw() {

  translate(width/2, height/2);
  tmin++;
  tmax++;
  k = a - b;
  m = (a - b) / b;

  //Calculations
  float x = k * cos(tmin) + d * cos(m * tmin);
  float y = k * sin(tmax) - d * sin(m * tmax);
  noStroke();
  fill(123, 0, 255, 120);
  ellipse(x, y, 12, 12);
}



This site here provided some code in Archim v2.1 which I adapted for Processing and experimented with the parameters of the equation:  
http://www.archimy.com/examples/2d-hypotrochoid.html

Sunday, 16 September 2012

Prism installation V&A

Amongst these visualisations projected onto Keiichi Matsuda's prism structure is one of mine for air quality in London. The installation is inside the tallest cupola of the V&A. there was a nice photo of it on the BBC News website yesterday.



Monday, 3 September 2012

Last variation

Last variation on the forthcoming Prism designs I hope, Sulphur Dioxide, Ozone and Nitrogen Dioxide levels in central London