This page was generated from doc/euclidean/bezier-properties.ipynb. Interactive online version: Binder badge.

Properties of Bézier Splines#

The terms Bézier spline and Bézier curve are sometimes used interchangeably for two slightly different things:

  1. A curve constructed from a single Bernstein polynomial of degree \(d\), given a control polygon consisting of a sequence of \(d + 1\) vertices. The first and last vertex lie on the curve (at its start and end, respectively), while the other vertices in general don’t (the curve approximates them).

  2. A piecewise polynomial curve consisting of multiple segments, each of them constructed from a separate Bernstein polynomial. The start and end points of neighboring control polygons typically coincide, leading to \(C^0\) continuity. However, the overall control polygon can be chosen in a way to achieve \(G^1\) or \(C^1\) (or even higher) continuity.

We use the term Bézier curve for the former and Bézier spline for the latter. Bézier splines in the latter sense are well known from their common use in 2D vector graphics software, where cubic (i.e. degree 3) curve segments are typically used. Each segment has four control points: The start and end point of the segment (shared with the end and start of the previous and next segment, respectively) as well as two additional points that control the shape of the curve segment.

[1]:
import matplotlib.pyplot as plt
import numpy as np
[2]:
import splines

As an example, we create control points for a Bézier spline consisting of four segments, having polynomial degrees of 1, 2, 3 and 4.

[3]:
control_points = [
    [(0, 0), (1, 4)],
    [(1, 4), (2, 2), (4, 4)],
    [(4, 4), (6, 4), (5, 2), (7, 2)],
    [(7, 2), (8, 0), (4, 0), (5, 1), (3, 1)],
]

We are using the class splines.Bernstein to construct a Bézier spline from these control points.

[4]:
s = splines.Bernstein(control_points)
[5]:
times = np.linspace(s.grid[0], s.grid[-1], 100)
[6]:
fig, ax = plt.subplots()
for segment in control_points:
    xy = np.transpose(segment)
    ax.plot(*xy, '--')
    ax.scatter(*xy, color='grey')
ax.plot(*s.evaluate(times).T, 'k.')
ax.axis('equal');
../_images/euclidean_bezier-properties_10_0.svg