functional language for computing with geometry
%================================== Bernstain/Bezier's basis ==================================%
DEF Domain (n::IsIntPos) = QUOTE:(#:n:(1/n));
DEF Fact (n::IsInt) = *:(CAT:<<1>, 2..n>);
DEF Choose (n,i::IsInt) = Fact:n / (Fact:i * Fact:(n-i));
DEF Bernstein (n::IsInt)(i::IsInt) =
*~[K:(Choose:<n,i>),**~[ID,K:i], **~[-~[K:1,ID],K:(n-i)]]~S1;
DEF BernsteinBase (n::IsInt) = AA:(Bernstein:n):(0..n);
DEF BernsteinBasisGraph (n::IsIntPos) = STRUCT:(
(CONS~AA:MAP~AA:CONS~DISTL):< S1, BernsteinBase:n>:
(Domain:23)
);
STRUCT:<@1:(CUBOID:<1,1>), BernsteinBasisGraph:4>;