Julia で亀甲ベースの格子模様を描く(7)
plotter.jl を include
https://blog.goo.ne.jp/r-de-r/e/bd71a52a09801335d56f7c47d879bfe3
plotter.jl に plotarc() を追加した(未完成だが一応使える)
include("plotter.jl")
function kikkou7(nx=6, ny=5; r=1, d=r/3, width=600, height=400)
function unit(x, y, r, d)
udrl1 = [:lower, :lower, :lower, :upper, :upper, :upper]
udrl2 = [:upper, :lower, :lower, :lower, :upper, :upper]
xs = [0, sqrt3*r/2, sqrt3*r/2, NaN, sqrt3*d/2, sqrt3*d/2];
ys = [0, r/2, -r/2, NaN, d/2, -d/2];
xs2 = copy(xs)
ys2 = copy(ys)
for θ = 0:60:300 # degree
for i = 1:length(xs)
xs2[i], ys2[i] = xs[i] * cosd(θ) + ys[i] * sind(θ), xs[i] * sind(θ) - ys[i] * cosd(θ)
end
plotline(x .+ xs2, y .+ ys2, lwd=4, col=:cornsilk)
plotline(x .+ xs2[5:6], y .+ ys2[5:6], lwd=6, col=:cornsilk)
cx, cy = (xs2[5] + xs2[6])/2, (ys2[5] + ys2[6])/2
plotarc(x + cx, y + cy, x + xs2[2], y + ys2[2], 0.55r, udrl=udrl1[θ÷60+1], lwd=3, col=:cornsilk)
plotarc(x + cx, y + cy, x + xs2[3], y + ys2[3], 0.55r, udrl=udrl2[θ÷60+1], lwd=3, col=:cornsilk)
end
end
sqrt3 = sqrt(3)
nx += 2
ny += 1
x1, y1, x2, y2 = r * sqrt3, 2r, nx * r * sqrt3, (1.5ny + 3)r
println("(width, height) = ($(x2 - x1), $(y2 - y1))")
plotbegin(w=width, h=height)
plotlimit(x1, y1, x2, y2)
plotbox(x1, y1, x2, y2, col=:gray, fcol=:gray)
for y = 1:ny
for x = 1:nx
unit(x * sqrt3 * r, (2y + (x % 2))r, r, d)
end
end
plotend()
end
(8.660254037844387, 7).*70
kikkou7(4, 3, width=610, height=490)
savefig("fig7.png")