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

Properties of Bézier Splines§

[1]:
import matplotlib.pyplot as plt
import numpy as np
[2]:
import splines
[3]:
# TODO: example plot of cubic Bézier with "handles"
[4]:
control_points = [
    [(0, 0), (1, 4)],
    [(1, 4), (2, 2), (4, 4)],
    [(4, 4), (6, 4), (5, 2), (6, 2)],
    [(6, 2), (6, 0), (4, 0), (5, 1), (3, 1)],
]
[5]:
s = splines.Bernstein(control_points)
[6]:
s.grid
[6]:
[0, 1, 2, 3, 4]
[7]:
times = np.linspace(s.grid[0], s.grid[-1], 100)
[8]:
fig, ax = plt.subplots()
for segment in control_points:
    xy = np.transpose(segment)
    ax.plot(*xy, '--', linewidth=1)
    ax.scatter(*xy, color='grey')
ax.plot(*s.evaluate(times).T, 'k.')
ax.axis('equal');
[8]:
(-0.30000000000000004, 6.3, -0.2, 4.2)
../_images/euclidean_bezier-properties_9_1.svg
[9]:
# TODO: example with non-uniform time