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?

More than 1 year has passed since last update.

正三角形の3頂点の距離から角度「超有名な幾何学問題 ∠BDC=?」をsympyとFreeCADでやってみたい。

Last updated at Posted at 2024-07-19

・図を正確に?FreeCADで書きました。

オリジナル

・YUUU0123 様 (0:00〜3:42)

sympyで

ver0.1  点Bの円と点Cの円の 交点Dと点Aの距離が5の方程式をsolveで
https://docs.sympy.org/latest/modules/solvers/solvers.html
・d=を忘れていたので,repで対応。

# ver0.1
from sympy import *
var('d',real=True,poitive=True)
BD,CD,AD=4,3,5
A,B,C=map(Point,[(d/2,d/2*sqrt(3)),(0,0),(d,0)])
D=Circle(B,BD).intersection(Circle(C,CD))[1]
rep={d:solve(Eq(A.distance(D),AD),d)[1]}
A,C,D=A.subs(rep),C.subs(rep),D.subs(rep)
print("#",deg(Triangle(B,D,C).angles[D].simplify()))
# 150
print("#",d.subs(rep),float(d.subs(rep)))
# sqrt(12*sqrt(3) + 25) 6.766432567522307

FreeCADのマクロで作図

・計算部分は、Ver.0.1 の コピー貼り付けです。

import FreeCAD
import Part
import DraftTools
import Draft
import Mesh
############################################################################
# ver0.1
from sympy import *
var('d',real=True,poitive=True)
BD,CD,AD=4,3,5
A,B,C=map(Point,[(d/2,d/2*sqrt(3)),(0,0),(d,0)])
D=Circle(B,BD).intersection(Circle(C,CD))[1]
rep={d:solve(Eq(A.distance(D),AD),d)[1]}
A,C,D=A.subs(rep),C.subs(rep),D.subs(rep)
print("#",deg(Triangle(B,D,C).angles[D].simplify()))
# 150
print("#",d.subs(rep),float(d.subs(rep)))
# 150
# sqrt(12*sqrt(3) + 25) 6.766432567522307
############################################################################
# 3D作図 z=0 XY平面に作図しました。
############################################################################
def myXYZ2Txt_2D(A):
    #return '(' + str(A.x) + ',' + str(A.y) +  ')'
    return ""
def myTxtXYZ_2D(A,myWedgei):
    P5x=float(A.x)
    P5y=float(A.y)
    P5z=0.0
    p5 = FreeCAD.Vector(P5x, P5y, P5z)
    myText = Draft.makeText(myWedgei, p5)
    myText.Label = myWedgei
    FreeCADGui.ActiveDocument.ActiveObject.FontSize = '0.5 mm'
    #FreeCADGui.ActiveDocument.ActiveObject.FontSize = '1.0 mm'
    return
def myTxtXYZ_S_2D(*xy_tx):
    for i in range(1,int(len(xy_tx)/2)+1):
        myTxtXYZ_2D(xy_tx[2*i-2],xy_tx[2*i-1]+myXYZ2Txt_2D(xy_tx[2*i-2]) )
    return
def myLine_2D(A,B):
    Ax,Ay,Az=float(A.x),float(A.y),0.0
    Bx,By,Bz=float(B.x),float(B.y),0.0
    pl = FreeCAD.Placement()
    pl.Rotation.Q = (0.4247081540122249, 0.17592004639554645, 0.33985110062924484, 0.8204732460821097)
    pl.Base = FreeCAD.Vector(-3.9166066876399563, -2.1670824762243774, 1.7495260956243028)
    points = [FreeCAD.Vector(Ax,Ay,Az), FreeCAD.Vector(Bx,By,Bz)]
    line = Draft.make_wire(points, placement=pl, closed=False, face=True, support=None)
    Draft.autogroup(line)
    return
def myLine_S_2D(*args):
    for i in range(1,len(args)):
        myLine_2D(args[i-1],args[i])
    return
def myLine_C_2D(*args):
    for i in range(1,len(args)):
        myLine_2D(args[i-1],args[i])
    myLine_2D(args[i],args[0])
    return
def myLine_H_2D(*args):
    for i in range(1,len(args)):
        myLine_2D(args[0],args[i])
    return
#######################################################################################
myLine_C_2D      (A,B,C)  
myLine_H_2D      (D,A,B,C)
myTxtXYZ_S_2D(A,"A",B,"B",C,"C",D,"D")
####################################################################################
doc = App.activeDocument()
App.ActiveDocument.addObject("App::Origin", "Origin")
# App.ActiveDocumen!t.getObject('Origin').Visibility = True
App.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewAxonometric()
Gui.SendMsgToActiveView("ViewFit")

isometric方向?です。

1.png

拡大図

2.png

拡大図(CADの操作で寸法線を追加)
・(青色の)角度寸法は、ニセモノです。Part>計測>角度計算 です。
・角度寸法の表示は、まだ勉強中です。
・正三角形の辺の長さ sqrt(12*sqrt(3) + 25) 6.766432567522307
3.png

sympyで(オリジナル 様の方法を参考に)

・プログラムでありません。
・私はわかっていないので、メチャクチャです。

# プログラムでありません。
from sympy import *
var('maru,peke',real=True,poitive=True)
BD,CD,AD=4,3,5
EB=4
AE=3
maruPpeke=60
ED=4
trAED=Triangle(sss=(3,4,5))
degAED=90
degBEA=150
degBDC=150

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

(テンプレート)

・以下ができたら、助かります。指定と全部です

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

・sympyのsubs
Substitution

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?