next up previous contents
Next: error estimation Up: cubic Bézier curve Previous: cubic Bézier curve   Contents

control points choice

Since we want the Bézier curve endpoints to match the elliptical arc endpoints, finding the first two control points of the cubic Bézier curve is done as for linear Bézier curves:

    $\displaystyle B_3(0)$ $\displaystyle = E(\eta_1) \Rightarrow P_1 = E(\eta_1)$
    $\displaystyle B_3(1)$ $\displaystyle = E(\eta_2) \Rightarrow P_2 = E(\eta_2)$

Matching of the Bézier curve and elliptical arc slopes at endpoints allows us to define the two remaining control points using only two scalar parameters:

    $\displaystyle B_3'(0)$ $\displaystyle = k_1 E'(\eta_1) \Rightarrow 3(Q_1 - P_1) = k_1 E'(\eta_1)$
    $\displaystyle B_3'(1)$ $\displaystyle = k_2 E'(\eta_2) \Rightarrow 3(P_2 - Q_2) = k_2 E'(\eta_2)$

In order to have the same orientation for the elliptical arc and its approximation, $ k_1$ and $ k_2$ should both be positive. Replacing the $ k_1$ and $ k_2$ scalars by $ \alpha_1=k_1/3$ and $ \alpha_2=k_2/3$ leads to the simple definition of $ Q_1$ and $ Q_2$:

    $\displaystyle Q_1$ $\displaystyle = P_1 + \alpha_1 E'(\eta_1) \qquad \alpha_1 > 0$
    $\displaystyle Q_2$ $\displaystyle = P_2 - \alpha_2 E'(\eta_2) \qquad \alpha_2 > 0$

With these definitions of the control points, the first and second derivatives of the Bézier curves are:

    $\displaystyle B_3'(0)$ $\displaystyle = 3(Q_1 - P_1)$ $\displaystyle =$ $\displaystyle \phantom{-}3\alpha_1 E'(\eta_1)$
    $\displaystyle B_3''(0)$ $\displaystyle = 6[Q_2-2Q_1+P_1]$ $\displaystyle =$ $\displaystyle \phantom{-}6[E(\eta_2) - E(\eta_1) - 2 \alpha_1 E'(\eta_1) - \alpha_2 E'(\eta_2)]$
    $\displaystyle B_3'(1)$ $\displaystyle = 3(P_2 - Q_2)$ $\displaystyle =$ $\displaystyle \phantom{-}3\alpha_2 E'(\eta_2)$
    $\displaystyle B_3''(1)$ $\displaystyle = 6[P_2-2Q_2+Q_1]$ $\displaystyle =$ $\displaystyle -6[E(\eta_2) - E(\eta_1) - \alpha_1 E'(\eta_1) - 2 \alpha_2 E'(\eta_2)]$

introducing these derivatives in equation (1) gives the signed curvatures at Bézier curve endpoints:

\begin{equation*}\left\{\begin{aligned}\widetilde{C}_B(0) &= \frac{2 [x'_1(y_2 -...
...{3 \alpha_2^2 ({x'_2}^2+{y'_2}^2)^{3/2}} \\  \end{aligned}\right.\end{equation*}

The curvatures of the elliptical arc at endpoints are computed the same way, introducing the ellipse parametric equation derivatives (4) and (5) into equation (1):

\begin{equation*}\left\{\begin{aligned}\widetilde{C}_E(\eta_1) &= \frac{x'_1 y''...
...'_2 - y'_2 x''_2}{({x'_2}^2+{y'_2}^2)^{3/2}} \end{aligned}\right.\end{equation*}

where $ x''_{\eta_i}$ and $ y''_{\eta_i}$ are the coordinates of $ E''(\eta_i)$.

In order to find the values of $ \alpha_1$ and $ \alpha_2$, we state that the signed curvature of the Bézier curve and elliptical arc at endpoints should be the same, so we combine systems (13) and (14):

$\displaystyle \left\{ \begin{aligned}2 [x'_1(y_2 - y_1) - y'_1(x_2 - x_1)] + 2 ...
... - x'_1 y'_2] -3 \alpha_2^2 [x'_2 y''_2 - y'_2 x''_2] &= 0 \end{aligned}\right.$

This system can be further simplified by using the ellipse parametric equation (3) and its derivatives (4) and (5) which imply the following relations:

$\displaystyle \left\{\begin{aligned}x'_1(y_2 - y_1) - y'_1(x_2 - x_1) &= \phant...
...ta_2-\eta_1))\\  x'_2 y''_2 - y'_2 x''_2 &= \phantom{-}a b \end{aligned}\right.$

So after simplifying by $ a b$, the system becomes:

$\displaystyle \left\{\begin{aligned}2(1-\cos(\eta_2-\eta_1)) - 2\alpha_2\sin(\e...
...-\eta_1)) - 2\alpha_1\sin(\eta_2-\eta_1) - 3\alpha_2^2 = 0 \end{aligned}\right.$

Introducing $ \tau=\tan\left(\frac{\eta_2-\eta_1}{2}\right)$ and multiplying by $ 1+\tau^2$ this can be written:

$\displaystyle \left\{\begin{aligned}4\tau^2 - 4\tau\alpha_2 - 3(1+\tau^2)\alpha...
... 0 \\  4\tau^2 - 4\tau\alpha_1 - 3(1+\tau^2)\alpha_2^2 = 0 \end{aligned}\right.$

Subtracting one equation from the other, we obtain:

    $\displaystyle (\alpha_2-\alpha_1) \big(3(1+\tau^2)(\alpha_1 +\alpha_2) - 4\tau\big) = 0$

This implies the system has two sets of solutions. Since we have preprocessed our arcs to ensure $ \eta1<\eta_2\le\eta_1+\pi/2$, we know that $ 0<=\tau<=1$, so $ \tau$ can be computed without loss of accuracy and $ \tau^2$ can be extracted from square roots without sign change. The first set of solutions is:

      $\displaystyle \left\{\begin{aligned}&\alpha_2 = \alpha_1\\ &3(1+\tau^2)\alpha_1^2 + 4\tau \alpha_1 - 4\tau^2 = 0 \end{aligned}\right.$
    $\displaystyle \Rightarrow$ $\displaystyle \left\{\begin{aligned}&\alpha_1 = \left(\frac{2\tau}{1+\tau^2}\ri...
...\tau^2}\right)\left(\frac{-1\pm\sqrt{4+3\tau^2}}{3}\right) \end{aligned}\right.$

and the second set is:

      $\displaystyle \left\{\begin{aligned}&\alpha_2 = \frac{4\tau}{3(1+\tau^2)}-\alph...
...\tau \alpha_1 + \frac{4\tau^2(1-3\tau^2)}{3(1+\tau^2)} = 0 \end{aligned}\right.$
    $\displaystyle \Rightarrow$ $\displaystyle \left\{\begin{aligned}&\alpha_1 = \left(\frac{2\tau}{1+\tau^2}\ri...
...}{1+\tau^2}\right)\left(\frac{1\mp \tau\sqrt{3}}{3}\right) \end{aligned}\right.$

It is obvious that all these solutions are real ones. For the first set of solutions it is also obvious that one solution is always positive while the other one is always negative. Remembering we are only interested in positive solutions, we can choose the positive one. For the second set of solutions, one solution becomes negative or null when $ \tau\ge1/\sqrt{3}$, i.e. if $ \eta_2-\eta_1\ge\frac{\pi}{3}$.

The full set of positive solutions is therefore:

\begin{equation*}\left\{\begin{aligned}\alpha_1&= \sin(\eta_2-\eta_1) \frac{\sqr...
...eft(\frac{\eta_2-\eta_1}{2}\right)}-1}{3}\\  \end{aligned}\right.\end{equation*}

or (only if $ \eta_2-\eta_1<\frac{\pi}{3}$):

\begin{equation*}\left\{\begin{aligned}\alpha_1&= \sin(\eta_2-\eta_1) \frac{1+\t...
...t(\frac{\eta_2-\eta_1}{2}\right)\sqrt{3}}{3} \end{aligned}\right.\end{equation*}

or (only if $ \eta_2-\eta_1<\frac{\pi}{3}$):

\begin{equation*}\left\{\begin{aligned}\alpha_1&= \sin(\eta_2-\eta_1) \frac{1-\t...
...t(\frac{\eta_2-\eta_1}{2}\right)\sqrt{3}}{3} \end{aligned}\right.\end{equation*}

Some tests show that all these solutions are acceptable, there is not a unique way to set up a cubic Bézier curve with the matching criteria we have chosen. Since the first solution is both the simplest one ( $ \alpha_1 = \alpha_2$) and has the wider applicability domain, we will use this one only and forget the other solutions.

\vspace{2ex}The control poin...
... \frac{\sqrt{4+3\tan^2\left(\frac{\eta_2-\eta_1}{2}\right)}-1}{3}

next up previous contents
Next: error estimation Up: cubic Bézier curve Previous: cubic Bézier curve   Contents
Luc Maisonobe 2005-05-29