# Parametric Equations

/Parametric equations express the points on a curve as a function of a variable. The images above were created by plotting a parametric equations in Processing. The equation was:

The video below was created by drawing lines between opposite points on the curve the equation produces. The colour of the curve changes based on it's length.

### Source Code

void setup() { size(1080, 720); frameRate(60); colorMode(HSB, 360, 100, 100); } //parametric equation parameters float a1 = 100; float b1 = 1; float c1 = 100; float d1 = 50; //increments corresponding parameter if true and decrements if false boolean reversed = false; boolean reversec = false; //time modifier float tMod = 0; void draw() { background(0); strokeWeight(3); //draw lines for (float t = tMod; t <= 0.005 * 5 + tMod + 0.004; t+= 0.005) { //first point float x1 = (cos(a1*t)-cos(b1*t)) *100 + width/2; float y1 = (sin(c1*(t ))-sin(d1*(t ))) * 100 + height/2; //second point float x2 = (cos(a1*(t + HALF_PI))-cos(b1*(t + HALF_PI))) *100 + width/2; float y2 = (sin(c1*(t + HALF_PI))-sin(d1*(t + HALF_PI))) * 100 + height/2; //length of line float lengthL = sqrt(pow(abs(x1-x2), 2) + pow(abs(y1-y2), 2)); //set colour based on length of line stroke(map(lengthL - 120, 0, 160, 0, 360), 100, 100); //draw line line(x1, y1, x2, y2); } //increase time modifier tMod += 0.0005; //change some parameters to create more interesting movement if (reversec) { c1-=0.001; } else { c1+=0.001; } if (c1 > 50) { reversec = true; } else if (c1 < 1) { reversec = false; } if (reversed) { d1-=0.001; } else { d1+=0.001; } if (d1 > 50) { reversed = true; } else if (d1 < 1) { reversed = false; } }

Wiki: Click Here

Processing: Click Here