This transformation breaks each cubic at the midpoint into two cubics.

No SVG Support

Figure 13.1: Break Cubic

The algorithm is quite straightforward:

  • Original cubic is between (cx,cy) and (x3,y3) with control points (x1,y1) and (x2,y2)
  • Find midpoint between (cx,cy) and first control point (x1,y1), call it (x01,y01)
  • Find midpoint between first control point (x1,y1) and second control point (x2,y2), call it (x12,y12)
  • Find midpoint between second control point (x2,y2) and the end point (x3,y3), call it (x23,y23)
  • Find midpoint between (x01,y01) and point (x12,y12), call it (x0112,y0112)
  • Find midpoint between (x12,y12) and point (x23,y23), call it (x1223,y1223)
  • End of first cubic is (newcx,newcy), the midpoint of (x0112,y0112) to (x1223,y1223
  • The first cubic is (cx,cy) to (newcx,newcy) with control points (x01,y01) and (x0112,y0112)
  • The second cubic is (newcx,newcy) to (x3,y3) with control points (x1223,y1223) and (x23,y23)

Repeating the process allows a long curve segment to be broken into smaller parts, sometimes useful when animating.

Replacing half by some other fraction would break the cubic into two parts equivalent to the fraction chosen.

The diagram below shows the curves resulting from multiple uses of break_cubic.

No SVG Support

Figure 13.2: Break Cubic