0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

大人用です。四等分円と半円。中学受験2013年灘中(その3/3)「【これぞ図形の最高峰】灘中の算数の難問で頭をフル回転させよう...」様を、円弧と円弧の交点計算を Gemini先生に教えてもらいました。

0
Last updated at Posted at 2026-08-25

(その1/3) の続き。円と円の交点の決め打ち。計算結果を目視でした。
https://qiita.com/mrrclb48z/items/568fb364a9588d2988f1
(その2/3) の続き。円を 円弧風にでした。
https://qiita.com/mrrclb48z/items/b2428c0638c7fe6ec5a5

sympyで

ver4.1

・プログラムで座標をチョイスです。

# ver4.1
from sympy import *
DE,EF=4,6
D,E,F,G=map(Point,[(0,DE),(0,0),(EF,0),(EF,DE)])


# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

# SymPyを用いた2つの円弧の交点計算スクリプト(幾何学的ベクトル代数版)

import sympy as sp


def calculate_arc_intersections(
    Ax1, Ay1, Ax2, Ay2, Ar, Bx1, By1, Bx2, By2, Br
):
    def get_circle_center(x1, y1, x2, y2, r):
        xm = (x1 + x2) / 2
        ym = (y1 + y2) / 2
        dx = x2 - x1
        dy = y2 - y1
        d = sp.sqrt(dx**2 + dy**2)

        r_abs = sp.Abs(r)
        h = sp.sqrt(r_abs**2 - (d / 2) ** 2)

        ux = dx / d
        uy = dy / d

        s = sp.sign(r)
        xc = xm - s * h * uy
        yc = ym + s * h * ux

        return xc, yc

    # 1. 幾何学的に各円弧の円心座標を算出
    xcA, ycA = get_circle_center(Ax1, Ay1, Ax2, Ay2, Ar)
    xcB, ycB = get_circle_center(Bx1, By1, Bx2, By2, Br)

    # 2. 2点間距離 D の計算
    dx = xcB - xcA
    dy = ycB - ycA
    D = sp.sqrt(dx**2 + dy**2)

    # 3. 代数ソルバーを使わず、ベクトル計算で直接交点を解く
    # 中心線上の投影距離 a
    rA_abs = sp.Abs(Ar)
    rB_abs = sp.Abs(Br)
    a = (rA_abs**2 - rB_abs**2 + D**2) / (2 * D)

    # 垂線の足 M(xM, yM)
    xM = xcA + a * (dx / D)
    yM = ycA + a * (dy / D)

    # 垂線の高さ h_int
    h_int = sp.sqrt(rA_abs**2 - a**2)

    # 中心線の法線ベクトル ( -dy/D, dx/D )
    nx = -dy / D
    ny = dx / D

    # 交点1と交点2(一瞬で求まる明確な閉形式)
    x1 = xM + h_int * nx
    y1 = yM + h_int * ny

    x2 = xM - h_int * nx
    y2 = yM - h_int * ny

    return [(x1, y1), (x2, y2)], (xcA, ycA), (xcB, ycB)


# # --- 実行および出力 ---
# Ax1, Ay1, Ax2, Ay2, Ar = sp.symbols("Ax1 Ay1 Ax2 Ay2 Ar", real=True)
# Bx1, By1, Bx2, By2, Br = sp.symbols("Bx1 By1 Bx2 By2 Br", real=True)

# intersections, centerA, centerB = calculate_arc_intersections(
#     Ax1, Ay1, Ax2, Ay2, Ar, Bx1, By1, Bx2, By2, Br
# )

# print("=== 交点1の座標 ===")
# print("x1 =", intersections[0][0])
# print("y1 =", intersections[0][1])

# print("\n=== 交点2の座標 ===")
# print("x2 =", intersections[1][0])
# print("y2 =", intersections[1][1])


# # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
# # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
# # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
J=Point(DE,DE)
intersections, centerA, centerB = calculate_arc_intersections(
    E.x, E.y,F.x,F.y,-Rational(1,2)*EF, \
    E.x, E.y,J.x,J.y,DE
)
# print("#",intersections)

# --- DEFGの内側(0 < x < EF かつ 0 < y < DE)にある点を選択 ---
inside_points = [
    Point(pt[0], pt[1])
    for pt in intersections
    if (0 < pt[0] < EF) and (0 < pt[1] < DE)
]


print("# 内側の点:", inside_points[0])
H=inside_points[0]
print("#",Polygon(E,F,G,H).area)
# 内側の点: Point2D(96/25, 72/25)
# 324/25

ver4.2

・公式?への直接代入の場合。同じだと思うので、省略です。
・お好みで、次次リンクの計算結果の計算式に代入です。?subs デスヨ。ver2.1参照。

ChatGPT先生にver4.1 を丸投げです。PNG図だけ出力して下さい。
省略。忘れていた。

いつもの? sympyの実行環境 と 参考のおすすめです。

sympyのweb上での実行方法

SymPy Live Shellで。
ソースコードの解説は、私よりGemini先生へのソースコードの丸投げがおすすめです。質問の追加はいくらでも。
モーダル対応?「実行して」。「作図して」「問題文章の丸投げ」いい時代です。

(テンプレート)

いつもと違うおすすめです。

Qiita 内

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?