-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodular_multiplication.py
More file actions
50 lines (40 loc) · 1.33 KB
/
modular_multiplication.py
File metadata and controls
50 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'''
Dibutuhkan :
numpy, matplotlib, PyQt6, PySide6
'''
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('QtAgg')
# Modular Multiplication By Ayub AG
jumlah_titik = 150
radius_lingkaran = 3
fig = plt.figure(facecolor='black')
ax = fig.add_axes([0,0,1,1], aspect='equal', facecolor='black')
ax.set_xticks([])
ax.set_yticks([])
ax.set_xlim(-radius_lingkaran - 0.2, radius_lingkaran + 0.2)
ax.set_ylim(-radius_lingkaran - 0.2, radius_lingkaran + 0.2)
gmbr, = ax.plot([], [], lw=1, color='white', antialiased=True)
sudut_titik = np.linspace(0, 2 * np.pi, jumlah_titik + 1)
titikX = radius_lingkaran * np.sin(sudut_titik)
titikY = radius_lingkaran * np.cos(sudut_titik)
x = np.empty(0)
y = np.empty(0)
for i in np.arange(jumlah_titik):
modulo = (i * 1.2) % jumlah_titik
x = np.append(x, [titikX[i], titikX[int(modulo)], np.nan])
y = np.append(y, [titikY[i], titikY[int(modulo)], np.nan])
gmbr.set_data(x, y)
fig.canvas.draw()
plt.pause(10/1000)
for j in np.arange(1.2, 10, 0.01):
x = np.empty(0)
y = np.empty(0)
for i in np.arange(jumlah_titik):
modulo = (i * j) % jumlah_titik
x = np.append(x, [titikX[i], titikX[int(modulo)], np.nan])
y = np.append(y, [titikY[i], titikY[int(modulo)], np.nan])
gmbr.set_data(x, y)
fig.canvas.draw()
plt.pause(10/1000)