Mandelbrot set: Difference between revisions

Line 8,947:
 
===Distance Estimation, Normal Maps, 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#Normal_map_effect ''Normal map effect'']). Note that the second derivative (ddZ) grows very fast, so the second method can only be used for small iteration numbers (n <= 400).
<syntaxhighlight lang="python">import numpy as np
import matplotlib.pyplot as plt
Line 8,979:
N = abs(Z) > 2 # normal map 1 (potential function)
U = Z[N] / dZ[N]
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)
 
Line 8,988:
LN, ZN, AN, BN = np.log(abs(Z[N])), Z[N], dZ[N], ddZ[N]
U = ZN * AN * ((1 + LN) * np.conj(AN ** 2) - LN * np.conj(ZN * BN))
U = U / abs(U) # unit normal vector to the equidistant lines
T[N] = np.maximum((U.real * v.real + U.imag * v.imag + height) / (1 + height), 0)
 
Line 9,118:
EM, CM, IM = E[M], C[M], I[M]
E[M], I[M] = (2 * S[IM] + EM) * EM + CM, IM + 1
Z[M], dZ[M] = S[IM+1I[M]] + E[M], 2 * Z[M] * dZ[M] + 1
 
N = abs(Z) > 2 # exterior distance estimation
305

edits