from math import sqrt as SQ
from matplotlib.patches import Polygon as poly
import matplotlib.pyplot as plt
c1 = SQ(3)/2
c2 = SQ(33)/12
c3 = (3*SQ(11)+6)/12
c4 = SQ(11)/2
def drawDiamond(ax, fig, pts):
d = poly([pts[0][0], pts[1][0], pts[2][0],
pts[3][0], pts[0][0], pts[2][0]],
ec = 'k',
fc = '#00000000',
ls =":",
lw = 2.5)
ax.add_patch(d)
for p in pts :
ax.scatter(p[0][0],
p[0][1],
c = p[1],
lw = 10,
zorder = 2)
def vertDiamond(pts) :
fig = plt.figure(figsize = (6, 6))
ax = fig.add_subplot(111, xlim = (-0.1, 2.1), ylim = (0.1, 2.1))
#Remove axes and ticks.
for side in ['bottom', 'left', 'top', 'right']:
ax.spines[side].set_visible(False)
ax.set_xticks([])
ax.set_yticks([])
drawDiamond(ax, fig, pts)
fig.savefig("2023.04.14 Express1.png",
bbox_inches = 'tight')
def solution(pts1, pts2, n) :
fig = plt.figure(figsize = (12, 12))
ax = fig.add_subplot(111, xlim = (-0.1, 2.3), ylim = (0.1, 2.3))
#Remove axes and ticks.
for side in ['bottom', 'left', 'top', 'right']:
ax.spines[side].set_visible(False)
ax.set_xticks([])
ax.set_yticks([])
drawDiamond(ax, fig, pts1)
drawDiamond(ax, fig, pts2)
ax.plot((pts1[3][0][0], pts2[3][0][0]),
(pts1[3][0][1], pts2[3][0][1]),
c = 'k',
ls =":",
lw = 2.5,
zorder = 1)
fig.savefig("2023.04.14 Express" + str(n) + ".png",
bbox_inches = 'tight')
pts = [([0.5, 1], 'r'),
([1, 1+c1], 'g'),
([1.5, 1], 'b'),
([1, 1-c1], 'g')]
vertDiamond(pts)
def triangle() :
fig = plt.figure(figsize = (8, 8))
ax = fig.add_subplot(111, xlim = (-0.1, 2.3), ylim = (0.1, 2.3))
#Remove axes and ticks.
for side in ['bottom', 'left', 'top', 'right']:
ax.spines[side].set_visible(False)
ax.set_xticks([])
ax.set_yticks([])
d = poly([[1, 0.5+c4], [0.5, 0.5],
[1.5, 0.5], [1, 0.5+c4]],
ec = 'k',
fc = '#00000000',
ls =":",
lw = 2.5)
ax.add_patch(d)
variables = [("√3", (0.6, 1.3), 'k'),
("√3", (1.25, 1.3), 'k'),
("1", (.965, 0.4), 'k'),
("α", (.965, 1.9), 'k')]
for v in variables :
plt.annotate(v[0], v[1], c = v[2], fontsize = 20)
fig.savefig("2023.04.14 Express2.png",
bbox_inches = 'tight')
triangle()
pts1 = [([0.75-c2, c3+SQ(3)/12], 'r'),
([1, 0.5+c4], 'g'),
([0.75+c2, c3-SQ(3)/12], 'b'),
([0.5, 0.5], 'g')]
pts2 = [([1.25+c2, c3+SQ(3)/12], 'r'),
([1, 0.5+c4], 'g'),
([1.25-c2, c3-SQ(3)/12], 'b'),
([1.5, 0.5], 'g')]
solution(pts1, pts2, 3)
pts2 = [([1.25+c2, c3+SQ(3)/12], 'b'),
([1, 0.5+c4], 'g'),
([1.25-c2, c3-SQ(3)/12], 'r'),
([1.5, 0.5], 'g')]
solution(pts1, pts2, 4)