function [cl,cr] = bezier_subdivision(c,s)
% BEZIER_SUBDIVISION: subdivision of a Bezier curve
% [cl,cr] = bezier_subdivision(c,s)
% split Bezier curve with control points c(k,:) 
% at parameter s, generating control points 
% cl(k,:) and cr(k,:) for left and right segments

cl = c(1,:); cr = c(end,:);
for m = 2:size(c,1);
   c = (1-s)*c(1:end-1,:) + s*c(2:end,:);
   cl = [cl; c(1,:)]; cr = [c(end,:); cr];
end

