Pensieve Header: Programs to generate pictures of the barycentric subdivision, following pensieve://2010-06/.

SetDirectory["C:\\drorbn\\AcademicPensieve\\Classes\\17-SummerHomology"];

del[s_Simplex] := Table[
Delete[s, i],
{i, Length[s]}
];
del[expr_] := expr /. s_Simplex :> del[s];
cone[a_, s_Simplex] := Prepend[s, a];
cone[a_, expr_] := expr /. s_Simplex :> cone[a, s];
B[Simplex[v_]] := Simplex[v];
B[s_Simplex] := cone[Expand[Mean[List @@ s]], B[del[s]]];
B[expr_] := expr /. s_Simplex :> B[s];

B[Simplex[e0,e1,e2]]

Draw2D[ss_] := Module[
{rule, mat},
rule = Thread[{e0,e1,e2} -> (({{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}))];
mat=Drop[Orthogonalize[(({{1, 1, 1}, {0, 1, 0}, {0, 0, 1}}))], 1];
Graphics[ss /. s_Simplex :> {
RGBColor[Random[], Random[], Random[]],
Polygon[mat.(# /.rule)& /@ List @@ s]
}]
]

MakeImage["BCSD-2-1", Draw2D[B[Simplex[e0,e1,e2]]]]

MakeImage["BCSD-2-2", Draw2D[B[B[Simplex[e0,e1,e2]]]]]

MakeImage["BCSD-2-3", Draw2D[B[B[B[Simplex[e0,e1,e2]]]]]]

Draw3D[ss_, opts___] := Module[
{rule, mat, z, r, t},
mat=IdentityMatrix[4];
rule = Thread[{e0,e1,e2, e3} -> mat];
mat=Drop[Orthogonalize[ReplacePart[mat, {1,1,1,1}, 1]], 1];
Graphics3D[{
 Opacity[0.5],
Union[Flatten[ss]] /. s_Simplex :> {
Hue[Random[]],
Polygon[mat.(# /.rule)& /@ List @@ s]
}
},
Boxed -> False, opts
]
]

MakeImage["BCSD-3-1", Draw3D[del[B[Simplex[e0,e1,e2, e3]]],
ViewPoint->{-0.755491,-2.80478,0.749964},ViewVertical->{0.,0.,1.}]]

MakeImage["BCSD-3-2",Draw3D[del[B[B[Simplex[e0,e1,e2, e3]]]],
ViewPoint->{-0.755491,-2.80478,0.749964},ViewVertical->{0.,0.,1.}]]

ShrinkTo[p_, s_Simplex] := Module[
{b=(1-p)Mean[List @@s]},
Expand[p#+b]& /@ s
];
ShrinkTo[p_, expr_] := expr /. s_Simplex :> ShrinkTo[p, s]

Draw3D[del[ShrinkTo[0.7, B[Simplex[e0,e1,e2, e3]]]]]

MakeImage["BCSD-3-1S",Draw3D[del[ShrinkTo[0.7, B[Simplex[e0,e1,e2, e3]]]],
ViewPoint->{-0.755491,-2.80478,0.749964},ViewVertical->{0.,0.,1.}]]

MakeImage["BCSD-3-2S",Draw3D[del[ShrinkTo[0.7,B[ShrinkTo[0.7,B[Simplex[e0,e1,e2, e3]]]]]],
ViewPoint->{-0.755491,-2.80478,0.749964},ViewVertical->{0.,0.,1.}]]