What is a good algorithm for smoothing multiple quadratic Bézier curves?

I have a vector drawing application where users can draw lines using multiple quadratic bezier curves. A curve, for example, can have 5 points - points 0-2 for a quadratic bezier curve, and points 2-4 form another. If the slope @ of the end of the first bezier curve is not equal to the slope at the beginning of the second bezier curve, the curve is not smooth.

I want to enable a "smooth" button that users can click to smooth lines automatically. I want the overall MSE between the original and the smoothed curves to be small, as opposed to making the slopes match. However, 100% accuracy is not needed since the paint program is more important. Are there any good algorithms that can do this? I can't seem to find links to this.


source to share

1 answer

If you want to keep the overall shape of the line and make the corners round, you can: Create new points around each corner:

for example in the case where you describe there will be one angle in P2

We could use any epsilon <0.5 for this purpose. Lets use 0.1 So we have P1.9, P2.1.

P1.9.x = (9 * P2.x + P1.x)/10
P1.9.y = (9 * P2.y + P1.y)/10

P2.1.x = (9 * P2.x + P3.x)/10
P2.1.y = (9 * P2.y + P3.y)/10


You can do:

Bezier(P0, P1, P1.9);
Bezier(P1.9, P2, P2.1);
Bezier(P2.1, P3, P4);


instead of doing:

Bezier(P0, P1, P2);
Bezier(P2, P3, P4);


I hope this new answer helps. Otherwise, I would like to see an image describing the line view you have and the result you would like to see (this will help filter out answers that do not meet the criteria)

Old answer: Users enter 3 points for each bezier curve?

If you want to make a smooth line, you can do the following:

1.Creating new interpolated points:

p0.5[x] = (p0[x] + p1[x]) / 2;
p0.5[y] = (p0[y] + p1[y]) / 2;


1.b do the same for p1.5, p2.5 ... where p (N.5) uses p (N) and p (N + 1)

2. Instead of a picture:

Bezier(P0, P1, P2);
Bezier(P2, P3, P4);



Line(p0, 0.5);
Bezier(p0.5, p1, p1.5);
Bezier(p1.5, p2, p2.5);
Bezier(p2.5, p3, p3.5);
Line(p3.5, p4);


Hope it's easy to understand and help.



All Articles