function p=castel3(p,t)
% computes the Bézier curves with control points p(:,1), p(:,2), ... , p(:,end)
% in the points of the vector t

% first index: number of coordinates 
% second index: number of evaluation points
% third index: number of control points

p=reshape(p,[size(p,1),1,size(p,2)]);
p=repmat(p,[1,length(t),1]); %we could also get rid of this by using cleverly the first bsxfun
t=reshape(t,1,length(t),1);
for i=size(p,3):-1:2
  p(:,:,1:i-1) = bsxfun(@times, p(:,:,1:i-1) , 1-t) + bsxfun(@times, p(:,:,2:i), t);
end
p=p(:,:,1);

