-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2d-visualization.py
123 lines (64 loc) · 2.2 KB
/
2d-visualization.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"""
feel free to message me to add new attractors
available mode : default : put your own 3D attractor here
Clifford
Juan
Henon
"""
startingPosition = [0.1, 0.1] #starting point position
iterations = 1_000_000 #number of points to compute
mode = "Juan" #mode : available : "default" "Clifford" "Juan" "Henon"
_MARKERWIDTH = 0.02 #if lower than one, will be transparent, can be used to trace "occupation maps"
_DISPLAY_EVOLUTION = True #If set to True, will plot X, Y, and Z on a plot at the end
start_display = 0
end_display = 250
print(f'***** Current Settings ***** \n Starting Position = {startingPosition} \n Iterations = {iterations} \n Mode = {mode} \n Settings can be updated directly in the file')
import matplotlib.pyplot as plt
from math import cos, sin
axe = plt.figure().add_subplot()
def NextStep(pos, mode="default"):
px = pos[0]
py = pos[1]
if mode == "default":
x = 0
y = 0
return x, y
elif mode == "Clifford":
alpha = 1.7
beta = 1.8
gamma = 0.9
delta = 0.4
x = sin(alpha * py) + gamma * cos(alpha * px)
y = sin(beta * px) + delta * cos(beta * py)
return x, y
elif mode == "Juan":
c0 = -0.7623860293700191
c1 = -0.6638578730949067
c2 = 1.8167801002094635
c3 = -2.7677186549504844
x = cos(c0 * px)**2 - sin(c1 * py)**2
y = 2*cos(c2 * px) * sin(c3 * py)
return x, y
elif mode == "Henon":
a = 1.4
b = 0.3
x = 1 + py - a * px**2
y = b * px
return x, y
X = [startingPosition[0]]
Y = [startingPosition[1]]
sx, sy = startingPosition[0], startingPosition[1]
for i in range(iterations):
if(i%100000 == 0): print(i, " ", i/iterations*100, "%")
sx, sy = NextStep([sx, sy], mode)
X.append(sx)
Y.append(sy)
print("rendering")
axe.plot(X, Y, marker=".", linewidth=0, markersize=_MARKERWIDTH)
plt.show()
if _DISPLAY_EVOLUTION:
plt.plot(X[start_display:end_display], label="X")
plt.plot(Y[start_display:end_display], label="Y")
plt.title("Evolutions")
plt.legend()
plt.show()