Mandelbrot set: Difference between revisions

Content added Content deleted
Line 8,905: Line 8,905:
n, r = 200, 500 # number of iterations and escape radius (r > 2)
n, r = 200, 500 # number of iterations and escape radius (r > 2)


height, angle = 1.5, 45 # height factor and direction of the incoming light
height, direction = 1.5, 45 # height factor and direction of the incoming light
v = np.exp(angle / 180 * np.pi * 1j) # unit 2D vector in this direction
v = np.exp(direction / 180 * np.pi * 1j) # unit 2D vector in this direction


x = np.linspace(0, 2, num=d+1)
x = np.linspace(0, 2, num=d+1)
Line 8,931: Line 8,931:
U = Z[N] / dZ[N]
U = Z[N] / dZ[N]
U = U / abs(U) # unit normal vector to the equipotential lines
U = U / abs(U) # unit normal vector to the equipotential lines
T[N] = np.maximum((U.real * v.real + U.imag * v.imag + height) / (1 + height), 0)
S = np.sin(100 * np.angle(U)) / 10 # perturbation function (stripes)
T[N] = np.maximum((U.real * v.real + U.imag * v.imag + height + S) / (1 + height), 0)


plt.imshow(T ** 1.0, cmap=plt.cm.bone, origin="lower")
plt.imshow(T ** 1.0, cmap=plt.cm.bone, origin="lower")