I am just trying to understand the control points from a curve. The curve should behave like a Gaussian curve.
Unfortunately, I don’t really understand how to handle the control points.
Can someone please help me?
My current sketch for testing:
int []points = new int[12];
void setup() {
size(800, 800);
strokeWeight(2);
for (int i =0; i<12; i++)
points[i] = int(random(400));
}
void draw() {
background(220);
translate(width/4, height/4);
float xDist = 30;
for (int i =0; i<11; i++) {
// xy position
float x = i*xDist;
float x2 = (i+1)*xDist;
float y = points[i];
float y2 = points[i+1];
//control points
float cp1, cp2, cp3, cp4;
cp1 = x;
cp2 = y;
cp3 = x2;
cp4 = y2;
noFill();
curve(cp1, cp2, x, y, x2, y2, cp3, cp4);
fill(255);
circle(x, y, 10);
}
}
Thanks in advance!