In [2]:
import numpy as np
import matplotlib.pyplot as plt
class JuliaSet:
def __init__(self, c, n=100):
self.c = c
self.n = n
self._d=.001
self._complexplane = []
for i in (0, 4/self._d):
for k in (0, 4/self._d):
self._complexplane.append(complex(-2+i*self._d,-2j+k*self._d) )
def juliamap(self, z):
return self.c+z**2
def iterate(self, z):
m = 1
runningz = z
while True:
juliamap(self, z)
if abs(runningz)>2:
return m
elif m>=n:
return 0
else:
m+=1
def set_spacing(self, _d):
self._d = _d
self._complexplane = []
for i in np.arange(-2, 2, self._d):
for j in np.arange(-2, 2, self._d):
self._complexplane.append(complex(i, j))
return self._complexplane
def generate(self):
self._d
self.set=[]
for i in np.arange(-2, 2, self._d):
for j in np.arange(-2, 2, self._d):
self.set.append(complex(i,j))
return self.set
def frange(start, stop, step):
i = start
while i < stop:
yield i
i += step
myJuliaSet=JuliaSet(0, 100)
In [ ]: