Julia で麻の葉格子模様を描く(2)
plotter.jl を include
https://blog.goo.ne.jp/r-de-r/e/bd71a52a09801335d56f7c47d879bfe3
include("plotter.js")
function asanoha4(nx=6, ny=5; r=1, width=600, height=400)
a = r * sqrt(3) / 2
b = r / 2
c = a / 3
d = (a - c) / 2
e = d/sqrt(3)
f = a - d
g = b-e
h = b - 2e
function unit(x, y)
xs = [-a, -a, -c, 0, -a+c, -a, 0, 0, NaN,
a, a, c, 0, a-c, a, 0, 0, NaN,
-a, -a, -c, 0, -a+c, -a, 0, 0, NaN,
a, a, c, 0, a-c, a, 0, 0, NaN,
d, 0, -d, -d, 0, d, d, NaN,
f, f, a, NaN, -f, -f, -a, NaN, f, f, a, NaN, -f, -f, -a]
ys = [0, b, b, 0, 0, b, 0, b, NaN,
0, b, b, 0, 0, b, 0, b, NaN,
0, -b, -b, 0, 0, -b, 0, -b, NaN,
0, -b, -b, 0, 0, -b, 0, -b, NaN,
e, 2e, e, -e, -2e, -e, e, NaN,
b, g, h, NaN, b, g, h, NaN, -b, -g, -h, NaN, -b, -g, -h]
plotline(x .+ xs, y .+ ys, lwd=2, col=:bisque)
plotline(x .+ [-a, a, NaN, -a, a], y .+ [b, -b, NaN, -b, b], lwd=4, col=:bisque)
end
plotbegin(w=width, h=height)
x1, y1, x2, y2 = a, b, 2(nx + 0.5) * a, (2ny + 1) * b
println("(width, height) = ($(x2 - x1), $(y2 - y1))")
plotlimit(x1, y1, x2, y2)
plotbox(x1, y1, x2, y2, col=:gray, fcol=:gray)
for x = 1:nx
for y = 1:ny
unit(2a * x, 2b * y)
end
end
plotend()
end
asanoha4(4, 3, width=693, height=300)
savefig("fig4.png")
※コメント投稿者のブログIDはブログ作成者のみに通知されます