-
Notifications
You must be signed in to change notification settings - Fork 0
/
addingEquations.py
58 lines (38 loc) · 1.17 KB
/
addingEquations.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
from math import pi, cos, sin, tan
# from matplotlib import pyplot as plt
import matplotlib.pyplot as plt
numberOfPoints = 2 ** 6
plotX = []
plotY = []
for i in range(numberOfPoints + 1):
angle = i * pi * 2 / numberOfPoints
x, y = (0,0)
# Simple unit circle
x += cos(angle)
y += sin(angle)
# Simple unit square
x += round(cos(angle))
y += round(sin(angle))
# Pointed star
starPointCount = 4 # numberOfPoints // 8
currentSegment = int(angle / (pi/starPointCount))
angleDifference = 0
if currentSegment % 2 == 0: # Even segment:
angleDifference = (currentSegment * pi / starPointCount) - angle
else:
angleDifference = angle - ((currentSegment+1) * pi / starPointCount)
x -= cos(angle) * angleDifference
y -= sin(angle) * angleDifference
plotX.append(x)
plotY.append(y)
xMax, yMax = max(plotX), max(plotY)
for i in range(numberOfPoints + 1):
plotX[i] /= xMax
plotY[i] /= yMax
figure = plt.figure()
ax = figure.add_subplot()
plt.title(f"Vertices = {numberOfPoints}")
plt.plot(plotX, plotY)
ax.set_aspect('equal', adjustable='box')
# plt.axis('off')
plt.show()