裏 RjpWiki

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

算額(その220)

2023年05月02日 | Julia

算額(その220)

中村信弥「改訂増補 長野県の算額
http://www.wasan.jp/zoho/zoho.html
県内の算額2(183)
長野県下高井郡木島平村西小路 満昌院 嘉永5年(1852)

七四 加須市大字外野 棘脱地蔵堂 明治7年(1874)
埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.

栃木県足利市家富町 鑁阿寺 明治17年(1884)3月
http://www.wasan.jp/totigi/bannaji2.html
(求めるものが異なる)

甲円と乙円 2 個ずつに外接する丙円がある。甲円と乙円の径が与えられたとき,丙円の径を求めよ。

図のように記号を定め,方程式を解き r3 を求める。
甲円の中心座標,半径を (r3 + r1, 0), r1
乙円の中心座標,半径を (0, r3 + r2), r2
丙円の中心座標,半径を (0, 0), r3

using SymPy

@syms r1::positive, r2::positive, r3::positive

eq = (r3 + r1)^2 + (r3 + r2)^2 - (r1 + r2)^2  # 甲円と乙円が外接する
res = solve(eq, r3)[1]
res |> println

   -r1/2 - r2/2 + sqrt(r1^2 + 6*r1*r2 + r2^2)/2

r1, r2 を与え r3 を得る関数

f(r1, r2) = (sqrt(r1^2 + 6*r1*r2 + r2^2) - r1 - r2)/2
f(3, 2) |> println
f(3.7, 1.2) |> println

   1.0
   0.781485726411305

using Plots
using Printf

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.5)
   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 draw(r1, r2, more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r3 = (sqrt(r1^2 + 6*r1*r2 + r2^2) - r1 - r2)/2
   @printf("甲円の半径 = %.3f,  乙円の半径 = %.3f;  丙円の半径 = %.3f\n", r1, r2, r3)
   plot()
   circle(0, 0, r3, :blue)
   circle(r3 + r1, 0, r1, :magenta)
   circle(-r3 - r1, 0, r1, :magenta)
   circle(0, r3 + r2, r2)
   circle(0, -r3 - r2, r2)

   if more == true
       point(0, 0, "  丙円(0,0,r3)", :blue)
       point(r3 + r1, 0, " 甲円(r3+r1,r1)", :magenta)
       point(0, r3+r2, " 乙円(0,r3+r2,r2)", :red)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

draw(3, 2, true)

   甲円の半径 = 3.000,  乙円の半径 = 2.000;  丙円の半径 = 1.000

draw(3.7, 1.2, false)

   甲円の半径 = 3.700,  乙円の半径 = 1.200;  丙円の半径 = 0.781

 

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

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

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