Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
Created November 4, 2024 05:24
Show Gist options
  • Save pgtwitter/cd564451515f50299c00d3114d817299 to your computer and use it in GitHub Desktop.
Save pgtwitter/cd564451515f50299c00d3114d817299 to your computer and use it in GitHub Desktop.
ポアンカレの円板(参考 https://qiita.com/hibit/items/5a49bedaa826fddf0a33 を 縦横比を1にしたもの)
# %%
# reference https://qiita.com/hibit/items/5a49bedaa826fddf0a33
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set(aspect=1)
theta = np.linspace(0, 2*np.pi, 100)
colorlist = ["r", "g", "b", "c", "m", "y"]
t = list(range(0, 6))
for n in t:
n2 = np.power(2, n)
for phi in np.linspace(0, 2*np.pi, 2*n2+1):
x = np.cos(theta)*np.tan(np.pi/n2) + np.cos(phi)/np.cos(np.pi/n2)
y = np.sin(theta)*np.tan(np.pi/n2) + np.sin(phi)/np.cos(np.pi/n2)
ax.plot(x, y, lw=0.5, color=colorlist[n-2])
for phi in np.linspace(0, 2*np.pi, 9):
t = np.linspace(-2, 2, 100)
x = t*np.cos(phi)
y = t*np.sin(phi)
ax.plot(x, y, lw=0.5, color='y')
ax.plot(np.cos(theta), np.sin(theta), color='black')
plt.xlim(-1, 1)
plt.ylim(-1, 1)
# plt.grid()
plt.show()
@pgtwitter
Copy link
Author

output

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