16

What mathematical formula does Blender use to calculate Bezier paths?

David
  • 49,291
  • 38
  • 159
  • 317
Garrett
  • 6,596
  • 6
  • 47
  • 75

2 Answers2

15

For each segment of the path between two control points, it approximates a cubic Bezier curve:

Bezier Curve formula

where P0 and P3 are the control points and P1 and P2 are the handles.

Visual control points

greatwolf
  • 2,961
  • 6
  • 23
  • 29
Garrett
  • 6,596
  • 6
  • 47
  • 75
10

Even though this isn't a question about Blender's code exactly, linking to Blender's code for calculating cubic bezier curves may help understanding.

  • 2D masks can also use a different (more straightforward but slower) method where you can get any point on along the spline using a factor:
    See BKE_mask_point_segment_co (trivial to adapt for 3D curves too).
  • 3D curves use an optimized (less straightforward), fixed step, subdivision method:
    See BKE_curve_forward_diff_bezier

To see how this method works, see wikipedia's description of Higher order curves

ideasman42
  • 47,387
  • 10
  • 141
  • 223