Algorithm for inserting points in a piecewise-cubic Bézier path
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When working with vector graphics, 3D modeling, or computer-aided geometric design, piecewise-cubic Bezier paths are widely used due to their simplicity and smoothness. A Bezier path composed of piecewise-cubic segments provides a flexible and efficient way to represent complex curves. However, adjusting these paths by inserting new points can be challenging. This article walks through the algorithm for inserting points into a piecewise-cubic Bezier path, using the De Casteljau subdivision method to maintain continuity and precision.
Understanding Cubic Bezier Curves
Before exploring the insertion algorithm, it is essential to understand a cubic Bezier curve, defined by four control points: , , , and . The parametric equation for a cubic Bezier curve is:
This equation creates a smooth curve from to , controlled by intermediate points and that shape the tangent directions at the endpoints.
Why Insert Points?
Inserting new points into a Bezier path may be necessary for several reasons:
- Increasing Path Detail: Adding points allows for finer, more detailed rendering of the curve.
- Path Modification: Helps adjust the curve shape without rebuilding the entire path.
- Collision Detection: Allows algorithms to work on a set of smaller segments rather than one large curve.
- Animation Precision: Refines paths used for animations, ensuring precise movement along the curve.
Algorithm for Insertion
Overview
- Determine the Segment: Identify which segment of the Bezier path contains the insertion point.
- Subdivide with De Casteljau: Split the segment into two sub-curves at the parameter value .
- Create New Control Points: Calculate the control points for both new segments.
- Preserve Continuity: Ensure that the new segments connect smoothly to maintain the curve's continuity.
Step 1: Determine the Segment
Given a set of piecewise-cubic Bezier segments, determine which segment contains the parameter value where the new point must be inserted. This step involves iterating over the segments and finding the one whose parametric interval contains .
Step 2: Subdivide Using De Casteljau
The De Casteljau algorithm is the standard tool for splitting a cubic Bezier curve at parameter . Given the original control points , compute intermediate points through successive linear interpolation:
First level:
Second level:
Third level (the point on the curve):
The point is the new insertion point, lying exactly on the original curve at parameter .
Step 3: Create New Control Points
The two new Bezier segments are defined by:
- First segment:
- Second segment:
Both segments together trace exactly the same curve as the original segment. No approximation is involved. This is one of the key strengths of De Casteljau subdivision.
Step 4: Preserve Continuity
The subdivision naturally preserves continuity at the split point because the tangent vectors from both sides match. To ensure continuity across the entire path, verify that the last control point of the first new segment and the first control point of the second new segment are the same point (they are, by construction). If the original path had continuity at segment boundaries, check that the new control point arrangement does not break that property.
Worked Example
Consider a Bezier curve with control points , , , . We want to split at .
First level:
Second level:
Third level:
The two resulting segments are:
- Segment 1:
- Segment 2:
Together, these two curves reproduce the original curve exactly.
Summary
| Step | Key Process |
| Determine Segment | Identify the segment containing the insertion |
| De Casteljau Split | Compute intermediate points through linear interpolation |
| New Control Points | First segment: , second: |
| Preserve Continuity | Continuity is guaranteed by construction |
Common Pitfalls
- Choosing or produces a degenerate split where one segment has zero length. Guard against this in code.
- When inserting into a multi-segment path, make sure to remap the global parameter to the local segment parameter before applying De Casteljau.
- Floating-point precision can drift over many successive subdivisions. If you need high accuracy after many splits, consider using rational arithmetic or interval methods.
Understanding this technique is crucial for anyone working in computer graphics or geometric modeling. Through precise subdivision, seamless animations, detailed curve editing, and robust collision detection all become possible.

