class mendelbert(object):
def __init__(self, iterations=10, plot_points=10, color=-1j):
self.iterations = iterations
self.plot_points = plot_points
self.color = color
def checkpoint(self, c):
z = 0
for i in range(self.iterations):
z = z^2 + c
if abs(z) >= 2: return i*self.color
return 0
def plot(self, rem=-2, rep=2, imm=-2, imp=2):
return complex_plot(self.checkpoint, (rem,rep), (imm,imp), plot_points=self.plot_points)
@interact
def _(zoom = input_box(1, label='zoom'),
re_coord = input_box(0, label='real coordinate'),
im_coord = input_box(0, label='imaginary coordinate'),
iterations = input_box(2, label='iterations'),
pts = input_box(50, label='points'),
color = input_box(-1j, label='complex color as in 1+1j')):
rem, rep = -2/zoom+re_coord, 2/zoom+re_coord
imm, imp = -2/zoom+im_coord, 2/zoom+im_coord
print 'Bottom real edge:', rem
print 'Top real edge:', rep
print 'Bottom imaginary edge:', imm
print 'Top real edge:', imp
print 'Zoom:', zoom
print 'Real coordinate:', re_coord
print 'Imaginary coordinate:', im_coord
print 'Number of iterations:', iterations
print 'Number of points per axis:', pts
print 'Color:', color
P = mendelbert(iterations=iterations, plot_points=pts)
show(P.plot(rem=rem, rep=rep, imm=imm, imp=imp))
|
|
Click to the left again to hide and once more to show the dynamic interactive window
|