算額(その12)
山形県山形市山寺 立石寺(山寺)根本中堂 大正3年
http://www.wasan.jp/yamagata/yamadera.html
下図のように,正方形の中に四分円,大小の円がある。円の半径を求めよ。
これも,ちょっと面倒であるが紙と鉛筆で計算できる。
正方形の一辺の長さを 1,大円,小円の半径と中心座標を r1, (r1, y1), r2, (x2, y2) とする。
using SymPy
@syms r1::positive, r2::positive, y1::positive, x2::positive, y2::positive
eq1 = r1^2 + y1^2 - (1 - r1)^2;
eq2 = (1//2)^2 + (1 - r2)^2 - (1 + r2)^2;
eq3 = (1 - r1)^2 + y1^2 - (1 + r1)^2;
solve([eq1, eq2, eq3], (r1, r2, y1))
1-element Vector{Tuple{Sym, Sym, Sym}}:
(1/6, 1/16, sqrt(6)/3)
using Plots
function circle(ox, oy, r, color=:red; beginangle=0, endangle=360)
θ = beginangle:0.1:endangle
x = r.*cosd.(θ)
y = r.*sind.(θ)
plot!(ox .+ x, oy .+ y, color=color, linewidth=0.5)
end;
function point(x, y, string="", color=:green, position=:left, vertical=:center)
scatter!([x], [y], color=color, markerstrokewidth=0)
annotate!(x, y, text(string, 10, position, color))
end;
function draw(more=false)
pyplot(size=(500, 500), aspectratio=1, label="", fontfamily="IPAMincho")
(r1, r2, y1) = (1//6, 1//16, sqrt(6)/3)
println("r1 = $r1, r2 = $r2, y1 = $y1")
plot()
if more
point(r1, y1, " (r1, y1)", :blue)
point(1/2, 1 - r2, " (1/2, 1 - r2)", :blue)
end
circle(1, 0, 1, beginangle=90, endangle=180)
plot!([0, 1, 1, 0, 0], [0, 0, 1, 1, 0], color=:red, linewidth=0.5,
xlims=(-0.05, 1.05), ylims=(-0.05, 1.05))
circle(r1, y1, r1, :blue)
circle(1/2, 1 - r2, r2, :blue)
circle(0, 0, 1, beginangle=0, endangle=90)
end;