Last active
February 20, 2022 20:52
-
-
Save omaraflak/d0ed86f99a33c1543d9d521a43700ac9 to your computer and use it in GitHub Desktop.
Vortex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Author
omaraflak
commented
Feb 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment