The Catalan Project

(*This is the program fom class*)

ts[n_Integer] := ts[Range[0, n+1]];
ts[{_,_}]={ds[]};
ts[vs_List]:=Module[{l,r,k,t1,t2,tds},
Union@@Table[
l=ts[Prepend[vs[[k;;]],vs[[1]]]];
r=ts[vs[[2;;k]]];
Flatten[Table[
tds=Join[t1,t2];
If[k>3,AppendTo[tds,d[vs[[2]],vs[[k]]]]];
If[k<Length[vs],AppendTo[tds,d[vs[[1]],vs[[k]]]]];
tds,
{t1,l},{t2,r}]],
{k,3,Length[vs]}
]
]

Draw all triangulations

n=Input["Enter"]
lll = Table[Union[ds@@Range[0,n+1]/.j_Integer:> d[j,j+1]/. n+2 :> 0,s], {s, ts[n]}];
Manipulate[Multicolumn[lll/. ds[ls___] :> Graphics[{ls}]/.d[i_,j_]:> Line[{i,j}]/. j_Integer :> {Cos[2 π j/(n+2)], Sin[2 π j/(n+2)]},Frame->All,ItemSize->n],{n,4,7,1}]

Draw a single triangulation

poly[tr_ds] := Module[{bb},
bb = Union[ds@@Range[0,Length[tr]+2]/.j_Integer:> d[j,j+1]/. Length[tr]+3 :> 0,tr];
Graphics[List@@bb]/.d[i_,j_]:> Line[{i,j}]/. j_Integer :> {Cos[2 π j/(Length[tr]+3)], Sin[2 π j/(Length[tr]+3)]}
]

poly[ts[3][[1]]]