Skip to content

adhishagc/bezier-curve-python

Repository files navigation

Bezier Curve: Mathematical Implementation & Visual Exploration

A high-performance Python implementation and interactive visualization tool for Bézier Curves, a fundamental geometric construct in computer graphics, CAD/CAM, and typeface design.

Bezier Curve Animation

Mathematical Foundation

Bézier curves are parametric curves that rely on Bernstein Polynomials to create smooth, scalable paths. Unlike traditional splines, a Bézier curve is entirely contained within the convex hull of its control points.

The Bernstein Basis

A Bézier curve of degree $n$ is mathematically defined as:

$$ \mathbf{B}(t) = \sum_{i=0}^n b_{i,n}(t) \mathbf{P}_i, \quad 0 \leq t \leq 1 $$

Where the Bernstein basis polynomials $b_{i,n}(t)$ are given by:

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

  • $\mathbf{P}_i$: The $i$-th control point.
  • $\binom{n}{i}$: The binomial coefficient.
  • $t$: The interpolation parameter.

Visual Results & Interpretations

This project provides 2D and 3D implementations of Bézier curves, including higher-order patches.

1. Linear & Quadratic Convergence

The simplest forms of Bézier curves, where the path is determined by 2 or 3 control points respectively.

Quadratic Bezier

2. High-Degree Bernstein Basis Plots

The basis functions determine the "weight" of each control point at any given $t$.

Bernstein Basis

3. Stochastic 3D Path Generation

Randomized control point generation in 3D space demonstrates the robustness of the algorithm for complex trajectory planning.

3D Bezier Curve

4. 2D Surface Patches

Extending the curve into a second parameter $u$ creates a Bézier Surface, essential for 3D modeling.

Bezier Surface Patch

Installation & Environment

This implementation uses standard Python data science libraries for calculation and rendering.

pip install numpy matplotlib pandas

How to Use

Running the Interactive Notebook

The core logic and visualizations are contained in the high-SEO optimized Jupyter notebook: Bezier_Curve_Mathematical_Implementation.ipynb

Manual Implementation Example

import numpy as np
import matplotlib.pyplot as plt

# Define Bernstein Basis function
def B_basis(n, i, t):
    return comb(n, i) * (t**i) * (1-t)**(n-i)

# Generate points on the curve
# ... (see notebook for full implementation)

Key Applications

  • Vector Graphics: Core technology behind SVG paths and Adobe Illustrator.
  • Animation: Keyframe interpolation and easing functions.
  • Robotics: Path planning for smooth manipulator movement.
  • Font Design: Mathematical representation of character glyphs (TrueType/OpenType).

Developed for Academic Research and Geometric Design Optimization.

About

Bezier Curve representation using Python Pyplot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors