Mandelbrot set: Difference between revisions

Content added Content deleted
m (→‎Normal Map Effect, Mercator Projection and Deep Zoom Images: Added Jussi Härkönen's paper and made changes to match Arnaud Chéritat's image.)
Line 10,902:
 
===Normal Map Effect, Mercator Projection and Deep Zoom Images===
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). See also [https://web.archive.org/web/20140618000747/http://jussiharkonen.com/files/on_fractal_coloring_techniques(lo-res).pdf ''On Smooth Fractal Coloring Techniques''] by Jussi Härkönen and [https://www.shadertoy.com/view/wtscDX Julia Stripes] on Shadertoy.
<syntaxhighlight lang="python">import numpy as np
import matplotlib.pyplot as plt
Line 10,910:
 
direction, height = 45, 1.5 # direction and height of the incoming light
stripes, damping = 104, 2.0 # stripe density and damping parameter
 
x = np.linspace(0, 2, num=d+1)
Line 10,922:
 
for k in range(n):
M = abs(Z.real ** 2 + Z.imag ** 2) < r ** 2
S[M], T[M] = S[M] + np.sincos(stripes * np.angle(Z[M])), T[M] + 1
Z[M], dZ[M], ddZ[M] = Z[M] ** 2 + C[M], 2 * Z[M] * dZ[M] + 1, 2 * (dZ[M] ** 2 + Z[M] * ddZ[M])
 
N = abs(Z) >= r # normal map effect 1 (potential function)
P, Q = S[N] / T[N], (S[N] + np.sincos(stripes * np.angle(Z[N]))) / (T[N] + 1)
F = np.log2(np.log(np.abs(Z[N])) / np.log(r)) # fraction between 0 and 1 (for interpolation)
HR = Q + (P - Q) * F * PF +* (13 - F)2 * QF) # heighthermite perturbationinterpolation (byr linearis interpolationbetween q and p)
U, H = Z[N] / dZ[N], 1 + R / damping # normal vectors to the equipotential lines and height perturbation
U, v = U / abs(U), np.exp(direction / 180 * np.pi * 1j) # unit normal vectors and unitvector 2Din vectorlight direction
D[N] = np.maximum((U.real * v.real + U.imag * v.imag + (1 + H / damping) * height) / (1 + height), 0)
 
plt.imshow(D ** 1.0, cmap=plt.cm.bone, origin="lower")
Line 10,939:
N = abs(Z) >= r # normal map effect 2 (distance estimation)
U = Z[N] * dZ[N] * ((1 + np.log(abs(Z[N]))) * np.conj(dZ[N] ** 2) - np.log(abs(Z[N])) * np.conj(Z[N] * ddZ[N]))
U, v = U / abs(U), np.exp(direction / 180 * np.pi * 1j) # unit normal vectors and unitvector 2Din vectorlight direction
D[N] = np.maximum((U.real * v.real + U.imag * v.imag + height) / (1 + height), 0)