Equation of a cubic Bezier curve

652 Views Asked by At

quadratic bezier curve

For a quadratic Bezier Curve defined by points $A, B, C$, with point $M$ on the curve interpolated by $i$,

When points $A, M, C$ and angle $\alpha$ are given, $i$ and $B$ are:

$$i^2 = \frac{(y_A-y_M)\sin\alpha-(x_A-x_M)\cos\alpha}{(y_A-y_C)\sin\alpha-(x_A-x_C)\cos\alpha}$$ $$x_B=\frac{x_A(1-i)^2+x_Ci^2-x_M}{2i(i-1)}$$ $$y_B=\frac{y_A(1-i)^2+y_Ci^2-y_M}{2i(i-1)}$$

for a full working out: $$x_D = x_A+i(x_B-x_A)$$ $$x_E = x_B+i(x_C-x_B)$$ $$x_M = x_D+i(x_E-x_D)$$

$$x_M = x_A(1-i)^2+2ix_B(1-i)+i^2x_C$$ $$x_B=\frac{x_A(1-i)^2+i^2x_C-x_M}{-2i(1-i)} = AB\sin\alpha+x_A$$ $$y_B=\frac{y_A(1-i)^2+i^2y_C-y_M}{-2i(1-i)} = AB\cos\alpha+y_A$$ $$AB = \frac{i^2(x_A-x_C)+x_A-x_M}{2i\sin\alpha(1-i)}= \frac{i^2(y_A-y_C)+y_A-y_M}{2i\cos\alpha(1-i)}$$

hence resulting the above 3 equations.

cubic bezier curve

Now consider a cubic Bezier curve defined by points $A, B, C, D$

$1)$With given points $A, D$, $M$ interpolated by $i$,angles $\alpha, \beta$, Can $B, C$ and $i$ be derived?

$2)$ if not, With given points $A, D$, $M$ (interpolated by $i$), $N$ (interpolated by $j$), angles $\alpha, \beta$, What are the equations for $B, C$, $i$ and $j$?

3

There are 3 best solutions below

6
On

Question 1: The answer is no.

Here is a counterexample

enter image description here

where with the same angles $\alpha$ and $\beta$, with given extreme points $A,D$ and current point $M$, it is possible to have different values for $i$ and different points $B$ and $C$.

I have taken $A(0,0), D(1,0)$,

($B(0,1), C=(0.8,0.6)$ for the red curve),

($B'(0,0.2), C'(0.6,1.2)$ for the blue curve).

In fact any other barycentric combination $(1-t) C_1 + t C_2$ of these curves, like the curve in black, will be a cubic Bezier solution of your issue.


Edit: We have seen that several solutions are possible, but we haven't shown how it is possible to obtain a solution. We are going to do it in the particular case where $BC$ is parallel to $AB$.

First of all, instead of refering to angles $\alpha, \beta$, I prefer to refer to triangle $ADE$, where $E$ is the intersection point of the rays issued from $A$ and $D$.

The key point is to compute the barycentric coordinates of $M$ with respect to triangle $ADE$,

$$M=uA+vD+wE\tag{*}$$

in two ways

  • The first one by the ratio of areas:

$$u=\dfrac{[MDE]}{[ADE]}, \ \ v=\dfrac{[AME]}{[ADE]}, \ \ w=\dfrac{[ADM]}{[ADE]}$$

  • The second one by exploiting the parallelism of segment $BC$ with segment $AD$ using the existence of $k \in (0,1)$ such that:

$$\begin{cases}B&=&kE+(1-k)A\\C&=&kE+(1-k)D \end{cases}$$

Plugging these relationships into the defining relationship:

$$M=(1-t)^3A+3(1-t)^2tB+3(1-t)t^2C+t^3D$$

will give a relationship:

$$M=\underbrace{[(1-t)^3+3(1-t)^2t(k-1)]}_{u'}A+[v']D+[w']E\tag{**}$$

It remains to identify (*) and (**) giving two equations in the two unknowns $t$ and $k$ that remains to be solved in order to get a value of $t$ and a value of $k$, the latter giving the positions of $B$ and $C$.

I have verified that it works but I don't want to expose rather tedious computations...

7
On

The point $M$ has the coordinates

$$(1-i)^3A+3(1-i)^2iB+3(1-i)i^2C+i^3D$$ and the angles at endpoints satisfy

$$\tan\alpha=\frac{B_x-A_x}{B_y-A_y},$$

$$\tan\beta=\frac{D_x-C_x}{D_y-C_y}.$$

This gives a system of four equations in five unknowns, so once indeterminate.


If you supply a second point $N$, you end up with six equations in six unknowns, a potentially determinate system. But due to nonlinearity, there might be several distinct solutions.

More precisely, all six equations are linear in $B_x,B_y,C_x,C_y$, with coefficients being cubic polynomials in $i$ and $j$. By expressing the compatibility conditions of this system, we get two polynomial equations of higher degree ($9$ ?) in $i,j$. The number of distinct solutions can be huge.

1
On

So here image shows that there are 7 controlling points

Now since point M is interpolated by i and N is interpolated by j, so we write

$$ x_B=x_A+i(x_M-x_A)$$ $$x_B= x_A+j(x_N-x_A)$$ $$x_C= x_D+i(x_M-x_D) $$ $$x_C=x_D+j(x_N-x_D)$$ $$x_M =x_A+i(x_D-x_A)$$ $$x_N= x_A+j(x_D-x_A)$$ Now we have to solve these 6 equations to find unknowns $x_B,x_C, i and j$ So we rearrange $$ x_B=\frac{ix_M+jx_N-(i+j-2)x_A}{2}$$ $$ x_C=\frac{ix_M+jx_N-(i+j-2)x_D}{2}$$ and $$i=\frac{x_M-x_A}{x_D-x_A}$$ $$j=\frac{x_N-x_A}{x_D-x_A}$$ So we plugin the value of i and j back into equation to solve for $x_B, x_C$ $$ x_B=\frac{(\frac{x_M-x_A}{x_D-x_A})x_M+x_N(\frac{x_N-x_A}{x_D-x_A})-((\frac{x_M-x_A}{x_D-x_A})+(\frac{x_N-x_A}{x_D-x_A})-2)x_A}{2}$$ $$ x_C=\frac{x_M(\frac{x_M-x_A}{x_D-x_A})+(\frac{x_N-x_A}{x_D-x_A})x_N-((\frac{x_M-x_A}{x_D-x_A})+(\frac{x_N-x_A}{x_D-x_A})-2)x_D}{2}$$ So that's how we can solve similarly for $y_B, y_C$ and backsubstituing for i and j will give us the interpolation value.