Mandelbrot set: Difference between revisions

Content added Content deleted
Line 7,986: Line 7,986:


direction, height = 45, 1.5 # direction and height of the incoming light
direction, height = 45, 1.5 # direction and height of the incoming light
stripes, damping = 5.0, 2.0 # stripe density and damping parameter
stripes, damping = 10, 2.0 # stripe density and damping parameter


x = range(0, 2, length=d+1)
x = range(0, 2, length=d+1)
Line 8,003: Line 8,003:
end
end


N = abs.(Z) .> 2 # exterior distance estimation
N = abs.(Z) .>= r # normal map effect 1 (potential function)
D[N] = log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N])

heatmap(D .^ 0.1, c=:balance)
savefig("Mandelbrot_distance_est.png")

N = abs.(Z) .> 2 # normal map effect 1 (potential function)
P, Q = S[N] ./ T[N], (S[N] .+ sin.(stripes .* angle.(Z[N]))) ./ (T[N] .+ 1)
P, Q = S[N] ./ T[N], (S[N] .+ sin.(stripes .* angle.(Z[N]))) ./ (T[N] .+ 1)
F = 1 .- log2.(log.(abs.(Z[N])) ./ log(r))
F = log2.(log.(abs.(Z[N])) ./ log(r)) # fraction between 0 and 1 (for interpolation)
H = P .+ (Q .- P) .* F .* F .* (3 .- 2 .* F) # hermite interpolation
H = F .* P .+ (1 .- F) .* Q # height perturbation (by linear interpolation)
U = Z[N] ./ dZ[N] # normal vectors to the equipotential lines
U = Z[N] ./ dZ[N] # normal vectors to the equipotential lines
U, v = U ./ abs.(U), exp(direction / 180 * pi * im) # unit normal vectors and unit 2D vector
U, v = U ./ abs.(U), exp(direction / 180 * pi * im) # unit normal vectors and unit 2D vector
Line 8,020: Line 8,014:
savefig("Mandelbrot_normal_map_1.png")
savefig("Mandelbrot_normal_map_1.png")


N = abs.(Z) .> 2 # normal map effect 2 (distance estimation)
N = abs.(Z) .>= r # normal map effect 2 (distance estimation)
U = Z[N] .* dZ[N] .* ((1 .+ log.(abs.(Z[N]))) .* conj.(dZ[N] .^ 2) .- log.(abs.(Z[N])) .* conj.(Z[N] .* ddZ[N]))
U = Z[N] .* dZ[N] .* ((1 .+ log.(abs.(Z[N]))) .* conj.(dZ[N] .^ 2) .- log.(abs.(Z[N])) .* conj.(Z[N] .* ddZ[N]))
U, v = U ./ abs.(U), exp(direction / 180 * pi * im) # unit normal vectors and unit 2D vector
U, v = U ./ abs.(U), exp(direction / 180 * pi * im) # unit normal vectors and unit 2D vector