空間図形「21年 宮城大 事業構想・食品業 5」をsympyとFreeCADでやってみた。

空間内の4点....


オリジナル

https://kamelink.com/blog/2022/12/02/6-6-21-miyagidai-jigyokoso-shokuhingyo-5/

https://mathmathmass.exblog.jp/32218175/

上と同じです。大学入試数学問題集成＞【４B】

https://mathexamtest.web.fc2.com/2021/202111081/2021110810100mj.html#top-0109

# sympyで(オリジナルのやり方)
勉強中

# sympyで(det:行列式)
```python
from sympy import *
def myTaisekiGyouretuSiki(PTO,PTA,PTB,PTC):
    return Matrix([[PTA.x-PTO.x, PTA.y-PTO.y, PTA.z-PTO.z], \
                   [PTB.x-PTO.x, PTB.y-PTO.y, PTB.z-PTO.z], \
                   [PTC.x-PTO.x, PTC.y-PTO.y, PTC.z-PTO.z]]).det()/6
def myMensekiVector3D(P,Q):
    return Rational(1,2)*sqrt(P.distance(Point(0,0,0))**2*Q.distance(Point(0,0,0))**2-P.dot(Q)**2)
var('b c')
O=Point3D(0,0, 0)
A=Point3D(1,1, 2)
B=Point3D(1,b,-1)
C=Point3D(0,1, c)
ans=solve(myTaisekiGyouretuSiki(O,A,B,C),c)[0]
print("#(1)",ans)
C=Point3D(0,1, c).subs({c:ans})
ans=solve([Eq((A-O).x,(B-C).x),Eq((A-O).y,(B-C).y),Eq((A-O).z,(B-C).z)],b)[b]
print("#(2)",ans)
B=B.subs({b:ans})
C=C.subs({b:ans})
print("#(3)",myMensekiVector3D(A-O,B-O)*2)
#(1) -3/(b - 1)
#(2) 2
#(3) sqrt(35)
```

on line sympyで、上記のソースコードを貼り付けて実行できました。私の環境は,pycharmです。　

https://live.sympy.org/



# FreeCADのマクロで
マクロからsympyを使っています。
(3)の条件で作図しています。
ねじれていないので、大丈夫だと思います。ねじれの点検が必要ですか？
CADで面積を出せるはずです。（勉強中）

an Isometric view

![png.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/109698/a9a14a0a-4665-8fcc-e75e-2f9d34522542.png)


![png1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/109698/062b47a1-64fb-b0ab-005b-8d5e426767c7.png)

Top(上から見た)

![png2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/109698/9b4926b0-b3d7-9e84-8df4-7fc3acc3c9e6.png)



```python
import FreeCAD
import Part
import Draft
import Mesh
#########################################################################################################
from sympy import *
def myTaisekiGyouretuSiki(PTO,PTA,PTB,PTC):
    return Matrix([[PTA.x-PTO.x, PTA.y-PTO.y, PTA.z-PTO.z], [PTB.x-PTO.x, PTB.y-PTO.y, PTB.z-PTO.z], [PTC.x-PTO.x, PTC.y-PTO.y, PTC.z-PTO.z]]).det()/6
def myMensekiVector3D(P,Q):
    return Rational(1,2)*sqrt(P.distance(Point(0,0,0))**2*Q.distance(Point(0,0,0))**2-P.dot(Q)**2)
var('b c')
O=Point3D(0,0, 0)
A=Point3D(1,1, 2)
B=Point3D(1,b,-1)
C=Point3D(0,1, c)
ans=solve(myTaisekiGyouretuSiki(O,A,B,C),c)[0]
print("#(1)",ans)
C=Point3D(0,1, c).subs({c:ans})
ans=solve([Eq((A-O).x,(B-C).x),Eq((A-O).y,(B-C).y),Eq((A-O).z,(B-C).z)],b)[b]
print("#(2)",ans)
B=B.subs({b:ans})
C=C.subs({b:ans})
print("#(3)",myMensekiVector3D(A-O,B-O)*2)
#(1) -3/(b - 1)
#(2) 2
#(3) sqrt(35)
#########################################################################################################
# 3D作図
def myXYZ2Txt(A):
    return '(' + str(A.x) + ',' + str(A.y) + ',' + str(A.z) + ')'
def myTxtXYZ(A,myWedgei):
    P5x=float(A.x)
    P5y=float(A.y)
    P5z=float(A.z)
    p5 = FreeCAD.Vector(P5x, P5y, P5z)
    myText = Draft.makeText(myWedgei, p5)
    myText.Label = myWedgei
    FreeCADGui.ActiveDocument.ActiveObject.FontSize = '0.2 mm'
def myTxtXYZ_S(*xy_tx):
    for i in range(1,int(len(xy_tx)/2)+1):
        myTxtXYZ(xy_tx[2*i-2],xy_tx[2*i-1]+myXYZ2Txt(xy_tx[2*i-2]) )
def myLine(A,B):
    Ax,Ay,Az=float(A.x),float(A.y),float(A.z)
    Bx,By,Bz=float(B.x),float(B.y),float(B.z)
    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)
def myLine_S(*args):
    for i in range(1,len(args)):
        myLine(args[i-1],args[i])
    return 0
myTxtXYZ_S(O,"O",A,"A",B,"B",C,"C",O,"O")
myLine_S  (O,A,B,C,O)
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")
```

# 参考
(勉強中)

https://www.google.com/search?q=%E5%85%B1%E9%9D%A2%E6%9D%A1%E4%BB%B6&rlz=1C1CHBD_jaJP908JP908&oq=%E5%85%B1%E9%9D%A2%E6%9D%A1%E4%BB%B6&aqs=chrome..69i57j0i512l3.534j0j7&sourceid=chrome&ie=UTF-8

多面体が正の体積を持つならば、その頂点集合は共面でない点を必ず含む。＜

https://ja.wikipedia.org/wiki/%E5%85%B1%E9%9D%A2

https://en.wikipedia.org/wiki/Coplanarity

DeepL翻訳より
コプラナリティー
コプラナリティ（Coplanarity
コプラナリティ（共平面性