Rational Quadratic Bézier


This was a homework question from the class that I found interesting. The proof method here is quite different from what was outlined in class by Dr. Wang.

§ Question 1

Circular Arc — Let C\mathcal{C} be the unit circle centred at the origin and A,B∈CA, B \in \mathcal{C} be endpoints of an arc subtending a central angle of θ∈(0,π).\theta \in (0, \pi).

Represent this circular arc as a rational quadratic Bézier curve

P(t)=(1−t)2P0+2wt(1−t)P1+t2P2(1−t)2+2wt(1−t)+t2, t∈[0,1]. P(t) = \frac{(1-t)^2 P_0 + 2 w t (1-t) P_1 + t^2 P_2}{(1-t)^2 + 2 w t (1-t) + t^2},\ t \in [0, 1].

Give control points P0,P1,P2P_0, P_1, P_2 and weight ww, show that w=cos⁡(θ/2)w = \cos(\theta / 2).

§ Solution

Let P0=AP_0 = A and P2=BP_2 = B so that P(0)=AP(0) = A and P(1)=B.P(1) = B. AA and BB being points on the unit circle are represented by A=⟨cos⁡α,sin⁡α⟩A = \langle\cos\alpha, \sin\alpha\rangle and B=⟨cos⁡β,sin⁡β⟩.B = \langle\cos\beta, \sin\beta\rangle. Assume wlog. that β>α\beta > \alpha so that the subtended angle is given by θ=β−α,\theta = \beta - \alpha, and that the origin of our local coordinate frame is at the centre of the circle.

At t=0.5t=0.5 the curve should be the midpoint of our circular arc MM,

P(0.5)=M=0.5P0+wP1+0.5P21+w(1+w)M=12(P0+P2)+wP1(1+w)M−wP1=12(P0+P2)⏟X.\begin{align*} P(0.5) = M &= \frac{0.5P_0 + wP_1 + 0.5P_2}{1+w}\\ (1+w)M &= \frac{1}{2}(P_0 + P_2) + wP_1\\ (1+w)M - wP_1 &= \underbrace{\frac{1}{2}(P_0 + P_2)}_{X}. \end{align*}

Observe that XX is midpoint of the chord connecting the end-points of the circular arc. From the above XX, MM, and P1P_1 are colinear implying that there exists scalars z,k∈Rz,k \in \mathbb{R} such that P1=zM=zkXP_1 = zM = zkX, yielding the constraint

∥X(1−wk−wzk)∥=(1−wk−wzk)∥X∥=1.(†) \|X(1 - wk - wzk)\| = (1 - wk - wzk)\|X\| = 1. \tag{\dag}

We have that ∥M∥=1\|M\| = 1 from the fact that MM is on the circle, this implies k=∥X∥−1.k = \|X\|^{-1}. From the illustration, we have that ∠XOP0=θ/2\angle{XOP_0} = \theta / 2 thus cos⁡(θ/2)=∥X∥\cos(\theta / 2) = \|X\| and k = sec⁡(θ/2)k~=~\sec(\theta / 2).

Next, notice that ∥P1∥=∥zM∥=z∥M∥=z\|P_1\| = \|zM\| = z\|M\| = z is equivalent to finding ∥X∥+∥XP1‾∥\|X\| + \|\overline{XP_1}\|. We found ∥X∥\|X\| previously, enabling us to solve for ∥XP1‾∥\|\overline{XP_1}\| — it is the tangent of the angle formed by ∠P1P0X=γ\angle P_1P_0X = \gamma times the length XP0‾\overline{XP_0}.

To find γ\gamma, we can use the fact the inner product of two direction vectors is proportional to the cosine of the angle, or cos⁡θ=(A⋅B)/(∥A∥∥B∥)\cos\theta = (A \cdot B) / (\|A\|\|B\|).

The direction of P1P0‾\overline{P_1P_0} is given by the tangent of the circle at P(0)P(0) by definition of the Bézier curve, and the direction of P0P2‾\overline{P_0P_2} is the difference between points.

γ=arccos⁡(P′(0)⋅P0P1‾∥P′(0)∥∥P0P1‾∥)=arccos⁡(⟨−sin⁡α,cos⁡α⟩⋅⟨cos⁡β−cos⁡α,sin⁡β−sin⁡α⟩∥⟨cos⁡β−cos⁡α,sin⁡β−sin⁡α⟩∥)=arccos⁡(−sin⁡(α)(cos⁡β−cos⁡α)+cos⁡(α)(sin⁡β−sin⁡α)(cos⁡β−cos⁡α)2+(sin⁡β−sin⁡α)2)=arccos⁡(cos⁡αsin⁡β−sin⁡αcos⁡β2−2cos⁡(β−α))=arccos⁡(sin⁡(θ)2−2cos⁡(θ))=arccos⁡(∥sin⁡(θ)2−2cos⁡(θ)∥)=arccos⁡[(12⋅sin⁡(θ)1−cos⁡(θ))2]=arccos⁡[12⋅sin⁡2(θ)1−cos⁡(θ)]=arccos⁡[12⋅1−cos⁡2(θ)1−cos⁡(θ)]=arccos⁡[12⋅(1−cos⁡(θ))(1+cos⁡(θ))1−cos⁡(θ)]=arccos⁡[1+cos⁡(θ)2]=arccos⁡[cos⁡(θ2)]=θ2\begin{align*} \gamma &= \arccos\left(\frac{P'(0) \cdot \overline{P_0P_1}}{\|P'(0)\|\|\overline{P_0P_1}\|}\right)\\ &= \arccos\left(\frac{\langle -\sin\alpha, \cos\alpha\rangle \cdot \langle \cos\beta - \cos\alpha, \sin\beta - \sin\alpha \rangle}{\|\langle \cos\beta - \cos\alpha, \sin\beta - \sin\alpha \rangle\|}\right)\\ &= \arccos\left(\frac{-\sin(\alpha)(\cos\beta - \cos\alpha) + \cos(\alpha)(\sin\beta - \sin\alpha)}{\sqrt{(\cos\beta - \cos\alpha)^2 + (\sin\beta - \sin\alpha)^2}}\right)\\ &= \arccos\left(\frac{\cos\alpha\sin\beta - \sin\alpha\cos\beta}{\sqrt{2 - 2\cos(\beta - \alpha)}}\right)\\ &= \arccos\left(\frac{\sin(\theta)}{\sqrt{2 - 2\cos(\theta)}}\right)\tag{using $\theta = \beta - \alpha$}\\ &= \arccos\left(\left\|\frac{\sin(\theta)}{\sqrt{2 - 2\cos(\theta)}}\right\|\right)\tag{$\gamma \in \mathbb{R}^{+}$ by construction}\\ &= \arccos\left[\sqrt{\left(\frac{1}{\sqrt{2}}\cdot\frac{\sin(\theta)}{\sqrt{1 - \cos(\theta)}}\right)^2}\right]\tag{definition of abs. value}\\ &= \arccos\left[\sqrt{\frac{1}{2}\cdot\frac{\sin^2(\theta)}{1 - \cos(\theta)}}\right]\\ &= \arccos\left[\sqrt{\frac{1}{2}\cdot\frac{1 - \cos^2(\theta)}{1 - \cos(\theta)}}\right]\tag{using $\cos^2\theta + \sin^2\theta = 1$}\\ &= \arccos\left[\sqrt{\frac{1}{2}\cdot\frac{(1 - \cos(\theta)) (1 + \cos(\theta))}{1 - \cos(\theta)}}\right]\tag{difference of squares}\\ &= \arccos\left[\sqrt{\frac{1 + \cos(\theta)}{2}}\right]\tag{half angle identity}\\ &= \arccos\left[\cos\left(\frac{\theta}{2}\right)\right]\\ &= \frac{\theta}{2}\\ \end{align*}

Solving for zz,

∥P1∥=z=∥X∥+∥XP0‾∥tan⁡γ=cos⁡(θ/2)+sin⁡(θ/2)tan⁡(θ/2)=sec⁡(θ/2).\begin{align*} \|P_1\| = z &= \|X\| + \|\overline{XP_0}\|\tan\gamma\\ &= \cos(\theta / 2) + \sin(\theta / 2)\tan(\theta / 2)\\ &= \sec(\theta / 2). \end{align*}

Plugging z=k=sec⁡(θ/2)z = k = \sec(\theta / 2) into (†\dag) gives

1=(1−wk−wzk)∥X∥=[1−wsec⁡(θ/2)−wsec⁡2(θ/2)]cos⁡(θ/2)sec⁡(θ/2)=1−wsec⁡(θ/2)−wsec⁡2(θ/2)1=cos⁡(θ/2)−w−wsec⁡(θ/2)cos⁡(θ/2)+1=w+wsec⁡(θ/2)cos⁡(θ/2)+1=w(1+sec⁡(θ/2))w=cos⁡(θ/2)+1sec⁡(θ/2)+1w=cos⁡(θ/2)\begin{align*} 1 &= (1 - wk - wzk)\|X\|\\ &= \left[1 - w\sec(\theta / 2) - w\sec^2(\theta / 2)\right]\cos(\theta/2)\\ \sec(\theta/2) &= 1 - w\sec(\theta / 2) - w\sec^2(\theta / 2)\\ 1 &= \cos(\theta / 2) - w - w\sec(\theta / 2)\\ \cos(\theta / 2) + 1 &= w + w\sec(\theta / 2)\\ \cos(\theta / 2) + 1 &= w(1 + \sec(\theta / 2))\\ w &= \frac{\cos(\theta / 2) + 1}{\sec(\theta / 2) + 1}\\ w &= \cos(\theta / 2) \end{align*}

Therefore, P0=A,P1=12sec⁡2(θ/2)(A+B),P2=B,w=cos⁡(θ/2)P_0 = A, P_1 = \frac{1}{2}\sec^2(\theta / 2) (A + B), P_2 = B, w = \cos(\theta / 2).

§ Question 2

Semi-circle – Represent the semi-circle x2+y2−1=0,y≥0x^2 + y^2 - 1 = 0, y \geq 0 as a rational quadratic Bézier curve.

§ Solution

Plugging in the results from part A, we get the following expression

P(t)=(1−t)2P0+sec⁡(θ/2)t(1−t)(P0+P2)+t2P2(1−t)2+2cos⁡(θ/2)t(1−t)+t2, t∈[0,1]. P(t) = \frac{(1-t)^2 P_0 + \sec(\theta / 2) t (1-t) (P_0 + P_2) + t^2 P_2}{(1-t)^2 + 2 \cos(\theta / 2) t (1-t) + t^2},\ t \in [0, 1].

Taking the limit of the subtended angle θ\theta as it tends towards π\pi yields an expression for representing a semi-circle with a rational Bézier,

lim⁡θ→πP(t)=lim⁡θ→π(1−t)2P0+sec⁡(θ/2)t(1−t)(P0+P2)+t2P2(1−t)2+2cos⁡(θ/2)t(1−t)+t2.\begin{align*} \lim_{\theta \to \pi} P(t) &= \lim_{\theta \to \pi}\frac{(1-t)^2 P_0 + \sec(\theta / 2) t (1-t) (P_0 + P_2) + t^2 P_2}{(1-t)^2 + 2 \cos(\theta / 2) t (1-t) + t^2}. \end{align*}

The denominator of the above expression can be solved directly yielding (1−t)2+t2 (1-t)^2 + t^2.

Next, we focus on evaluating the numerator. Following the assumptions we made about A,BA, B, and θ\theta at the beginning, we have that the limit as θ→π\theta \to \pi is the same as the limit as both α→0\alpha \to 0 and β→π.\beta \to \pi. This enables the numerator to be expressed as the following expression

(1−t)2lim⁡α→0⟨cos⁡α,sin⁡α⟩+t(1−t)lim⁡(α,β)→(0,π)sec⁡(β−α2)⟨cos⁡α+cos⁡β,sin⁡α+sin⁡β⟩+t2lim⁡β→π⟨cos⁡β,sin⁡β⟩.\begin{align*} &(1-t)^2\lim_{\alpha \to 0} \langle \cos\alpha, \sin\alpha\rangle\\ &\quad+ t (1-t) \lim_{(\alpha, \beta) \to (0, \pi)} \sec\left(\frac{\beta - \alpha}{2}\right) \left\langle \cos\alpha + \cos\beta, \sin\alpha + \sin\beta\right\rangle\\ &\quad+ t^2 \lim_{\beta \to \pi} \langle\cos\beta, \sin\beta\rangle. \end{align*}

The limits in the first and third line are trivial. We shift our focus to the second line as lim⁡θ→π/2sec⁡θ\lim_{\theta \to \pi / 2} \sec\theta is indeterminant.

Using the identity cos⁡α−cos⁡β=∓2sin⁡(A+B)sin⁡(∓A±B)\cos \alpha - \cos \beta = \mp2 \sin(A+B) \sin(\mp A\pm B), we have that

lim⁡(α,β)→(0,π)sec⁡(β−α2)⟨cos⁡α+cos⁡β,sin⁡α+sin⁡β⟩=2lim⁡(α,β)→(0,π)sec⁡(β−α2)⟨cos⁡(α+β2)cos⁡(α−β2),sin⁡(α+β2)cos⁡(α−β2)⟩=2lim⁡(α,β)→(0,π)sec⁡(β−α2)⟨cos⁡(α+β2)cos⁡(β−α2),sin⁡(α+β2)cos⁡(β−α2)⟩=2lim⁡(α,β)→(0,π)⟨cos⁡(α+β2),sin⁡(α+β2)⟩= 2⟨cos⁡(π2),sin⁡(π2)⟩= 2⟨0,1⟩\begin{align*} &\lim_{(\alpha, \beta) \to (0, \pi)}\sec\left(\frac{\beta - \alpha}{2}\right) \left\langle \cos\alpha + \cos\beta, \sin\alpha + \sin\beta\right\rangle\\ =&2\lim_{(\alpha, \beta) \to (0, \pi)}\sec\left(\frac{\beta - \alpha}{2}\right) \left\langle \cos\left(\frac{\alpha + \beta}{2}\right)\cos\left(\frac{\alpha - \beta}{2}\right), \sin\left(\frac{\alpha + \beta}{2}\right)\cos\left(\frac{\alpha - \beta}{2}\right)\right\rangle\\ =&2\lim_{(\alpha, \beta) \to (0, \pi)}\sec\left(\frac{\beta - \alpha}{2}\right) \left\langle \cos\left(\frac{\alpha + \beta}{2}\right)\cos\left(\frac{\beta - \alpha}{2}\right), \sin\left(\frac{\alpha + \beta}{2}\right)\cos\left(\frac{\beta - \alpha}{2}\right)\right\rangle\\ =&2\lim_{(\alpha, \beta) \to (0, \pi)}\left\langle \cos\left(\frac{\alpha + \beta}{2}\right), \sin\left(\frac{\alpha + \beta}{2}\right)\right\rangle\\ =&\ 2\Big\langle\cos\left(\frac{\pi}{2}\right), \sin\left(\frac{\pi}{2}\right)\Big\rangle\\ =&\ 2\langle 0, 1\rangle \end{align*}

Finally, the semi-circle is represented by the following rational quadratic Bézier curve

P(t)=(1−t)2⟨1,0⟩+2t(1−t)⟨0,1⟩+t2⟨−1,0⟩(1−t)2+t2.P(t) = \frac{(1-t)^2\langle 1, 0\rangle + 2t(1-t) \langle 0, 1\rangle + t^2 \langle -1, 0\rangle}{(1-t)^2 + t^2}.