I am searching a way to make c2 continuous CLOSED bezier spline via given points. I found a perfect description for OPENED spline here. Briefly it is: If were describe path needed as $i$ segments, where each segment is cubic Bezier curve, with control points from $P_{0,i}$ to $P_{3,i}$, then C2 continuity conditions are:

$P_{0,i}=P_{3,i-1}$ ; ($C0$ continuity)

$2P_{0,i}=P_{1,i}+P_{2,i-1}$; ($C1$ continuity)


$-2P_{1,i}+P_{2,i}=P_{1,i-1}-2P_{2,i-1}$ ; ($C2$ continuity)

Until this moment everything is clear for me (even with my poor math background).
Later they use fact that, the spline becomes linear at the end points. But I need to create a contour:

$P_{0,0}=P_{3,n}$, and this complication burn my brain. I have no ideas how to deal with such equations.

Could you help me to find control point for c2 continuous closed bezier spline?


1 Answer 1


Here is a simple way for building a $C^2$ closed spline obtained by assembling cubic Bezier curves. See Fig. 1.

1) Begin by considering a "scaffolding" polygon $P_0P_1P_2\cdots P_{n-1}P_n$ that will give the general shape of the curve to come (we take the cyclic convention: $P_n=P_0$ that will as well be used for families of points $A_k$, $B_k$, $C_k$ that are to be defined).

2) On each side $[P_kP_{k+1}]$, consider the $2$ points situated resp. at the third and two-thirds of this side:

$$B_k = \tfrac13(2 P_k + P_{k+1}) \ \ \ \text{and} \ \ \ \ C_k = \tfrac13(P_k + 2 P_{k+1}).$$

3) Then define midpoints $A_{k+1} = \tfrac12(B_k + C_k).$

4) At last, draw the $n$ Bezier curves defined by points $(A_k, B_k, C_k, A_{k+1})$.

At junction points $A_k$, it is almost immediate to verify that the speed vectors of the two joined arcs are the same; it not difficult to prove either that the acceleration vectors of the two arcs are the same too.

There is more to do. The process just described is convenient for curve approximations: for example, a designer who wants to build an egg-shaped curve has a satisfying answer.

But for "technical drawing", where the curve is constrained to pass through pre-determined points $A_k$, we have to build (if possible) points $P_k$ from points $A_k$. This is curve interpolation.

It is always possible. How ? We have just to understand Fig. 2 and the resulting system of equations (3).

Let us start from $6A_k$: this point can be expressed like this:

$$6A_k = 3C_{k-1}+ 3B_k = (P_{k-1} + 2P_k)+(2P_k + P_{k+1}) $$

(using definitions of $B_k$ and $C_k$), i.e.,

$$\tag{2}6A_k = P_{k-1} + 4P_k+ P_{k+1}$$

Gathering equations (2) for all values of $k$, and taking into account the cyclicity property, we get a system that, in the case of a 5 points, is:

$$\tag{3}\begin{cases}&4P_0 &+& P_1&+ &&&&& P_4 &=& 6A_0\\ &P_0 &+& 4P_1&+& P_2 &&&&&=& 6A_1\\ &&&P_1 &+& 4P_2&+& P_3 &&&=& 6A_2\\ &&&&&P_2 &+& 4P_3&+& P_4 &=& 6A_3\\ &P_0 &+&&&&& P_3&+& 4P_4 &=& 6A_4\\ \end{cases}$$

System (3) is invertible (diagonally dominant matrix) ; therefore, being given points $A_k$, we can obtain all points $P_k$.

Fig. 3 shows the versatility of this method : the generated curve can have as well concave parts or even loops.

Here is a Matlab implementation of the method just detailed:

clear all;close all;axis tight;hold on;
[X,Y]=getpts(); % mouse selection of points Ak ...
n=length(X);A=[X,Y]; % ... coords placed into a n x 2 array
for k=1:n;
for k=1:n

enter image description here

Fig. 1.

enter image description here Fig. 2.

enter image description here

Fig. 3.

  • $\begingroup$ Great! Is generalisation for surfaces exist? Approximation case will be more then enough for me. $\endgroup$
    – zlon
    Commented Jan 29, 2018 at 6:46
  • $\begingroup$ Thanks. Generalization to surfaces is surely not straightforward even if we restrict to the approximation case. I have been working on the so-called "Bezier patches" but not enough to provide an answer. But, sooner or later you will need to consider B-splines in order to have the ability to locally modify points without influencing all points. $\endgroup$
    – Jean Marie
    Commented Jan 29, 2018 at 6:59
  • $\begingroup$ I have added a third figure in order to see the method's versatility $\endgroup$
    – Jean Marie
    Commented Jan 29, 2018 at 7:00
  • $\begingroup$ I ask about surfaces as my the most general task is to create more or less "random" surface. Just now I create 2 bezier contours, create 2 orthogonal cylinders and multiply them to have a closed 3d shape. So I have no need to deal with local modification of point. Just bezier is simple enough for me to understand, and give me a good results. $\endgroup$
    – zlon
    Commented Jan 29, 2018 at 7:05
  • 1
    $\begingroup$ For Bezier patches, take a look e.g., at (scratchapixel.com/lessons/advanced-rendering/…) $\endgroup$
    – Jean Marie
    Commented Jan 29, 2018 at 7:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .