13def polygon(ax, points, fill='#edf4f8', z=2):
14 ax.add_patch(Polygon(points, closed=
True, facecolor=fill, edgecolor=BLUE, linewidth=1.5, zorder=z))
19def arrow(ax, start, end, color=BLUE):
20 ax.add_patch(FancyArrowPatch(start, end, arrowstyle=
'-|>', mutation_scale=12, color=color, lw=1.3))
23 fig, ax = plt.subplots(figsize=(10, 2.7))
24 ax.set(xlim=(-1.1, 9.1), ylim=(-.95, 1.6), aspect=
'equal')
26 centers = [0, 2.65, 5.3, 7.95]
28 p = np.array([[-.75,-.25],[.65,-.25],[.32,1.05],[-.05,.2]])
31 line(ax, p[[3,i]], dashed=
True, z=3)
32 polygon(ax, p[[0,1,2]],
'#fae3cc', z=3.5)
35 line(ax, p[[3,i]], dashed=
True, z=4)
36 face = p[[0,1,2]] + [centers[1],0]
37 labels = [
'Tetrahedron',
'Triangle',
'Edge',
'Vertex']
38 detail = [
'4 vertices',
'3 vertices',
'2 vertices',
'1 vertex']
39 title =
'Simplex<3, order>: boundary entities'
41 p = np.array([[-.75,.05],[-.4,-.25],[.4,-.25],[.75,.05],[.4,.48],[-.4,.48]])
45 polygon(ax, np.array([p[i],p[i+1],back[i+1],back[i]]),
'#d9e9f1')
47 face = p + [centers[1],.15]
48 labels = [
'Region',
'Face',
'Edge',
'Vertex']
49 detail = [
'region ID',
'planar polygon',
'shared by faces',
'position']
50 title =
'Polyhedron<3, order>: boundary entities'
52 line(ax, face[:2], ORANGE)
53 edge = np.array([[-.65,.2],[.65,.2]]) + [centers[2],0]
55 ax.scatter(*edge.T, s=25, color=BLUE, zorder=5)
56 ax.scatter(*edge[1], s=40, color=ORANGE, zorder=6)
57 ax.scatter(centers[3],.2,s=50,color=ORANGE,zorder=6)
58 for i, x
in enumerate(centers):
59 ax.text(x,-.53, f
'{labels[i]} ({3-i}-cell)', ha=
'center', color=DARK, weight=
'bold')
60 ax.text(x,-.8, detail[i], ha=
'center', color=DARK, fontsize=10)
61 for x
in centers[:-1]:
62 arrow(ax, (x+.92,.45), (x+1.66,.45))
64 arrow(ax, (x+1.66,.08), (x+.92,.08), ORANGE)
65 ax.text(3.95,1.4,title,ha=
'center',color=DARK,fontsize=12)
66 name =
'simplex_complex' if simplex
else 'cell_complex'
67 for ext
in [
'pdf',
'png']:
68 fig.savefig(OUT / f
'{name}.{ext}', bbox_inches=
'tight', dpi=180)