Interpolation

Your Progress in this Chapter

0%

0 / 10 units completed

Chapter Overview

Bezier Spline

Section 3.4 of 53 min1 code examples

Bézier Splines

Unlike linear interpolation, which creates a jagged path between data points, Bézier Splines create smooth, continuous curves. They are defined by "control points" that influence the shape of the curve without the curve necessarily passing through them (except for the endpoints). This makes them ideal for computer graphics, path planning for robotics, and aerodynamic smoothing.

1. The Mathematical Formula (Quadratic)

The most common form is the Quadratic Bézier curve, defined by three points: P_0 (start), P_1 (control), and P_2 (end). The curve is parameterized by t, where t ranges from 0 to 1: B(t) = (1 - t)^2 P_0 + 2(1 - t)t P_1 + t^2 P_2

As t moves from 0 to 1, the formula calculates a weighted blend of the three points, resulting in a smooth arc that "leans" toward the control point P_1.

2. Implementation in SepalSolver

In SepalSolver, the BezierCurve method generates a series of points along a spline. You provide the array of control points and the number of segments (resolution) you wish to generate for the final path.

Example 1C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Code is ready to run
OutputFrom the book
Bezier_Curve_Example.png

Examples

.. Admonition:: Example 1 : Robot Path Smoothing

A robot might calculate a path as a series of sharp turns (linear). By using these points as control points for a Bézier spline, the robot can follow a smooth trajectory that doesn't require it to come to a complete stop at every corner.