Mandelbrot set: Difference between revisions

Line 6,567:
 
===Distance Estimation, Normal Maps, Mercator Maps and Perturbation Theory ===
This is a translation of the corresponding Python section. The Mandelbrot set is represented by distance estimation and normal maps using 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="julia">using Plots
gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200)
Line 6,574:
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 thisthe incoming light
v = exp(angle / 180 * pi * im) # unit 2D vector in this direction
 
Line 6,583:
C = (2.0 + 1.0im) .* (A' .+ B .* im) .- 0.5
 
Z, dZ, ddZ, U = zero(C), zero(C), zero(C), zero(C)
D, T = zeros(size(C)), zeros(size(C))
 
Line 6,599:
 
N = abs.(Z) .> 2 # normal map (potential function)
U[N] = Z[N] ./ dZ[N]
T[N] = max.(((real.(U[N]) .* real.(v) .+ imag.(U[N]) .* imag.(v)) ./ abs.(U[N]) .+ height) ./ (1 .+ height), 0)
 
heatmap(T .^ 1.0, c=:grays)
Line 6,606:
 
N = abs.(Z) .> 2 # normal map (distance estimation)
ZN, dZN, ddZN = Z[N], dZ[N], ddZ[N]
U[N] = Z[N] .* dZ[N] .* ((1 .+ log.(abs.(Z[N]))) .* conj.(dZ[N] .^ 2) .- log.(abs.(Z[N])) .* conj.(Z[N] .* ddZ[N]))
T[N]U = max.(((real.(U[N])ZN .* realdZN .* (v)(1 .+ imaglog.(U[N]abs.(ZN))) .* imagconj.(v)dZN .^ 2) ./- log.(abs.(U[N]ZN) .+ height) ./* conj.(1ZN .+* heightddZN), 0)
T[N] = max.(((real.(U) .* real.(v) .+ imag.(U) .* imag.(v)) ./ abs.(U) .+ height) ./ (1 .+ height), 0)
 
heatmap(T .^ 1.0, c=:grays)
305

edits