Skip to content

Instantly share code, notes, and snippets.

@dirediredock
Last active March 4, 2025 03:30
Show Gist options
  • Save dirediredock/8d1cfcd3f41ec39e7e4310d16d946735 to your computer and use it in GitHub Desktop.
Save dirediredock/8d1cfcd3f41ec39e7e4310d16d946735 to your computer and use it in GitHub Desktop.
# by Matias I. Bofarull Oddo - 2022.04.20
# Inspired by Rafael Araujo's post:
# https://twitter.com/rafaela31416/status/1509334444976779264?s=20&t=mswbmkrYcJzZC5_5pbir7A
import matplotlib.pyplot as plt
Φ = (1 + (5 ** (1 / 2))) / 2
X_square = []
Y_square = []
points = [
[Φ, Φ],
[Φ, Φ * 2],
[Φ * 2, Φ * 2],
[Φ * 2, Φ],
]
for pair in points:
X_square.append(pair[0])
Y_square.append(pair[1])
X_square.append(points[0][0])
Y_square.append(points[0][1])
X_rectangle = []
Y_rectangle = []
points = [
[Φ - (1 / 2), Φ + ((Φ - 1) / 2)],
[Φ - (1 / 2), Φ * 2 - ((Φ - 1) / 2)],
[Φ * 2 + (1 / 2), Φ * 2 - ((Φ - 1) / 2)],
[Φ * 2 + (1 / 2), Φ + ((Φ - 1) / 2)],
]
for pair in points:
X_rectangle.append(pair[0])
Y_rectangle.append(pair[1])
X_rectangle.append(points[0][0])
Y_rectangle.append(points[0][1])
Z_wall = [0, 0, 0, 0, 0]
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection="3d", proj_type="ortho")
ax.set_box_aspect(aspect=(1, 1, 1))
ax.plot(X_square, Y_square, Z_wall, c="gray")
ax.plot(Z_wall, X_square, Y_square, c="gray")
ax.plot(Y_square, Z_wall, X_square, c="gray")
ax.plot(X_rectangle, Y_rectangle, Z_wall, c="gray")
ax.plot(Z_wall, X_rectangle, Y_rectangle, c="gray")
ax.plot(Y_rectangle, Z_wall, X_rectangle, c="gray")
ax.plot(
[Φ, Φ * 1.5, Φ * 2],
[X_square[0], X_rectangle[0], X_square[0]],
[Y_square[0], Y_rectangle[0], Y_square[0]],
c="k",
)
ax.plot(2 * [Φ * 1.5], X_rectangle[0:2], Y_rectangle[0:2], c="k")
ax.plot(
[Φ, Φ * 1.5, Φ * 2],
[X_square[1], X_rectangle[1], X_square[1]],
[Y_square[1], Y_rectangle[1], Y_square[1]],
c="k",
)
ax.plot(
[Φ, Φ * 1.5, Φ * 2],
[X_square[2], X_rectangle[2], X_square[2]],
[Y_square[2], Y_rectangle[2], Y_square[2]],
c="k",
)
ax.plot(2 * [Φ * 1.5], X_rectangle[2:4], Y_rectangle[2:4], c="k")
ax.plot(
[Φ, Φ * 1.5, Φ * 2],
[X_square[3], X_rectangle[3], X_square[3]],
[Y_square[3], Y_rectangle[3], Y_square[3]],
c="k",
)
ax.plot(
[X_square[0], X_rectangle[0], X_square[0]],
[Y_square[0], Y_rectangle[0], Y_square[0]],
[Φ, Φ * 1.5, Φ * 2],
c="k",
)
ax.plot(X_rectangle[0:2], Y_rectangle[0:2], 2 * [Φ * 1.5], c="k")
ax.plot(
[X_square[1], X_rectangle[1], X_square[1]],
[Y_square[1], Y_rectangle[1], Y_square[1]],
[Φ, Φ * 1.5, Φ * 2],
c="k",
)
ax.plot(
[X_square[2], X_rectangle[2], X_square[2]],
[Y_square[2], Y_rectangle[2], Y_square[2]],
[Φ, Φ * 1.5, Φ * 2],
c="k",
)
ax.plot(X_rectangle[2:4], Y_rectangle[2:4], 2 * [Φ * 1.5], c="k")
ax.plot(
[X_square[3], X_rectangle[3], X_square[3]],
[Y_square[3], Y_rectangle[3], Y_square[3]],
[Φ, Φ * 1.5, Φ * 2],
c="k",
)
ax.plot(
[Y_square[0], Y_rectangle[0], Y_square[0]],
[Φ, Φ * 1.5, Φ * 2],
[X_square[0], X_rectangle[0], X_square[0]],
c="k",
)
ax.plot(Y_rectangle[0:2], 2 * [Φ * 1.5], X_rectangle[0:2], c="k")
ax.plot(
[Y_square[1], Y_rectangle[1], Y_square[1]],
[Φ, Φ * 1.5, Φ * 2],
[X_square[1], X_rectangle[1], X_square[1]],
c="k",
)
ax.plot(
[Y_square[2], Y_rectangle[2], Y_square[2]],
[Φ, Φ * 1.5, Φ * 2],
[X_square[2], X_rectangle[2], X_square[2]],
c="k",
)
ax.plot(Y_rectangle[2:4], 2 * [Φ * 1.5], X_rectangle[2:4], c="k")
ax.plot(
[Y_square[3], Y_rectangle[3], Y_square[3]],
[Φ, Φ * 1.5, Φ * 2],
[X_square[3], X_rectangle[3], X_square[3]],
c="k",
)
ax.view_init(elev=35, azim=45)
plt.tight_layout()
plt.axis("off")
plt.show()
@dirediredock
Copy link
Author

Untitled.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment