Mandelbrot set: Difference between revisions
→Normalized Counting, Distance Estimation, Mercator Maps and Deep Zoom: Smoothing and normalized iteration numbers replaced by normal maps (sources adjusted).
(added vala) |
(→Normalized Counting, Distance Estimation, Mercator Maps and Deep Zoom: Smoothing and normalized iteration numbers replaced by normal maps (sources adjusted).) |
||
Line 8,935:
plt.show()</syntaxhighlight>
===
The Mandelbrot set is represented by distance estimation and normal maps using NumPy and complex matrices (cf. Arnaud Chéritat: [https://www.math.univ-toulouse.fr/~cheritat/wiki-draw/index.php/Mandelbrot_set#Boundary_detection_methods_via_distance_estimators ''Boundary detection methods via distance estimators''] and [https://www.math.univ-toulouse.fr/~cheritat/wiki-draw/index.php/Mandelbrot_set#Normal_map_effect ''Normal map effect'']).
<syntaxhighlight lang="python">import numpy as np
import matplotlib.pyplot as plt
Line 8,943 ⟶ 8,942:
d, h = 800, 500 # pixel density (= image width) and image height
n, r = 200, 500 # number of iterations and escape radius (r > 2)
height, angle = 1.5, 45 # height factor of the incoming light and direction of this light
v = np.exp(angle / 180 * np.pi * 1j) # unit 2D vector in this direction
x = np.linspace(0, 2, num=d+1)
Line 8,948 ⟶ 8,950:
A, B = np.meshgrid(x - 1, y - h / d)
C = (2.0
Z, dZ, ddZ, U = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C), np.zeros_like(C)
for k in range(n):
M =
N = abs(Z) > 2 # exterior distance estimation
plt.imshow(S ** 0.1, cmap=plt.cm.twilight_shifted)▼
D[N] = np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N])
plt.savefig("Mandelbrot_set_1.png", dpi=200)
N = abs(Z) >
T[N] = np.maximum(((U[N].real * v.real + U[N].imag * v.imag) / abs(U[N]) + height) / (1 + height), 0)
plt.imshow(T **
plt.savefig("Mandelbrot_set_2.png", dpi=200)
N = abs(Z) > 2 #
T[N] = np.maximum(((U[N].real * v.real + U[N].imag * v.imag) / abs(U[N]) + height) / (1 + height), 0)
plt.imshow(
plt.savefig("Mandelbrot_set_3.png", dpi=200)</syntaxhighlight>
Line 8,999 ⟶ 9,005:
N = abs(Z) > 2 # exterior distance estimation
D[N] =
plt.imshow(D.T ** 0.1, cmap=plt.cm.nipy_spectral, origin="lower")
plt.savefig("Mercator_Mandelbrot_map.png", dpi=200)
Line 9,052 ⟶ 9,058:
N = abs(Z) > 2 # exterior distance estimation
D[N] =
plt.imshow(D ** 0.3, cmap=plt.cm.nipy_spectral, origin="lower")
plt.savefig("Mandelbrot_deep_zoom.png", dpi=200)</syntaxhighlight>
Line 9,097 ⟶ 9,103:
N = abs(Z) > 2 # exterior distance estimation
D[N] =
plt.imshow(D.T ** 0.03, cmap=plt.cm.nipy_spectral, origin="lower")
plt.savefig("Mercator_Mandelbrot_deep_map.png", dpi=200)</syntaxhighlight>
|