next up previous contents
Next: error estimation Up: quadratic Bézier curve Previous: quadratic 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 quadratic Bézier curve is done as for linear Bézier curves, :

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

Matching of the Bézier curve and elliptical arc slopes at start point allows us to define the remaining control point using one scalar parameter:

    $\displaystyle B_2'(0) = k E'(\eta_1) \Rightarrow 2(Q - P_1) = k E'(\eta_1)\\ $

In order to have the same orientation for the elliptical arc and its approximation, $ k$ should be positive. Replacing $ k$ by $ \alpha=k/2$ leads to the simple definition of $ Q$:

    $\displaystyle Q = P_1 + \alpha E'(\eta_1) \qquad \alpha > 0$

We find $ \alpha$ by stating the Bézier curve slope should also match the arc slope at end point:

      $\displaystyle B_2'(1) = \tilde{k} E'(\eta_2)$
    $\displaystyle \Rightarrow$ $\displaystyle 2(P_2 - Q) = \tilde{k} E'(\eta_2)$
    $\displaystyle \Rightarrow$ $\displaystyle \det\left(P_2-P_1-\alpha E'(\eta_1),E'(\eta_2)\right)=0$
    $\displaystyle \Rightarrow$ $\displaystyle (x_2-x_1-\alpha x'_1)y'_2-(y_2-y_1-\alpha y'_1)x'_2=0$
    $\displaystyle \Rightarrow$ $\displaystyle \alpha=\frac{(x_2-x_1)y'_2-(y_2-y_1)x'_2}{x'_1y'_2-y'_1x'_2}$
    $\displaystyle \Rightarrow$ $\displaystyle \alpha=\frac{1-\cos(\eta_2-\eta_1)}{\sin(\eta_2-\eta_1)}$
    $\displaystyle \Rightarrow$ $\displaystyle \alpha=\tan\left(\frac{\eta_2-\eta_1}{2}\right)$

where $ x'_{\eta_i}$ and $ y'_{\eta_i}$ are the coordinates of $ E'(\eta_i)$. It is easy to verify that this also implies the symmetrical expression:


      $\displaystyle Q = P_2 - \tan\left(\frac{\eta_2-\eta_1}{2}\right)E'(\eta_2)$

If we have preprocessed our arcs to ensure $ \eta1<\eta_2\le\eta_1+\pi/2$, we know that $ 0<=\alpha<=1$. This implies that the orientation is right at both endpoints and also that $ \alpha$ can be computed without loss of accuracy. Equations (3) and (4) show that both $ E(\eta)$ and $ E'(\eta)$ are bounded by $ a$, so this preprocessing also ensures $ Q$ does not escape far away from points $ P_1$ and $ P_2$ (this could generate numerical overflows in some graphical packages).

\framebox[0.8\textwidth]{\parbox{0.75\textwidth}{%%
\vspace{2ex}The control poin...
...o}
Q &= P_2 - \tan\left(\frac{\eta_2-\eta_1}{2}\right) E'(\eta_2)
\end{align*}}}


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