I have been struggling to find out a solution for a case where i have a cubic Bezier curve where two arbitrary control points of the one are equal, therefore i should show that this curve can be the quadratic curve. Do you have any thoughts how to prove it?
[Math] Can a cubic Bezier curve be a quadratic one if two control points are equal from the cubic one
bezier-curvecurvesgeometry
Related Solutions
The simplest heuristic approximation method is the one proposed by Tiller and Hanson. They just offset the legs of the control polygon in perpendicular directions:
The blue curve is the original one, and the three blue lines are the legs of its control polygon. We offset these three lines, and intersect/trim them to get the points A and B. The red curve is the offset. It's only an approximation of the true offset, of course, but it's often adequate.
If the approximation is not good enough for your purposes, you split the curve into two, and approximate the two halves individually. Keep splitting until you're happy. You will certainly have to split the original curves at inflexion points, if any, for example.
Here is an example where the approximation is not very good, and splitting would probably be needed:
There is a long discussion of the Tiller-Hanson algorithm plus possible improvements on this web page.
The Tiller-Hanson approach is compared with several others (most of which are more complex) in this paper.
Another good reference, with more up-to-date materials, is this section from the Patrikalakis-Maekawa-Cho book.
For even more references, you can search for "offset" in this bibliography.
Let $(x,y)^R=(-y,x)$ represent rotation by $\pi/2$ counterclockwise and $$ \gamma(t)=(1-t)^3p_0+3t(1-t)^2p_1+3t^2(1-t)p_2+t^3p_3 $$ define a cubic bezier with control points $\{p_0,p_1,p_2,p_3\}$.
Suppose $p_0=(x_0,y_0)$, $p_3=(x_1,y_1)$, and $c=(c_x,c_y)$ are given so that $|p_0-c|=|p_3-c|=r$ ($p_3$ is counterclockwise from $p_0$). Then $p_1=p_0+\alpha(p_0-c)^R$ and $p_2=p_3-\alpha(p_3-c)^R$ where $$ \alpha=\frac43\tan\left(\frac14\cos^{-1}\left(\frac{(p_0-c)\cdot(p_3-c)}{r^2}\right)\right) $$ For a quarter of a circle, $\alpha=\frac43(\sqrt2-1)$, and $\gamma$ is no more than $0.00027$ of the radius of the circle off.
Here is a plot of $\gamma$ in red over the quarter circle in black. We really don't see the circle since it is no more than $0.1$ pixels off from $\gamma$ when the radius is $400$ pixels.
$\hspace{3.5cm}$
Computation of $\boldsymbol{\alpha}$
Looking at an arc with an angle of $\theta=\cos^{-1}\left(\frac{(p_0-c)\cdot(p_3-c)}{r^2}\right)$
$\hspace{1.5cm}$
we see that the distance from $c$ to the middle of the arc is $$ r\cos(\theta/2)+\frac34\alpha r\sin(\theta/2) $$ we wish to choose $\alpha$ so that this is equal to $r$. Solving for $\alpha$ gives $$ \begin{align} \alpha &=\frac43\frac{1-\cos(\theta/2)}{\sin(\theta/2)}\\ &=\frac43\tan(\theta/4) \end{align} $$
A Slight Improvement
Using a circle of radius $1$, the maximum error in radius produced using $\alpha=\frac43\tan(\theta/4)$ is approximately $$ 0.0741\cos^4(\theta/4)\tan^6(\theta/4) $$ and the error is always positive; that is, the cubic spline never passes inside the circle. Reducing $\alpha$ reduces the midpoint distance by $\frac34\sin(\theta/2)=\frac32\tan(\theta/4)\cos^2(\theta/4)$ times as much, so to distribute the error evenly between the positive and negative, a first guess, assuming that the amplitude of the radius is unchanged, would be to reduce $\alpha$ by $0.0247\cos^2(\theta/4)\tan^5(\theta/4)$.
A bit of investigation shows that, when equalizing the positive and negative swings of the radius, the amplitude increases and that $$ \alpha=\frac43\tan(\theta/4)-0.03552442\cos^2(\theta/4)\tan^5(\theta/4) $$ gives pretty even distribution of the error between positive and negative for $\theta\le\pi/2$. The maximum error, both positive and negative, is approximately $$ 0.0533\cos^4(\theta/4)\tan^6(\theta/4) $$ When $\theta=\pi/2$, this agrees with the article mentioned by bubba in comments.
Note however, that in minimizing the radial error from the circle, the actual variation in radius is increased. Using the simple formula for $\alpha$, which puts the cubic bezier outside the circle, the radius varies by $0.0741\cos^4(\theta/4)\tan^6(\theta/4)$. However, when we minimize the error, the radial variation increases to $0.1066\cos^4(\theta/4)\tan^6(\theta/4)$.
Best Answer
The cubic Bezier curve with control points $A$, $B$, $C$, $D$ has equation $$ P(t) = (1-t)^3A + 3t(1-t)^2B + 3t^2(1-t)C + t^3D $$ We can re-arrange this to get $$ P(t) = (-A + 3B -3C +D)t^3 + (3A-6B+3C)t^2 + (-3A+3B)t + A $$ So, the cubic curve will become quadratic if and only if $-A + 3B -3C +D = 0$.
This condition can also be written as $$ D - A = 3(C-B) $$ This has a nice geometric meaning: it says that the vector $\overrightarrow{AD}$ is three times the vector $\overrightarrow{BC}$.
As you can see, if two control points are equal, this does not mean that the curve will be quadratic.