・以下を、BCを水平で解いて下さい。作図をお願いします。
・mathjax をChatGPT先生へ、丸投げです。
・(2025-11-06追加)FreeCADのマクロを教えて下さい。
・(2025-11-06追加)その3/3
(本日の)ChatGPT先生へ
質問
以下を、BCを水平で解いて下さい。作図をお願いします。
(mathjaxを省略)
回答
import math
import matplotlib.pyplot as plt
from math import sqrt
# 点の定義
B = (0.0, 0.0)
C = (7.0, 0.0)
A = (44.0/7.0, 20.0*math.sqrt(3)/7.0)
D = (55.0/14.0, 25.0*math.sqrt(3)/14.0)
E = (47.0/7.0, 8.0*math.sqrt(3)/7.0)
# 交点 P (計算済の値を使う)
P = (8225.0/1519.0, (1400.0*math.sqrt(3))/1519.0)
F = (5.0, 0.0)
# 描画
fig, ax = plt.subplots(figsize=(6,6))
# 三角形 ABC
ax.plot([A[0],B[0],C[0],A[0]],[A[1],B[1],C[1],A[1]],'-')
# 線分 BE, CD, AP
ax.plot([B[0],E[0]],[B[1],E[1]],'--')
ax.plot([C[0],D[0]],[C[1],D[1]],'--')
ax.plot([A[0],P[0],F[0]],[A[1],P[1],F[1]],':')
# 点のプロットとラベル
points = {'A':A,'B':B,'C':C,'D':D,'E':E,'P':P,'F':F}
for name,(x,y) in points.items():
ax.scatter(x,y)
ax.text(x+0.08,y+0.08,name)
ax.set_aspect('equal', adjustable='box')
ax.axhline(0,color='gray',linewidth=0.5)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_title('Triangle ABC with D on AB (AD=3), E on CA (CE=2), P=BE∩CD, F=AP∩BC')
plt.grid(True)
plt.savefig('triangle_DEF.png', dpi=200)
plt.show()
最終解答(要約)をコピーできるテキスト形式で。
最終解答(要約)
問題1:
AP : PF = 21 : 10
問題2:
[△DEF] = 15√3 / 7 (およそ 3.712)
(本日の)ChatGPT先生へ。FreeCADのマクロを教えて下さい。
質問
以下を、BCを水平で解いて下さい。FreeCADのマクロを教えて下さい。
(mathjaxを省略)
回答
# FreeCAD macro: Draw triangle ABC with BC horizontal, construct points D (on AB, AD=3) and E (on CA, CE=2),
# find intersection P of BE and CD, extend AP to meet BC at F, compute AP:PF and area of triangle DEF.
# How to run: Paste into FreeCAD Macro editor and run, or save as .FCMacro and run.
import FreeCAD, FreeCADGui
import Draft
import Part
import math
DOC_NAME = 'Triangle_DEF_Doc'
if FreeCAD.ActiveDocument is None or FreeCAD.ActiveDocument.Name != DOC_NAME:
try:
FreeCAD.closeDocument(DOC_NAME)
except Exception:
pass
doc = FreeCAD.newDocument(DOC_NAME)
else:
doc = FreeCAD.ActiveDocument
# Coordinates (BC horizontal):
B = FreeCAD.Vector(0.0, 0.0, 0.0)
C = FreeCAD.Vector(7.0, 0.0, 0.0) # BC = 7 from law of cosines
Ax = 44.0/7.0
Ay = 20.0 * math.sqrt(3.0) / 7.0
A = FreeCAD.Vector(Ax, Ay, 0.0)
# Helper: linear interpolation
def lerp(P, Q, t):
return FreeCAD.Vector(P.x + t*(Q.x - P.x), P.y + t*(Q.y - P.y), 0.0)
# D on AB with AD = 3 (AB = 8) -> fraction from A toward B is 3/8
D = lerp(A, B, 3.0/8.0)
# E on CA with CE = 2 (CA = 5) -> fraction from C toward A is 2/5
E = lerp(C, A, 2.0/5.0)
# 2D line intersection (p1->p2) with (q1->q2)
def line_intersection(p1, p2, q1, q2):
# Solve p1 + s*(p2-p1) = q1 + t*(q2-q1)
dx1 = p2.x - p1.x
dy1 = p2.y - p1.y
dx2 = q2.x - q1.x
dy2 = q2.y - q1.y
denom = dx1*dy2 - dy1*dx2
if abs(denom) < 1e-12:
return None
s = ((q1.x - p1.x)*dy2 - (q1.y - p1.y)*dx2) / denom
return FreeCAD.Vector(p1.x + s*dx1, p1.y + s*dy1, 0.0)
P = line_intersection(B, E, C, D)
# Intersection F of line AP with BC (y=0) -> param t solving Ay + t*(Py-Ay) = 0
if P is None:
FreeCAD.Console.PrintError('Lines BE and CD are parallel (no intersection)\n')
else:
t = -A.y / (P.y - A.y)
F = FreeCAD.Vector(A.x + t*(P.x - A.x), 0.0, 0.0)
# create geometry: triangle edges and lines
objs = []
objs.append(Draft.makeLine(A, B))
objs.append(Draft.makeLine(B, C))
objs.append(Draft.makeLine(C, A))
objs.append(Draft.makeLine(B, E))
objs.append(Draft.makeLine(C, D))
objs.append(Draft.makeLine(A, P))
# markers for points
for name, pt in [('A', A), ('B', B), ('C', C), ('D', D), ('E', E), ('P', P), ('F', F)]:
s = Part.makeSphere(0.05, pt)
part = doc.addObject('Part::Feature', 'pt_' + name)
part.Shape = s
txt = Draft.makeText([name], point=FreeCAD.Vector(pt.x + 0.08, pt.y + 0.08, 0))
objs.append(part)
objs.append(txt)
doc.recompute()
# compute distances
def dist(P, Q):
return math.hypot(P.x - Q.x, P.y - Q.y)
AP = dist(A, P)
PF = dist(P, F)
ratio = AP / PF if PF != 0 else None
# area of triangle DEF using shoelace
def triangle_area(p, q, r):
return abs((p.x*(q.y-r.y) + q.x*(r.y-p.y) + r.x*(p.y-q.y)) / 2.0)
area_DEF = triangle_area(D, E, F)
FreeCAD.Console.PrintMessage('Coordinates:\n')
FreeCAD.Console.PrintMessage(f'A = ({A.x:.6f}, {A.y:.6f})\n')
FreeCAD.Console.PrintMessage(f'B = ({B.x:.6f}, {B.y:.6f})\n')
FreeCAD.Console.PrintMessage(f'C = ({C.x:.6f}, {C.y:.6f})\n')
FreeCAD.Console.PrintMessage(f'D = ({D.x:.6f}, {D.y:.6f})\n')
FreeCAD.Console.PrintMessage(f'E = ({E.x:.6f}, {E.y:.6f})\n')
FreeCAD.Console.PrintMessage(f'P = ({P.x:.6f}, {P.y:.6f})\n')
FreeCAD.Console.PrintMessage(f'F = ({F.x:.6f}, {F.y:.6f})\n')
FreeCAD.Console.PrintMessage('\nResults:\n')
if ratio is not None:
FreeCAD.Console.PrintMessage(f'AP:PF = {ratio:.6f} -> exact 21:10\n')
FreeCAD.Console.PrintMessage(f'Area(DEF) = {area_DEF:.12f} -> exact 15*sqrt(3)/7 (~{(15*math.sqrt(3)/7):.12f})\n')
# fit view
try:
FreeCADGui.SendMsgToActiveView('ViewFit')
except Exception:
pass
Gemini先生へ
copilot先生へ
いつもの? sympyの実行環境と 参考のおすすめです。

