function segments = deCasteljau(b1, b2, b3, b4, tol)
% Plot 2D Bezier curve recursively.
% b1, b2, b3, and b4 are the control points for the curve (length-2 row
% vectors in [x, y] order). Assumes figure hold is on. Recursively
% subdivides curve at parameter midpoint until max distance from a line
% drawn between endpoints is below `tol`. Returns the number of line
% segments used to draw the curve.
% In addition, animate control points while error is above 10*tol to
% visualize the algorithm.