Sarcone's dynamic Muller-Lyer illusion

Gen Kuroki

2018-03-10, 2018-09-13

See

In [1]:
using Base64

using Plots
gr(legend=false)
ENV["PLOTS_TEST"] = "true"

# 線分を描く函数
segment(A, B; color="black", kwargs...) = plot([A[1], B[1]], [A[2], B[2]]; color=color, kwargs...)
segment!(A, B; color="black", kwargs...) = plot!([A[1], B[1]], [A[2], B[2]]; color=color, kwargs...)
segment!(p, A, B; color="black", kwargs...) = plot!(p, [A[1], B[1]], [A[2], B[2]]; color=color, kwargs...)

# 円周を描く函数
function circle(O, r; a=0, b=2π, color="black", kwargs...)
    t = linspace(a, b, 1001)
    x(t) = O[1] + r*cos(t)
    y(t) = O[1] + r*sin(t)
    plot(x.(t), y.(t); color=color, kwargs...)
end
function circle!(O, r; a=0, b=2π, color="black", kwargs...)
    t = linspace(a, b, 1001)
    x(t) = O[1] + r*cos(t)
    y(t) = O[2] + r*sin(t)
    plot!(x.(t), y.(t); color=color, kwargs...)
end
function circle!(p, O, r; a=0, b=2π, color="black", kwargs...)
    t = linspace(a, b, 1001)
    x(t) = O[1] + r*cos(t)
    y(t) = O[1] + r*sin(t)
    plot!(p, x.(t), y.(t); color=color, kwargs...)
end

# 表示用函数
showimg(mime, fn) = open(fn) do f
    base64 = base64encode(f)
    display("text/html", """<img src="data:$mime;base64,$base64">""")
end