Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Folder full of pertinent coursework

1666 views
1
import math
2
3
class JuliaSet(object):
4
def __init__(self, c, n = 100):
5
self.c = c
6
self.n = n
7
self._d = 0.001
8
self._complexplane = []
9
self.set = []
10
11
def juliamap(self, z):
12
return (z ** 2) + self.c
13
14
def iterate(self, z):
15
m = 0
16
while True:
17
z = self.juliamap(z)
18
m += 1
19
if abs(z) > 2:
20
return m
21
if m >= self.n:
22
return 0
23
24
def makeplane(self):
25
plane = [i * self._d for i in range(int(-2 / self._d), int(2 / self._d), 1)]
26
self._complexplane=[complex(x,y) for x in plane for y in plane]
27
28
def set_spacing(self, d):
29
self._d = d
30
self.makeplane()
31
32
def generate(self):
33
self.set = [self.iterate(i) for i in self._complexplane]
34
return self.set
35