catenaries
@author
void setup(){
size(500, 500);
mousePressed();
}
void draw(){}
void mousePressed(){
background(248, 248, 255);
noFill();
for(int i = 0; i < 150; i++){
float a = random(1, 2);
PVector middle = new PVector(random(width), random(height));
stroke(0, random(100, 255));
strokeWeight(1);
beginShape();
for(float x = 0; x <= width; x += 1){
float c = getCatenary(a, (x - middle.x) * 0.02);
vertex(x, middle.y - c);
}
endShape();
}
}
float getCatenary(float a, float x){
return a * ((exp(x / a) + exp(-x / a)) / 2.0);
}