# B-spline Curves: Closed Curves

There are many ways to generate closed curves. The simple ones are
either wrapping control points or wrapping knot vectors.

### Wrapping Control Points

Suppose we want to construct a closed B-spline curve
**C**(*u*) of degree *p*
defined by *n*+1 control points **P**_{0},
**P**_{1}, ..., **P**_{n}. The number of
knots is *m*+1, where *m* = *n* + *p* + 1.
Here is the construction procedure:
- Design an uniform knot sequence of
*m*+1 knots:
*u*_{0} = 0, *u*_{1} = 1/*m*,
*u*_{1} = 2/*m*, ...,
*u*_{m} = 1. Note that the domain of the curve
is [*u*_{p}, *u*_{n-p}].
See the discussion in
open curves for the details.
- Wrap the first
*p* and last *p* control points.
More precisely, let
**P**_{0} = **P**_{n-p+1},
**P**_{1} = **P**_{n-p+2}, ...,
**P**_{p-2}
= **P**_{n-1} and
**P**_{p-1}
= **P**_{n}. This is shown in the figure
below.

The constructed curve is *C*^{p-1} continuous
at the joining point **C**(*u*_{p}) =
**C**(*u*_{n-p}).
The following is an example. Figure (a) shows an open B-spline curve of
degree 3 defined by 10 (*n* = 9) control points and a uniform knot
vector. In the figure, control point pairs 0 and 7, 1 and 8, and 2 and 9
are placed close to each other to illustrate the construction.
Figure (b) shows the result of making control points 0 and 7 identical.
The shape of the curve does not change very much. Then, control points 1 and
8 are made identical as shown in Figure (c). It is clear that the gap
between the first and last points of the curve is closer. Finally, the curve
becomes a closed on when control points 2 and 9 are made identical as
shown in Figure (d).

### Wrapping Knots

Another way of constructing closed B-spline curves is by wrapping knots.
Suppose we want to construct a closed B-spline curve
**C**(*u*) of degree *p* defined by *n*+1 control points
**P**_{0}, **P**_{1}, ..., **P**_{n}.
The following is the construction procedure:
- Add a new control point
**P**_{n+1} =
**P**_{0}. Therefore, the number of control points
is *n*+2.
- Find an appropriate knot sequence of
*n*+1 knots
*u*_{0}, *u*_{1}, ...,
*u*_{n}. These knots are not necessarily
uniform, an advantage over the method discussed above.
- Add
*p*+2 knots and wrap around the first *p*+2 knots:
*u*_{n+1} = *u*_{0},
*u*_{n+2} = *u*_{1},
...,
*u*_{n+p} = *u*_{p-1},
*u*_{n+p+1} =
*u*_{p},
*u*_{n+p+2} =
*u*_{p+1} as shown in the following
diagram. In this way, we have *n*+*p*+2 =
(*n*+1) + *p* + 1 knots.

- The open B-spline curve
**C**(*u*) of degree *p*
defined on the above constructed *n*+1 control points
and *n+p*+2 knots is a closed curve with
*C*^{p-1} continuity at the joining point
**C**(*u*_{0})
= **C**(*u*_{n+1}).
Note that the domain of this closed curve is
[*u*_{0}, *u*_{n+1}].