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?

ChatGPT先生へ「sympy で、トレミーの定理のユーザー定義関数を教えて下さい。」

Last updated at Posted at 2025-12-22

オリジナル

ver0.5
・(Youtubeのコメント様より)>トレミーの定理より、...

(本日の)ChatGPT先生へ

sympy で、トレミーの定理のユーザー定義関数を教えて下さい。

(回答抜粋)

2️⃣ 基本形:Point を渡すユーザー定義関数

・✔ 定理の等式を返す関数

from sympy import *
from sympy.geometry import Point

def ptolemy_expression(A, B, C, D):
    """
    Ptolemy の定理の左辺−右辺を返す
    = 0 なら定理成立
    """
    AB = A.distance(B)
    BC = B.distance(C)
    CD = C.distance(D)
    DA = D.distance(A)
    AC = A.distance(C)
    BD = B.distance(D)

    return simplify(AC*BD - (AB*CD + BC*DA))

3️⃣ 判定用関数(True / False)

def is_ptolemy(A, B, C, D):
    """
    トレミーの定理が成立するか判定
    """
    expr = ptolemy_expression(A, B, C, D)
    return simplify(expr) == 0

4️⃣ 使用例(象徴計算)

A = Point(1,0)
B = Point(0,1)
C = Point(-1,0)
D = Point(0,-1)

print(ptolemy_expression(A,B,C,D))
print(is_ptolemy(A,B,C,D))
0
True

...
もし次に
・複素数平面版
・SymPy の Circle と連動
・証明用(expand / factor 付き)
・FreeCAD 用マクロ連携
をやりたければ、どれを出すか教えて下さい。...

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

wikipedia

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?