-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle_map.py
96 lines (73 loc) · 2.49 KB
/
circle_map.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
import numpy as np
import matplotlib.pyplot as plt
import math
angle = np.linspace( 0 , 2 * np.pi , 150 )
radius = 10
hl = [0, 0]
x = radius * np.cos( angle )
y = radius * np.sin( angle )
figure, axes = plt.subplots( 1 )
axes.plot( x, y )
axes.set_aspect( 1 )
plt.title( 'Parametric Equation Circle' )
z = 1
hl = [hl[0]-radius, hl[1]]
for i in range (2*(radius // z)):
cl = [hl[0]+z, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
hl = cl
hl = [0,0]
for x in range (1, (radius)+1):
cl = [hl[0], hl[1]+z]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
chordlength = math.sqrt((radius)**2 - (x)**2)
print(chordlength)
numofiterations = chordlength // z
cl = [hl[0] - numofiterations, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
for y in range (int(numofiterations)):
cl = [hl[0]+z, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
cl = [hl[0] + numofiterations, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
for a in range (int(numofiterations)):
cl = [hl[0]-z, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
hl = [0,0]
for b in range (1, (radius)+1):
cl = [hl[0], hl[1]-z]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
chordlength = math.sqrt((radius)**2 - (b)**2)
print(chordlength)
numofiterations = chordlength // z
cl = [hl[0] - numofiterations, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
for y in range (int(numofiterations)):
cl = [hl[0]+z, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
cl = [hl[0] + numofiterations, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
for a in range (int(numofiterations)):
cl = [hl[0]-z, hl[1]]
plt.plot(cl[0], cl[1], color="blue", marker='o')
# plt.plot([hl[0], cl[0]], [hl[1], cl[1]], 'r')
hl = cl
plt.show()