Saturday 29 September 2012

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

No comments:

Post a Comment