Mandelbrot set: Difference between revisions

Content added Content deleted
Line 6,567: Line 6,567:


===Distance Estimation, Normal Maps, Mercator Maps and Perturbation Theory ===
===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'']).
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#Normal_map_effect ''Normal map effect'']).
<syntaxhighlight lang="julia">using Plots
<syntaxhighlight lang="julia">using Plots
gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200)
gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200)
Line 6,574: Line 6,574:
n, r = 200, 500 # number of iterations and escape radius (r > 2)
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
height, angle = 1.5, 45 # height factor and direction of the incoming light
v = exp(angle / 180 * pi * im) # unit 2D vector in this direction
v = exp(angle / 180 * pi * im) # unit 2D vector in this direction


Line 6,583: Line 6,583:
C = (2.0 + 1.0im) .* (A' .+ B .* im) .- 0.5
C = (2.0 + 1.0im) .* (A' .+ B .* im) .- 0.5


Z, dZ, ddZ, U = zero(C), zero(C), zero(C), zero(C)
Z, dZ, ddZ = zero(C), zero(C), zero(C)
D, T = zeros(size(C)), zeros(size(C))
D, T = zeros(size(C)), zeros(size(C))


Line 6,599: Line 6,599:


N = abs.(Z) .> 2 # normal map (potential function)
N = abs.(Z) .> 2 # normal map (potential function)
U[N] = Z[N] ./ dZ[N]
U = Z[N] ./ dZ[N]
T[N] = max.(((real.(U[N]) .* real.(v) .+ imag.(U[N]) .* imag.(v)) ./ abs.(U[N]) .+ height) ./ (1 .+ height), 0)
T[N] = max.(((real.(U) .* real.(v) .+ imag.(U) .* imag.(v)) ./ abs.(U) .+ height) ./ (1 .+ height), 0)


heatmap(T .^ 1.0, c=:grays)
heatmap(T .^ 1.0, c=:grays)
Line 6,606: Line 6,606:


N = abs.(Z) .> 2 # normal map (distance estimation)
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] = max.(((real.(U[N]) .* real.(v) .+ imag.(U[N]) .* imag.(v)) ./ abs.(U[N]) .+ height) ./ (1 .+ height), 0)
U = ZN .* dZN .* ((1 .+ log.(abs.(ZN))) .* conj.(dZN .^ 2) .- log.(abs.(ZN)) .* conj.(ZN .* ddZN))
T[N] = max.(((real.(U) .* real.(v) .+ imag.(U) .* imag.(v)) ./ abs.(U) .+ height) ./ (1 .+ height), 0)


heatmap(T .^ 1.0, c=:grays)
heatmap(T .^ 1.0, c=:grays)