裏 RjpWiki

Julia ときどき R, Python によるコンピュータプログラム,コンピュータ・サイエンス,統計学

算額(その182)

2023年03月30日 | Julia

算額(その182)

中村信弥「改訂増補 長野県の算額」
http://www.wasan.jp/zoho/zoho.html
県内の算額1(82)
長野県長野市篠ノ井 布制神社 文化3年(1806)

外円の中に長さ12寸の弦を引く。弦の上に甲乙丙円を置く。甲円の径が2寸5分のとき,丙円の径はいかほどか。

外円,甲円,乙円,丙円の半径を R, r3 = 25, r2, r1 とする。乙円,丙円の x 座標を x2, x1 とする。

using SymPy
@syms R::positive, x1::positive, r1::positive, x2::positive, r2::positive;

r3 = 25
chord = 120

eq0 = (R - 2r3)^2 + chord^2 - R^2
eq1 = (x2 - x1)^2 + (r2 - r1)^2 - (r1 + r2)^2
eq2 = x2^2 + (r3 - r2)^2 - (r3 + r2)^2
eq3 = x1^2 + (r3 - r1)^2 - (r3 + r1)^2
eq4 = x2^2 + (R - 2r3 + r2)^2 - (R - r2)^2

res = solve([eq0, eq1, eq2, eq3, eq4], (R, r1, r2, x1, x2))

   2-element Vector{NTuple{5, Sym}}:
    (169, 144/25, 3600/169, 24, 600/13)
    (169, 3600, 3600/169, 600, 600/13)

元の単位では丙円の直径は = 144/25 = 5.76000000000000

using Plots

function circle(ox, oy, r, color=:red; beginangle=0, endangle=360, fill=false)
   θ = beginangle:0.1:endangle
   x = r.*cosd.(θ)
   y = r.*sind.(θ)
   if fill
       plot!(ox .+ x, oy .+ y, linecolor=color, linewidth=0.5, seriestype=:shape, fillcolor=color)
   else
       plot!(ox .+ x, oy .+ y, color=color, linewidth=0.25)
   end
end;

function point(x, y, string="", color=:green, position=:left, vertical=:top; mark=true)
   mark && scatter!([x], [y], color=color, markerstrokewidth=0)
   annotate!(x, y, text(string, 10, position, color, vertical))
end;

function segment(x1, y1, x2, y2, color=:black; linestyle=:solid, linewidth=0.5)
   plot!([x1, x2], [y1, y2], color=color, linestyle=linestyle, linewidth=linewidth)
end;

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (R, r1, r2, x1, x2) = res[1]
   println("丙円の半径は = $(r1) = $(r1.evalf())")
   plot()
   circle(0, 0, R, :black)
   circle(0, R - r3, r3)
   circle(x1, R - 2r3 + r1, r1, :blue)
   circle(x2, R - 2r3 + r2, r2, :green)
   circle(-x2, R - 2r3 + r2, r2, :green)
   segment(-120, R - 2r3, 120, R - 2r3)
   if more == true
       point(0, R, "R ", :green, :right)
       point(0, R - r3, "R-r3 ", :green, :right)
       point(0, R - 2r3, "R-2r3 ", :green, :right)
       point(x1, R - 2r3, "x1") 
       point(x2, R - 2r3, "x2")
       point(7, R - r3, "甲", :red, mark=false)
       point(x1, R - 2r3, "丙 ", :red, :right, :top, mark=false)
       point(x2, R - 2r3 + r2, "乙", :red, mark=false)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
      plot!(showaxis=false, xlims=(-30, 125), ylims=(114, 174))
   end
end;

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

PVアクセスランキング にほんブログ村

PVアクセスランキング にほんブログ村