function [q p]=castel2split(p,t)
% splits the Bézier curve with control points p(:,1), p(:,2), ... , p(:,end)
% in the point t

q=zeros(size(p));
for i=length(p):-1:2
  q(:,length(p)+1-i)=p(:,1);
  p(:,1:i-1)=(1-t)*p(:,1:i-1) + t*p(:,2:i);
end
q(:,length(p))=p(:,1);
p=p(:,end:-1:1); %reverses the tuple of points p
