Jump to content

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>
 
===NormalizedDistance CountingEstimation, DistanceNormal EstimationMaps, Mercator Maps and Deep Zoom===
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'']).
The Mandelbrot set is printed with smooth colors.
The ''e^(-|z|)-smoothing'', ''normalized iteration count'' and ''exterior distance estimation'' algorithms are used with NumPy and complex matrices (see Javier Barrallo & Damien M. Jones: [http://www.mi.sanu.ac.rs/vismath/javier/index.html ''Coloring Algorithms for Dynamical Systems in the Complex Plane''] and Mikael Hvidtfeldt Christensen: [http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations ''Distance Estimated 3D Fractals (V): The Mandelbulb & Different DE Approximations'']).
<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 -+ 1.0j) * (A + B * 1j) - 0.5
 
Z, dZ, ddZ, U = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C), np.zeros_like(C)
SD, T, D = np.zeros(C.shape), np.zeros(C.shape), np.zeros(C.shape)
 
for k in range(n):
M = abs(Z).real ** 2 + Z.imag ** 2 < r ** 2
SZ[M], TdZ[M], ddZ[M] = SZ[M] ** 2 + np.exp(-C[M], 2 * abs(Z[M])), T* dZ[M] + 1, 2 * (dZ[M] ** 2 + Z[M] * ddZ[M])
Z[M], dZ[M] = Z[M] ** 2 + C[M], 2 * Z[M] * dZ[M] + 1
 
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.imshow(SD ** 0.1, cmap=plt.cm.twilight_shifted, origin="lower")
plt.savefig("Mandelbrot_set_1.png", dpi=200)
 
N = abs(Z) > r2 # normalizednormal iterationmap count(potential function)
TU[N] = TZ[N] -/ np.log2(np.log(abs(ZdZ[N])) / np.log(r))
T[N] = np.maximum(((U[N].real * v.real + U[N].imag * v.imag) / abs(U[N]) + height) / (1 + height), 0)
 
plt.imshow(T ** 0.1.0, cmap=plt.cm.twilight_shiftedgray, origin="lower")
plt.savefig("Mandelbrot_set_2.png", dpi=200)
 
N = abs(Z) > 2 # exteriornormal map (distance estimation)
DU[N] = 0.5Z[N] * dZ[N] * ((1 + np.log(abs(Z[N]))) * np.conj(dZ[N] ** 2) - np.log(abs(Z[N])) /* absnp.conj(dZZ[N] * ddZ[N]))
T[N] = np.maximum(((U[N].real * v.real + U[N].imag * v.imag) / abs(U[N]) + height) / (1 + height), 0)
 
plt.imshow(DT ** 0.1.0, cmap=plt.cm.twilight_shiftedgray, origin="lower")
plt.savefig("Mandelbrot_set_3.png", dpi=200)</syntaxhighlight>
 
Line 8,999 ⟶ 9,005:
 
N = abs(Z) > 2 # exterior distance estimation
D[N] = 0.5 * np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[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] = 0.5 * np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[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] = 0.5 * np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N])
 
plt.imshow(D.T ** 0.03, cmap=plt.cm.nipy_spectral, origin="lower")
plt.savefig("Mercator_Mandelbrot_deep_map.png", dpi=200)</syntaxhighlight>
 
305

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.