1

I have the following example I don't understand.

Here is a Bezier-Curve over [0, 1] with the following setup Bezier Curve

Now the example explains how to construct the other Bezier-Curve, which connects to point (2,2) with a C2-Continuity, over [1, 2].

(This is in German. "Stetigkeit" stands for continuity. Sorry about that)

enter image description here

Generally I know about

  • Calculate the length of the two intervals (1 and 1 each)
  • The positions of p1,2 and p2,2 are relative to the length of the intervals.

But I don't understand how to calculate them by pure math-

Saphire
  • 171

1 Answers1

5

The description presented looks confusing, so here is one possible interpretation, if the subject is about making a $C_2$ connection of the two cubic Bezier curves (segments).

The expression

\begin{align} s_1(t)&= B_0^3(t)\left[\begin{matrix}0\\ 0\end{matrix}\right] +B_1^3(t)\left[\begin{matrix}0\\ 1\end{matrix}\right] +B_2^3(t)\left[\begin{matrix}1\\ 2\end{matrix}\right] +B_3^3(t)\left[\begin{matrix}2\\ 2\end{matrix}\right] \tag{1}\label{1} \end{align}

defines the coordinates of a point $s_1(t)$ for any $t\in[0,1]$ on the first cubic Bezier curve (segment) with control points

\begin{align} p_{01}&=(0,0) ,\quad p_{11}=(0,0) ,\quad p_{21}=(1,2) ,\quad p_{31}=(2,2) , \end{align}
where, for example, $p_{21}=(1,2)$ means that $x$-coordinate of of the point $p_{21}$ is $1$, and its $y$-coordinate is $2$.

Points $p_{0k}$ and $p_{3k}$ are always located on the endpoints of the curve. The other two points $p_{1k}$ and $p_{2k}$ usually are not on the curve, but they control the shape of the curve.

Next, $B_k^3(t)$ means $k$-th cubic Bernstein polynomial,

\begin{align} B_k^3(t)&=\textstyle\binom{3}{k}(1-t)^{3-k}t^k ,\\ B_0^3(t)&=(1-t)^3 ,\quad B_1^3(t)=3(1-t)^2t ,\quad B_2^3(t)=3(1-t)t^2 ,\quad B_3^3(t)=t^3 . \end{align}

Thus, the expression \eqref{1} can be written in a general form for the $k$-th segment as

\begin{align} s_k(t)&= (1-t)^3 p_{0k} +3(1-t)^2t\cdot p_{1k} +3(1-t)t^2\cdot p_{2k} +t^3\cdot p_{3k} \tag{2}\label{2} , \end{align}

which in fact represents two expressions (in 2D), for $x$ and $y$-coordinates of the point $s_k(t)$ on the $k$-th Bezier segment

\begin{align} s_{kx}(t)&= (1-t)^3 p_{0kx} +3(1-t)^2t\cdot p_{1kx} +3(1-t)t^2\cdot p_{2kx} +t^3\cdot p_{3kx} ,\\ s_{ky}(t)&= (1-t)^3 p_{0ky} +3(1-t)^2t\cdot p_{1ky} +3(1-t)t^2\cdot p_{2ky} +t^3\cdot p_{3ky} , \end{align}

which are just ordinary cubic polynomials in terms of parameter $t$.

Note that for any segment the parameter $t$ (often called as time parameter) runs from $t=0$ (point $p_{0k}$) to $t=1$ (point $p_{3k}$).

The sequence of such connected segments $s_k$ is often called a cubic Bezier spline (don't confuse it with B-splines!), and the word "spline" suggests that these segments are connected smoothly, which this exercise was supposed to demonstrate.

What is missing in the original illustration, are the two actual cubic Bezier segments, which are smoothly connected:

enter image description here

So, the instructions tell us that given the first cubic Bezier segment $s_1$ which is defined by control points $p_{01}$ through $p_{31}$, we can smoothly (that is, the resulting two-segment curve will be $C_2$-continuous) extend the curve with segment $s_2$, by calculating three of its control points, $p_{02},p_{12}$ and $p_{22}$. The last control point can be chosen freely, its location does not affect the smoothness of the curve $s_1,s_2$ (in fact, the point $p_{01}$ can be chosen freely as well).

In order to get the $C_2$-continuity, we need first ensure $C_0$, that is, the starting point $p_{02}$ of the second segment must coincide with the endpoint $p_{31}$ of the first:

\begin{align} p_{02}&=p_{31} ,\\ \text{or }\quad s_1(1)&=s_2(0) . \end{align}

To get $C_1$-continuity, we need to guarantee that

\begin{align} s'_1(t)|_{t=1}&=s'_2(t)|_{t=0} ,\\ \text{which gives }\quad p_{12} &= 2p_{31}-p_{21} \end{align}

The last condition for $C_2$--continuity is

\begin{align} s''_1(t)|_{t=1}&=s''_2(t)|_{t=0} ,\\ \text{which gives }\quad p_{22} &= p_{11}+2p_{12}-2p_{21} . \end{align}
Also, note that the phrase "$\dots$ which connects to point $(2,2)$ with a $C_2$-continuity, over $[1, 2]$" is incorrect. The second segment (the actual curve) smoothly connects the endpoint $p_{31}$ of the first segment $s_1$ with the endpoint $p_{32}$ of the second segment $s_2$, and not "over $[1, 2]$", but still "over $[0, 1]$", that is, $t\in[0,1]$. Even if, for example, this two-segment curve represents a smooth trajectory of the point for some timeline $T$ and we assume that the segment $s_1$ starts at $T=0$ and ends at $T=1$, then $s_2$ follows and ends at $T=2$, we still have to use $t$ from 0 to 1 to calculate the points according to \eqref{2}.

Edit

In case if we would like to use a global time parameter $T$ to control the smooth movement of the point using given sequence of "time points", we need to use modified expression for the point on the curve.

Since cubic Bezier curves are defined for local time parameter $t\in[0,1]$, we need to modify the procedure of the smooth connection of the two segments by using a transformation from the global $T$, starting time $T=t_k$ and ending time $T=t_{k+1}$ for the segment $s_k$: \begin{align} t&=\tfrac{T-t_k}{t_{k+1}-t_k} . \end{align}

Then we have the expression for the coordinated of the point on the segment $s_k$ as

\begin{align} s_k(T) &= (1-\tfrac{T-t_k}{t_{k+1}-t_k})^3\cdot p_{0k} \\ &+3\cdot(1-\tfrac{T-t_k}{t_{k+1}-t_k})^2(\tfrac{T-t_k}{t_{k+1}-t_k})\cdot p_{1k} \\ &+3\cdot(1-\tfrac{T-t_k}{t_{k+1}-t_k})(\tfrac{T-t_k}{t_{k+1}-t_k})^2\cdot p_{2k} \\ &+(\tfrac{T-t_k}{t_{k+1}-t_k})^3\cdot p_{3k} . \end{align}

Given that, we can find the control points of the smoothly attached segment $s_{k+1}$, which has assigned global time length $t_{k+2}-t_{k+1}$, that satisfy three conditions of continuity:

\begin{align} s_{k+1}(T)|_{T=t_{k+1}}&=s_{k}(T)|_{T=t_{k+1}} ,\\ s'_{k+1}(T)|_{T=t_{k+1}}&=s'_{k}(T)|_{T=t_{k+1}} ,\\ s''_{k+1}(T)|_{T=t_{k+1}}&=s''_{k}(T)|_{T=t_{k+1}} . \end{align}

This system results in \begin{align} p_{0\,k+1}&=p_{1\,k} ,\\ p_{1\,k+1}&= p_{3\,k}- \tfrac{t_{k+2}-t_{k+1}}{t_{k+1}-t_k}\cdot(p_{2\,k}-p_{3\,k}) ,\\ p_{2\,k+1}&= 2p_{1\,k+1}-p_{3\,k} +(\tfrac{t_{k+2}-t_{k+1}}{t_{k+1}-t_k})^2\cdot(p_{1\,k}-2\,p_{2\,k}+p_{3\,k}) . \end{align}

Back to the OP: assuming we have

\begin{align} t_0&=0 ,\quad t_{1}=1 ,\quad t_{2}=3 . \end{align}

Then the control points of the extension curve $q_2$ would be \begin{align} q_{02}&=p_{31} ,\\ q_{12}&=3\,p_{31}-2\,p_{21} ,\\ q_{22}&=4\,p_{11}-12\,p_{21}+9\,p_{31} . \end{align}

And since we still can choose any point as $q_{32}$, let $q_{32}=p_{32}$, so we can compare the two extension segments, which differ in the time span: for the first one we have $t_1=1$, $t_2=2$, and for the second one we have $t_1=1$, $t_2=3$.

Here is the difference:

enter image description here

g.kov
  • 13,581
  • Thanks, how would the calculation for C2 change, if the second interval would be [1, 3]? – Saphire Jun 29 '18 at 09:04
  • @Saphire: What exactly do you mean by "interval would be $[1, 3]$"? Interval of what? Every cubic Bezier segment is defined specifically to use the local time parameter $t\in[0,1]$. And the described instructions are making a smooth ($C_2$) extension for the given Bezier segment with another one. – g.kov Jun 29 '18 at 09:31
  • I'm sorry. I mean if the interval for the points which are supposed to be created for a C2-Curve would be [1,3] instead of [1, 2]. In this example both intervals have the length of 1, but what if the second curve should be created over [1,3]? That would change the length. – Saphire Jun 29 '18 at 09:44
  • @Saphire: We can always smoothly extend our two-segment spline ${s_1,s_2}$ with the third segment, $s_3$, using exactly the same instructions to get $p_{03},p_{13},p_{23}$ from known $p_{12},p_{22},p_{32}$. Then we can consider that the global time parameter $T$ of our three-segment cubic Bezier spline ${s_1,s_2,s_3}$ varies from $0$ to $3$, while the local time parameter $t$ changes from $0$ to $1$ for every segment $s_1,s_2,s_3$. – g.kov Jun 29 '18 at 10:23
  • @Saphire: Please, check out the update - is that what you are after? – g.kov Jun 29 '18 at 14:55
  • @g.kov. Good answer. However, your statement that "Every cubic Bezier segment is defined specifically to use the local time parameter $t∈[0,1]$ is dubious, at best. Bezier segments often use parameter intervals different from $[0,1]$. For example, the Bezier segments in a NURBS curve use various different parameter intervals. Also, the concept of blossoming relies on the use of arbitrary parameter intervals. – bubba Jul 02 '18 at 01:54
  • @bubba: Well, its all about definitions. By the way, NURBS = Non-Uniform RATIONAL BASIS Spline = is much more complex in many ways and completely different beast than the simple cubic Bezier curve segment, which definition is in Eq.(1). Cubic Bezier segment is completely defined by four ordered control points, say, $p_0,p_1,p_2,p_3$ and everybody know that when the local time parameter $t$ varies from $0$ to $1$, the point moves from $p_0$ to $p_3$ along the curve (segment). There is just no place for $t$ outside the range $[0,1]$, by definition. – g.kov Jul 02 '18 at 07:51
  • @bubba:Of course, we can conveniently use any values for the global time $T$, as shown above, but the LOCAL $t=\tfrac{T-t_k}{t_{k+1}-t_k}$ is always in $[0,1]$. – g.kov Jul 02 '18 at 07:52