Skip to content

Instantly share code, notes, and snippets.

@omaraflak
Last active February 20, 2022 20:52
Show Gist options
  • Save omaraflak/d0ed86f99a33c1543d9d521a43700ac9 to your computer and use it in GitHub Desktop.
Save omaraflak/d0ed86f99a33c1543d9d521a43700ac9 to your computer and use it in GitHub Desktop.
Vortex
import numpy as np
from matplotlib import collections as mc, pyplot as plt
Point = tuple[float, float]
Line = tuple[Point, Point]
def get_lines(multiplier: int, modulus: int) -> list[Line]:
start = np.arange(1, modulus)
end = start * multiplier % modulus
angle = 2 * np.pi / modulus
points = lambda x: np.column_stack((np.cos(x), np.sin(x)))
return list(zip(points(start * angle), points(end * angle)))
def diagram(multiplier: int, modulus: int, linewidth: float = 0.5):
lines = get_lines(multiplier, modulus)
_, ax = plt.subplots()
ax.add_collection(mc.LineCollection(lines, linewidths=linewidth))
plt.axis("square")
plt.show()
if __name__ == "__main__":
diagram(240, 7417, 0.01)
@omaraflak
Copy link
Author

image

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