MMF.
• 5 min read

BezierLab: Interactive N-Degree Bézier Curve Construction in Python

How I built a standalone desktop GUI for generating, manipulating, and analyzing arbitrary-degree parametric Bézier curves with real-time mathematical rendering.

BezierLab Application Interface

Bézier curves are fundamental to modern computational geometry, computer-aided design (CAD), CNC toolpath generation, and vector typography. While commercial CAD packages hide the underlying mathematics behind black-box smoothing functions, engineering students and designers often lack an intuitive tool to explore how shifting higher-order control points affects curve curvature and derivative continuity.

To address this gap, I created BezierLab: an open-source, interactive desktop application built in Python that enables real-time visual construction and analytical inspection of Bézier curves of arbitrary degrees.

Mathematical Foundation

A Bézier curve of degree $n$ parameterized by $t \in [0, 1]$ is formulated as a linear combination of Bernstein basis polynomials $b_{i,n}(t)$ weighted by control points $P_i \in \mathbb{R}^2$:

Parametric Bézier Curve Equation:

$$B(t) = \sum_{i=0}^{n} b_{i,n}(t) P_i, \quad t \in [0, 1]$$

Bernstein Basis Polynomials:

$$b_{i,n}(t) = \binom{n}{i} t^i (1 - t)^{n - i} = \frac{n!}{i!(n - i)!} t^i (1 - t)^{n - i}$$

For numerical stability when evaluating high-degree curves, BezierLab implements De Casteljau's algorithm, recursively interpolating between intermediate control vertices:

Recursive De Casteljau Relation:

$$P_i^{(k)}(t) = (1 - t) P_i^{(k-1)}(t) + t P_{i+1}^{(k-1)}(t), \quad \begin{cases} k = 1, 2, \dots, n \\ i = 0, 1, \dots, n - k \end{cases}$$

where $P_i^{(0)}(t) = P_i$, and $B(t) = P_0^{(n)}(t)$.

Core Features of BezierLab

  • Arbitrary Degree Support ($n \ge 1$): Construct linear, quadratic, cubic, quartic, and higher $N$-degree curves by dynamically inserting or removing control nodes.
  • Direct Canvas Interaction: Drag-and-drop control vertices $P_i = (x_i, y_i)$ with immediate sub-millisecond recalculation and canvas repainting.
  • Convex Hull Visualization: Displays the bounding polygon formed by the control point set $\{P_0, P_1, \dots, P_n\}$, visually verifying the convex hull property: $B(t) \in \text{conv}(P_0, \dots, P_n)$.
  • Coordinate Inspection & Export: Inspect exact discrete spatial coordinates $(x_t, y_t)$ across parameterized step increments $\Delta t$, with full PNG image export support.

Engineering Applications

In manufacturing and mechanical engineering, Bézier curve interpolation provides critical advantages:

  • CNC Toolpath Optimization: Replacing segmented linear polylines with continuous $G^1$ (tangent continuous) and $G^2$ (curvature continuous) smooth spline curves, drastically cutting machine head jerk, vibration, and surface scallop height.
  • Robotic Trajectory Planning: Generating smooth position-velocity profiles between workspace waypoints to respect actuator torque and acceleration constraints.
  • Aerodynamic Airfoil Design: Parameterizing NACA and bionic flap profiles with minimal control variables.

Download & Repository

BezierLab is open-source and distributed both as Python source code and standalone Windows executables: