Merge two or more cubic Bézier curves for optimization

2.9k Views Asked by At

I am looking for an algorithm which can merge several cubic Bezier curves. For instance, I have a lot of cubic Bezier that are joined to form a poly-Bezier curve. The idea is to merge dynamically some of these cubic Bezier segments to one cubic Bezier in order to minimize the number of the Bézier curves.

Anyone can help me for this problem?

Thank you for advance.

1

There are 1 best solutions below

7
On

In general, several Bezier curves (even two) can not be represented exactly as a single Bezier curve. So, the best you can hope for is an approximation.

I'd suggest the following approach.

Take two of your curves, say $A(t)$ and $B(t)$. Assume they are both parameterized by $t \in [0,1]$. Calculate four equally-spaced points on these two curves. These would be $P_1 = A(0)$, $P_2= A(2/3)$, $P_3 = B(1/3)$, $P_3 = B(1)$. Then calculate a Bezier curve $C(t)$ such that $C(0) = P_1$, $C(1/3) = P_2$, $C(2/3) = P_3$, $C(1) = P_4$. Then check to see whether $C$ is "close" enough to $A$ and $B$.

Once you have this basic "two-into-one" utility working, there are numerous ways to use it to combine longer strings of curves.