function Z = mpbezierval(CP,t)
	[n,m] = size(CP);
	if (m ~= 8), error("CP did not come from the \"Control Points of MetaPost Bezier Curve\" page!!!\n"); end
	[j,k]=size(t);
	if ((j>1) & (k>1)), error("t must be a scalar or vector of \"times\"!!!\n"); end
	if (j>1), t=t'; end
	k=length(t);
	t0=floor(t);
	t0=max(t0,0);
	I=find(t0>=n);
	t0(I)=n-1;
	s=t-t0;
	a=(1-s).^3; b=3*(1-s).^2.*s; c=3*(1-s).*s.^2; d=s.^3;
	a=[a;a]; b=[b;b]; c=[c;c]; d=[d;d];
	Z=CP(t0+1,1:2)'.*a + CP(t0+1,3:4)'.*b + CP(t0+1,5:6)'.*c + CP(t0+1,7:8)'.*d;
	if (j>1), Z=Z'; end
endfunction;
