Mandelbrot set: Difference between revisions
Content added Content deleted
(→Distance Estimation, Normal Maps, Mercator Maps and Deep Zoom: Improved readability and speed) |
(→Distance Estimation, Normal Maps, Mercator Maps and Perturbation Theory: Improved readability) |
||
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: |
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 |
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 |
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 |
U = Z[N] ./ dZ[N] |
||
T[N] = max.(((real.(U |
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])) |
|||
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) |