Could someone give me a reason/proof why the control points do not lie on the Bézier Curve? Perhaps involving Bernstein Polynomials, if possible?
Thanks!
bezier-curve
Could someone give me a reason/proof why the control points do not lie on the Bézier Curve? Perhaps involving Bernstein Polynomials, if possible?
Thanks!
You can see that it will be difficult to solve this satisfactorily by considering the case where the points to be interpolated are at the extrema of a sinusoidal curve. Any reasonable solution should have horizontal tangents at the points, but this is not possible with quadratic curves.
Peter has described how to achieve continuity of the tangents with many arbitrary choices. You can reduce those choices to a single choice by requiring continuity in the derivatives, not just their directions (which determine the tangents). This looks nice formally, but it can lead to rather wild curves, since a single choice of control point at one end then determines all the control points (since you now have to take equal steps on both sides of the points in Peter's method), and these may end up quite far away from the original points – again, take the case of the extrema of a sinusoidal; this will cause the control points to oscillate more and more as you propagate them.
What I would try in order to get around these problems, if you really have to use quadratic Bézier curves, is to use some good interpolation method, e.g. cubic splines, and calculate intermediate points between the given points, along with tangent directions at the given points and the intermediate points. Then you can draw quadratic Bézier curves through all the points, given and intermediate, and determine control points by intersecting the tangents. This wouldn't work without the intermediate points, because the tangents might not intersect at reasonable points – again, think of the extrema of a sinuisoidal, where the desired tangents are in fact parallel – but I think it should work with the intermediate points – for instance, in the sinusoidal example, the intermediate points would be at the inflection points of the sinusoidal, and the tangents would intersect at suitable control points.
As you're probably aware, you can put the control points wherever you like, so this answer isn't about where the control points should go, but about how to put them where you want them. If I understand correctly, you want them to be at the same distance from $B$ as the red and green $B_1$ and $B_2$, but not on the lines $AB$ and $BC$, but on a line perpendicular to the bisector of $\angle ABC$.
So you need a vector pointing along that bisector. Several operations will require normalizing vectors, so I'll denote by $n(\vec x)=\vec x/|\vec x|$ the unit vector along $\vec x$; in coordinates, this would be
$$x_1'=\frac{x_1}{\sqrt{x_1^2+x_2^2}}\;,$$ $$x_2'=\frac{x_2}{\sqrt{x_1^2+x_2^2}}\;.$$
If we denote by $\vec a, \vec b, \vec c$ the vectors for points $A$, $B$ and $C$, respectively, and the differences $\vec a - \vec b$ and $\vec c - \vec b$ by $\Delta\vec a$ and $\Delta\vec c$, respectively, then the vector $\vec m=n(n(\Delta \vec a)+n(\Delta \vec c))$ is a unit vector along the bisector of $\angle ABC$.
Now comes the tricky part. It's easy to get just any vector perpendicular to $\vec m$, but if I understand correctly you want to go different lengths to the two sides, corresponding to $1/6$ of the length of the corresponding line segment, so you have to get the signs right. You can do this by projecting $\vec m$ out of $\Delta \vec a$ and $\Delta \vec c$, respectively:
$$\vec m_{a}=n(\Delta\vec a-(\Delta\vec a\cdot\vec m)\vec m)\;,$$ $$\vec m_{c}=n(\Delta\vec c-(\Delta\vec c\cdot\vec m)\vec m)\;.$$
Then you just have to add the desired multiples of these vectors to $\vec b$:
$$\vec b_1 = \vec b + \frac{|\Delta\vec a|}6 \vec m_a\;,$$ $$\vec b_2 = \vec b + \frac{|\Delta\vec c|}6 \vec m_c\;.$$
[Edit in response to the comment:]
I'm not sure whether I fully understand what you're asking for since I don't know what "initial formula" refers to (and the comment is partly ungrammatical), but I gather that you're more comfortable with coordinate notation than with vector notation, so I'll write all the equations out in coordinate notation; I hope that will enable you to implement them.
I'd already done this for the normalization operation; so here again for completeness: The operation $n(\vec x)$ applied to the vector $\vec x$ with coordinates $(x_1,x_2)$ results in a unit vector $\vec x'=\vec x/|\vec x|$ with coordinates $(x_1',x_2')$ given by
$$x_1'=\frac{x_1}{\sqrt{x_1^2+x_2^2}}\;,$$ $$x_2'=\frac{x_2}{\sqrt{x_1^2+x_2^2}}\;.$$
The coordinates $(\Delta a_1,\Delta a_2)$ of the vector $\Delta\vec a$ are given by $\Delta a_1=a_1-b_1$ and $\Delta a_2=a_2-b_2$, respectively, and likewise $\Delta c_1=c_1-b_1$ and $\Delta c_2=c_2-b_2$ for the coordinates $(\Delta c_1,\Delta c_2)$ of the vector $\Delta\vec c$.
The scalar product $\vec x\cdot\vec s$ of vectors $\vec x$ and $\vec s$ with coordinates $(x_1,x_2)$ and $(s_1,s_2)$, respectively, is $x_1s_1+x_2s_2$, so e.g. the coordinates of $\Delta\vec a-(\Delta\vec a\cdot\vec m)\vec m$ are $\Delta a_1-(\Delta a_1 m_1+\Delta a_2m_2)m_1$ and $\Delta a_2-(\Delta a_1 m_1+\Delta a_2m_2)m_2$. The norm (length) $|\vec x|$ of a vector $\vec x$ with coordinates $(x_1,x_2)$ is given by $\sqrt{x_1^2+x_2^2}$, so the first coordinate of the first of the last two equations is
$$b_{11}=b_1+\frac{\sqrt{\Delta a_1^2+\Delta a_2^2}}6m_{a1}\;.$$
I hope that's roughly what you were looking for.
Best Answer
I assume that by "control points" you mean the intermediate control points, because the curve interpolates between the first control point and the last one.
Your statement as phrased is not true in all cases. However, if I guess at your intention...
Consider that a point $P(t)$ on the curve defined by control points $P_i$ is $P(t) = \Sigma_{i=0}^n P_i b_{i,n}(t)$ (using Wikipedia's notation for the Bernstein basis polynomials). For the right hand side of that to be identically $P_j$ we require $b_{j,n}(t) = 1$ and $\forall k\ne j : b_{k,n}(t) = 0$. But the only cases for which this is possible are $j=0$, $t=0$ and $j=n$, $t=1$.
To prove that latter statement, take the formula for the Bernstein basis polynomials: $b_{k,n}(t) = {}^{n}C_{k} t^k (1-t)^{n-k}$. For this to evaluate to $0$ when $0 \le k \le n$ and $k, n \in \mathbb{N}$ we require $t=0$ or $t=1$. It is left as an exercise to demonstrate that these correspond to the first and last control points.