1/4円の中に直角三角形「高校入試チャレンジ問題　EBの長さは？」をsympyとFreeCADでやってみたい。

・？？？**点Eが、辺AB上**。BC上でない。
　YouTubeのコメント様 より
　＞半円を描いて、考えました。
　の、考え方でいいでしょうか？
・扇形の作図は、初めてだと思います。

# オリジナル
・YUUU0123 様 (0:00〜4:49) 

https://youtu.be/Jc_aKmKcF9k

# sympyで　
**ver0.1 直線と直線の交点計算。**
```python
# ver0.1 直線と直線の交点計算。 
from sympy import *
r=2
A,B,C,D=map(Point,[(0,r),(0,0),(r,0),(r*cos(rad(45)),r*sin(rad(45)))])
E=Line(D,D+(D-C).rotate(pi/2)).intersection(Line(A,B))[0]
print("#",E.y)
# -2 + 2*sqrt(2)
```
**ver0.2 変数で。直線と直線の交点計算。**
```python
# ver0.2 変数で。直線と直線の交点計算。 
from sympy import *
# r=2
var('r',real=True,poitive=True)
A,B,C,D=map(Point,[(0,r),(0,0),(r,0),(r*cos(rad(45)),r*sin(rad(45)))])
E=Line(D,D+(D-C).rotate(pi/2)).intersection(Line(A,B))[0]
print("#",E.y)
print("#",E.y.subs({r:2}))
# r*(-1 + sqrt(2))
# -2 + 2*sqrt(2)
```

# FreeCADのマクロで作図
```python
import FreeCAD
import Part
import DraftTools
import Draft
import Mesh
############################################################################
from sympy import *
r=2
A,B,C,D=map(Point,[(0,r),(0,0),(r,0),(r*cos(rad(45)),r*sin(rad(45)))])
E=Line(D,D+(D-C).rotate(pi/2)).intersection(Line(A,B))[0]
print("#",E.y)
# -2 + 2*sqrt(2)
############################################################################
# 3D作図 z=0 XY平面に作図しました。
############################################################################
# 円の作図　FrecCADのdocより
# https://wiki.freecad.org/Macro_Circle
def Freecad3D_circle(x=0.0,y=0.0,z=0.0,radius=0.0,diameter=0.0,circumference=0.0,area=0.0,startangle=0.0,endangle=0.0,arc=0.0,anglecenter=0.0,cord=0.0,arrow=0.0,center=0,placemObject=""):
    from math import sqrt, pi
    if placemObject == "":
        pl = FreeCAD.Placement()
        pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()   
        pl.Base = FreeCAD.Vector(x,y,z)
    else:
        pl = FreeCAD.Placement()
        pl = placemObject                                  # placement imposted
    if diameter != 0:                                      # with diameter
        radius = diameter / 2.0
    elif circumference != 0:                               # with circumference
        radius = (circumference / pi) / 2.0
    elif area != 0:                                        # with area
        radius =  sqrt((area / pi))
    elif (cord != 0) and (arrow != 0):                     # with cord and arrow
        radius = ((arrow**2) + (cord**2) / 4.0) / (arrow*2) 
    elif (arc != 0) and (anglecenter != 0):                # with arc and anglecenter central in degrees
        radius = ((360/anglecenter)*arc) / pi/2.0
        if endangle != 0:
            startangle  = endangle - anglecenter
        endangle   = anglecenter + startangle
        startangle  = endangle - anglecenter
    if radius != 0:
        try:
            Draft.makeCircle(radius,placement=pl,face=False,startangle=startangle,endangle=endangle,support=None)
            if center != 0:
                x=pl.Base.x
                y=pl.Base.y
                z=pl.Base.z
                Draft.makePoint(x,y,z)
        except Exception:
            App.Console.PrintError("Unexpected keyword argument" + "\n")
        App.ActiveDocument.recompute()
    else:
        App.Console.PrintMessage("Unexpected keyword argument" + "\n")
        App.Console.PrintMessage("circle(x,y,z,radius,diameter,circumference,area,startangle,endangle,[arc,anglecenter],[cord,arrow],center,placemObject)" + "\n")
        App.Console.PrintMessage("circle(radius=10.0,placemObject=App.Placement(App.Vector(11,20,30), App.Rotation(30,40,0), App.Vector(0,0,0)))" + "\n")
    return
def myCircle_2D(myCi):
    x=myCi.center.x
    y=myCi.center.y
    r=myCi.radius
    Freecad3D_circle(
           x=float(x),y=float(y),z=0.0,
           radius=float(abs(r)),
           center=1,
           placemObject=App.Placement(App.Vector(float(x),float(y),0),
           App.Rotation(0,0,0),App.Vector(0,0,0)))
    return
def myCircle_Ogigata_2D(myCi,myStAngle,myEndAngle):
    x=myCi.center.x
    y=myCi.center.y
    r=myCi.radius
    Freecad3D_circle(
           x=float(x),y=float(y),z=0.0,
           radius=float(abs(r)),
           startangle=myStAngle,
           endangle=myEndAngle,
           center=1,
           placemObject=App.Placement(App.Vector(float(x),float(y),0),
           App.Rotation(0,0,0),App.Vector(0,0,0)))
    myLine_S_2D(Point(x,y),Point(x+r*cos(rad(myStAngle)), y+r*sin(rad(myStAngle))))
    myLine_S_2D(Point(x,y),Point(x+r*cos(rad(myEndAngle)), y+r*sin(rad(myEndAngle))))
    return
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.2 mm'
    # FreeCADGui.ActiveDocument.ActiveObject.FontSize = '0.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_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
##################################################################################
myCircle_Ogigata_2D(Circle(B,r),0,90)
myLine_S_2D      (C,D,E)  
myTxtXYZ_S_2D(A,"A",B,"B",C,"C",D,"D")
# myTxtXYZ_S_2D(E,"E")
####################################################################################
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方向?です。(省略)

拡大図
![2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/109698/a0e8f9ea-8ba9-73de-639a-8ef1701b45d5.png)


拡大図(CADの操作で寸法線を追加)
・(青色の)角度寸法は、ニセモノです。Part＞計測＞角度計算 です。
・角度寸法の表示は、まだ勉強中です。

![3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/109698/71e6fc3e-bd6d-fcf4-6839-ab850c72c08e.png)

# sympyで(オリジナル 様の方法を参考に)
```python
from sympy import *
print("#",sqrt(2)-(2-sqrt(2)))
# -2 + 2*sqrt(2)
```
# いつもの? sympyの実行環境と 参考のおすすめです。
[(テンプレート)](https://qiita.com/mrrclb48z/items/00dd08b0317069be9342)

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

https://qiita.com/mrrclb48z/items/555d85face87552c34fb

https://qiita.com/mrrclb48z/items/5f57eac92aaca30e85c0


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