[Math] Calculating control points of Cubic Bézier curve

bezier-curve

I'm trying to draw different arcs with a Cubic Bezier curve and my problem is that after reading different blogs that explain it, I can draw only a 90degree arc using this article. Is it possible if I have the starting X/Y coordinates, the circle radius and length of the arc to calculate other 3 coordinates?(my problem is basicly the different lenght of the arc I want to draw)

Best Answer

For a circular arc with angular span $\theta$ and unit radius, described as $C(t) = (cos(t), sin(t))$, where $t=[0, \theta]$, a good cubic Bezier curve approximation can be obtained with the following control points:

$P_0 = (1, 0)$,
$P_1 = (1, 0) + L(0,1)$,
$P_2 = (cos\theta, sin\theta) - L (-sin\theta, cos\theta)$,
$P_3 = (cos\theta, sin\theta) $

where $L = \frac43tan(\frac\theta4)$

The cubic Bezier curve approximation obtained this way always interpolates the two end points and the mid-point of the circular arc and the approximation error is always positive, which means the cubic Bezier curve is always "outside" the circular arc. The maximum radial error $(x(t)^2 + y(t)^2 - 1)$ from this approximation can also be computed analytically as

$E_{max} = \frac4{27} ( sin^6(\frac\theta4)/cos^2(\frac\theta4) )$

You can use this maximum error formula to decide how many Bezier segments you want to break up your arc into and then use the control points formula to obtain control points for each Bezier segment.