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.

正六角形の面積は?「【難問?!】図形問題が衝撃すぎたwww【別解数学#10】」をsympyとFreeCADでやってみたい。

Last updated at Posted at 2023-06-27

解答について教えて下さい。正六角形は1種類で、長方形は2種類ですか?
裏向き裏向き?
CADで、どなたか確認できますか?(私は、CAD勉強中。相似も。)
解答探しています。
問題文は2次元ですが、3次元FreeCADのマクロで、XY平面上に作図しました。

オリジナル(youtube)

sympyで計算だけ(PASSLABO様のやり方)

2通りで解ける?そうです。
相似の勉強中。

sympyで計算だけ(sympy的?安易なやり方)

θの答えが2つ。64.7...°と85.2...°です。
勇者が、距離r直進して、60°右に曲がるです。 -(pi-2/3*pi)
出発点Hで、西に向かって、(180-120-θ)°右に曲がるです。
(>平行条件の3でもいいような気もしました。
「同位角(英:Corresponding angles)」
https://ja.wikipedia.org/wiki/%E5%B9%B3%E8%A1%8C#%E5%B9%B3%E9%9D%A2%E5%B9%BE%E4%BD%95 )

from  sympy import *
r=symbols('r',real=True,positive=True)
θ=symbols('θ',real=True,positive=True)
def rokukakukei(r_ans,θ_ans):
    print("#",r_ans,θ_ans,float(r_ans),float(θ_ans*180/pi))
    print("#",herons(r_ans,r_ans,r_ans)*6)
    return
def herons(a,b,c):
    s=(a+b+c)/2
    return sqrt(s*(s-a)*(s-b)*(s-c))
H=  Point( 0,0 )
G=H+Point( r*cos( (pi-(θ+2/3*pi))                         ),r*sin(  (pi-(θ+2/3*pi))                         ))
F=G+Point( r*cos( (pi-(θ+2/3*pi))-(pi-2/3*pi)             ),r*sin(  (pi-(θ+2/3*pi))-(pi-2/3*pi)             ))
E=F+Point( r*cos( (pi-(θ+2/3*pi))-(pi-2/3*pi)-(pi-2/3*pi) ),r*sin(  (pi-(θ+2/3*pi))-(pi-2/3*pi)-(pi-2/3*pi) ))
A=  Point(F.x,E.y)
B=  Point(F.x,0  )
ans=solve([Eq(Polygon(H,G,F,B).area,23),Eq(Polygon(F,E,A).area,20)],[r,θ])
rokukakukei(ans[0][0],ans[0][1])
print()
rokukakukei(ans[1][0],ans[1][1])
# 2*3**(3/4)*sqrt(37)/3 -pi/12 + acos(-20*sqrt(3)/37)/2 9.243800075729927 64.71500395394821
# 222

# 2*3**(3/4)*sqrt(37)/3 -acos(-20*sqrt(3)/37)/2 + 11*pi/12 9.243800075729927 85.28499604605179
# 222

①私の環境は,pycharmです。
②よく聞くのは、Jupyterです。
③web上で、上記のソースを「SymPy Live shell」に、コピー貼り付けでもできました。
黒背景の右上に、マウスを移動すると、コピーマークが発生します。
??? タブレット環境で、コピー貼り付けが実行できませんでした。???
計算時間は、2分以上かかると思います。

FreeCADのマクロで作図

import FreeCAD
import Part
import DraftTools
import Draft
import Mesh
############################################################################
# 計算
from  sympy import *
r=symbols('r',real=True,positive=True)
θ=symbols('θ',real=True,positive=True)
def rokukakukei(r_ans,θ_ans):
    print("#",r_ans,θ_ans,float(r_ans),float(θ_ans*180/pi))
    print("#",herons(r_ans,r_ans,r_ans)*6)
    return
def herons(a,b,c):
    s=(a+b+c)/2
    return sqrt(s*(s-a)*(s-b)*(s-c))
H=  Point(0,0)
G=H+Point(r*cos (pi-θ)                         ,r*sin (pi-θ)                         )
F=G+Point(r*cos((pi-θ)-(pi-2/3*pi))            ,r*sin((pi-θ)-(pi-2/3*pi))            )
E=F+Point(r*cos((pi-θ)-(pi-2/3*pi)-(pi-2/3*pi)),r*sin((pi-θ)-(pi-2/3*pi)-(pi-2/3*pi)))
A=  Point(F.x,E.y)
B=  Point(F.x,0  )
ans=solve([Eq(Polygon(H,G,F,B).area,23),Eq(Polygon(F,E,A).area,20)],[r,θ])
rokukakukei(ans[0][0],ans[0][1])
print()
rokukakukei(ans[1][0],ans[1][1])
############################################################################
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 = '1.5 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_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 sakuzu(H,G,F,E, B,A,r_ans,θ_ans,dx,dy):
    mySubs={r:r_ans,θ:θ_ans}
    H=Point(H.x+dx,H.y+dy)
    H=  H.subs(mySubs)
    G=H+G.subs(mySubs)
    F=H+F.subs(mySubs)
    E=H+E.subs(mySubs)
    B=H+B.subs(mySubs)
    A=H+A.subs(mySubs)
    II=H+(E-F)
    J=II+(F-G)
    C=Point(II.x,0.0)
    D=Point(II.x,A.y)
    #
    myLine_C_2D  (A,B,C,D)
    myLine_C_2D  (H,G,F,E,J,II)
    myTxtXYZ_S_2D(A,"A",B,"B",C,"C",D,"D")
    myTxtXYZ_S_2D(H,"H",G,"G",F,"F",E,"E",J,"J",II,"I")
    return 
sakuzu( H,G,F,E, B,A,ans[0][0],ans[0][1], 0.0,0.0 )
# sakuzu( H,G,F,E, B,A,ans[1][0],ans[1][1],25.0,0.0 )
sakuzu( H,G,F,E, B,A,ans[1][0],ans[1][1], 0.0,0.0 )
#############################################################
doc = App.activeDocument()
App.ActiveDocument.addObject("App::Origin", "Origin")
App.ActiveDocument.getObject('Origin').Visibility = True
App.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewAxonometric()
Gui.SendMsgToActiveView("ViewFit")

0png.png

CADで、どなたか確認できますか?

1png.png

点Hで重ねてみました。CADの着色を勉強中。

2png.png

参考

私のおすすめです。

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?