裏 RjpWiki

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

算額(その70)

2022年12月22日 | Julia

算額(その70)

東京都府中市 大國魂神社
http://www2.ttcn.ne.jp/~nagai/sangaku/sangakumondai1.htm

直角三角形 ABC 内に正方形,長方形,等円 2 個がある。
AB が 27 寸,BC が 36 寸のとき,等円の直径を求めよ。

図のように記号を定め,方程式を解く。

eq6 が https://blog.goo.ne.jp/r-de-r/e/b63974576ba4fdb13955aa322b1ad901 で示した,「鉤股弦と内接円の径」に基づくものである。

using SymPy
@syms R::positive, AB::positive, AE::positive, AD::positive, ae::positive, ad::positive, de::positive, ae::positive;

DE = ae
BD = ae
AB = 27
eq1 = AE - 3//5*AD;
eq2 = ae - 3//5*ad;
eq3 = de - 4//5*ad;
eq4 = AE - DE/de*ae;
eq5 = AD + BD - AB;
eq6 = ae + de - ad - R;

solve([eq1, eq2, eq3, eq4, eq5, eq6], (R, ae, de, ad, AE, AD))

   1-element Vector{NTuple{6, Sym}}:
    (8, 12, 16, 20, 9, 15)

等円の径は 8 である。また,正方形の一辺は 12,長方形の長辺は 20,短辺は 4.8 である。

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=:top; mark=true)
  mark && scatter!([x], [y], color=color, markerstrokewidth=0)
  annotate!(x, y, text(string, 10, position, color, vertical))
end;

function distance(x1, y1, x2, y2, x0, y0)
 p1, p2 = sympy.Point(x1, y1), sympy.Point(x2, y2)
 l = sympy.Line(p1, p2)
 l.distance(sympy.Point(x0, y0))
end;

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (R, ae, de, ad, AE, AD) = (8, 12, 16, 20, 9, 15)
   r = R/2
   cosine, sine = (4, 3) ./ 5
   Ax, Ay = (0, 27)
   Bx, By = (0, 0)
   Cx, Cy = (36, 0)
   plot([Ax, Bx, Cx, Ax], [Ay, By, Cy, Ay], lw=0.5, showaxis=false)
   Dx, Dy = (0, 27 - AD)
   Ex, Ey = AE*cosine, AB - AE*sine
   DE = AD*cosine
   ex, ey = (Ex + DE*cosine, Ey - DE*sine)
   ax, ay = (ex - DE*sine, ey - DE*cosine)
   dx, dy = (ex + de*cosine, ey - de*sine)
   plot!([Ex, Dx, ax, ex, Ex], [Ey, Dy, ay, ey, Ey], color=:black, lw=0.5)
   plot!([ax, ax, dx, dx, ax], [ay, 0, 0, ay, ay], color=:black, lw=0.5)
   circle(r, r, r)
   # 右の等円の中心座標 -- 2辺までの距離が等しいとの方程式を解く
   @syms Ox, Oy
   eq1 = distance(ax, ay, ex, ey, Ox, Oy) - r
   eq2 = distance(dx, dy, ex, ey, Ox, Oy) - r
   res = solve([eq1, eq2])[3]
   circle(res[Ox], res[Oy], r)
   if more
       println("正方形の一辺 = $DE")
       println("長方形の辺 = $ad, $dy")
       println("等円の径と中心座標 = $R, $((res[Ox], res[Oy]))")
       point(Ax, Ay, "A ", :black, :right)
       point(Bx, By, "B ", :black, :right)
       point(Cx, Cy, " C", :black)
       point(Dx, Dy, "  D", :black)
       point(Ex, Ey, "  E", :black)
       point(ex, ey, "  e", :black)
       point(ax, ay, " a", :black)
       point(dx, dy, "  d", :black)
       point(r, r, "(r,r)", :red, :center)
       point(res[Ox], res[Oy], "(Ox,Oy)", :red, :center)
       point((Dx + ex)/2, (Dy + ey)/2, "正方形", :center, mark=false)
       point((ax + dx)/2, dy/2, "長方形", :center, mark=false)
       point(r, 1.5r, "等円", :center, mark=false)
       point(res[Ox], 0.5r + res[Oy], "等円", :center, mark=false)
   end
end;

   正方形の一辺 = 12.0
   長方形の辺 = 20, 4.8000000000000025
   等円の径と中心座標 = 8, (17.6000000000000, 8.80000000000000)

 


コメント    この記事についてブログを書く
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« 和算の心(その001) | トップ | 算額(その71) »
最新の画像もっと見る

コメントを投稿

Julia」カテゴリの最新記事