We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In processing we have the method bezierPoint() and vertexPoint().
We don't have a quadraticPoint() and I needed one.
I made one and I thought I drop it here cause it's not the most easy thing to figure out.
So here it is:
void setup() {
noFill();
strokeWeight(1);
beginShape();
vertex(20, 20);
quadraticVertex(80, 20, 50, 50);
endShape();
noStroke();
fill(255, 0, 0);
int steps = 10;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps);
float x = quadraticPoint(20, 80, 50, t);
float y = quadraticPoint(20, 20, 50, t);
ellipse(x, y, 5, 5);
}
}
public float quadraticPoint(float a, float b, float c, float t) {
return bezierPoint(a, a + ((b-a)*2/3.0f), c + ((b-c)*2/3.0f), c, t);
}
Comments
what is a quadraticPoint ?
It stays within the rectangle?
Well, we have curvePoint and bezierPoint: https://processing.org/reference/bezierPoint_.html https://processing.org/reference/curvePoint_.html
But we have nothing for something made with quadraticVertex. Maybe quadraticBezierPoint is a better name?
Here a method for when a shape is made with curveVertex. In this case curveVertexPoint might be a better name :)