(四面体の体積)「2021 奈良女子大学 数学 問題Ⅱ」をsympyでやってみた。(その2)sympy3Dで

つづき

https://qiita.com/mrrclb48z/items/2008c816520c61253fd4

#Pycharmで
(4)P,Q,G2,G3の正方形でしょうか？同一平面上の証明が必要ですね。

```python
from sympy import *
var('d11')
def myTaiseki(PTO,PTA,PTB,PTC):
    return abs(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)
PB=Point3D(0                ,0                        ,0)
PC=Point3D(d11              ,0                        ,0)
PD=Point3D(d11*Rational(1,2),d11*Rational(1,2)*sqrt(3),0)
dm=Point3D(PD.x             ,PD.y*Rational(1,3)       ,0)
PA=Point3D(dm.x             ,dm.y                     ,sqrt(d11**2-(dm.x**2+dm.y**2)))
PP=PA+(PB-PA)/3
PQ=PA+(PC-PA)/3
PR=PA+(PD-PA)/3
G1=(PA+PB+PC)/3
G2=(PA+PC+PD)/3
G3=(PA+PD+PB)/3
G4=(PB+PC+PD)/3
mySubs={d11:1}
print("#(1)体積-1,2",myTaiseki(PA,PB,PC,PD),myTaiseki(PA,PP,PQ,PR))
print("#(2)正四面体 ",G1.distance(G2),G1.distance(G3),G1.distance(G4))
print("#(2)正四面体 ",G2.distance(G3),G3.distance(G4),G4.distance(G2))
print("#(3)体積-重心",myTaiseki(G1,G2,G3,G4))
print("#(4)体積-八面",PP.distance(PQ),PQ.distance(G2),G2.distance(G3),G3.distance(PP))
print("#(4)体積-八面",myTaiseki(PP,PQ,G2,PR)+myTaiseki(PP,G2,G3,PR)+myTaiseki(PP,PQ,G2,G1)+myTaiseki(PP,G2,G3,G1))
print("")
print("#(1)体積-1,2",myTaiseki(PA,PB,PC,PD).subs(mySubs),myTaiseki(PA,PP,PQ,PR).subs(mySubs))
print("#(2)正四面体 ",G1.distance(G2).subs(mySubs),G1.distance(G3).subs(mySubs),G1.distance(G4).subs(mySubs))
print("#(2)正四面体 ",G2.distance(G3).subs(mySubs),G3.distance(G4).subs(mySubs),G4.distance(G2).subs(mySubs))
print("#(3)体積-重心",myTaiseki(G1,G2,G3,G4).subs(mySubs))
print("#(4)体積-八面",PP.distance(PQ).subs(mySubs),PQ.distance(G2).subs(mySubs),G2.distance(G3).subs(mySubs),G3.distance(PP).subs(mySubs))
print("#(4)体積-八面",(myTaiseki(PP,PQ,G2,PR)+myTaiseki(PP,G2,G3,PR)+myTaiseki(PP,PQ,G2,G1)+myTaiseki(PP,G2,G3,G1)).subs(mySubs))
print("")
print("#(1)体積-1,2",float(myTaiseki(PA,PB,PC,PD).subs(mySubs)),
                    float(myTaiseki(PA,PP,PQ,PR).subs(mySubs)))
print("#(2)正四面体 ",float(G1.distance(G2).subs(mySubs)),
                     float(G1.distance(G3).subs(mySubs)),
                     float(G1.distance(G4).subs(mySubs)))
print("#(2)正四面体 ",float(G2.distance(G3).subs(mySubs)),
                     float(G3.distance(G4).subs(mySubs)),
                     float(G4.distance(G2).subs(mySubs)))
print("#(3)体積-重心",float(myTaiseki(G1,G2,G3,G4).subs(mySubs)))
print("#(4)体積-八面",float(PP.distance(PQ).subs(mySubs)),
                     float(PQ.distance(G2).subs(mySubs)),
                     float(G2.distance(G3).subs(mySubs)),
                     float(G3.distance(PP).subs(mySubs)))
print("#(4)体積-八面",float(
            (myTaiseki(PP,PQ,G2,PR)+myTaiseki(PP,G2,G3,PR)+myTaiseki(PP,PQ,G2,G1)+myTaiseki(PP,G2,G3,G1)).subs(mySubs))
      )
#(1)体積-1,2 sqrt(2)/12 sqrt(2)/324
#(2)正四面体  1/3 1/3 1/3
#(2)正四面体  1/3 1/3 1/3
#(3)体積-重心 sqrt(2)/324
#(4)体積-八面 1/3 1/3 1/3 1/3
#(4)体積-八面 sqrt(2)/81

#(1)体積-1,2 0.11785113019775792 0.004364856673991034
#(2)正四面体  0.3333333333333333 0.3333333333333333 0.3333333333333333
#(2)正四面体  0.3333333333333333 0.3333333333333333 0.3333333333333333
#(3)体積-重心 0.004364856673991034
#(4)体積-八面 0.3333333333333333 0.3333333333333333 0.3333333333333333 0.3333333333333333
#(4)体積-八面 0.017459426695964137
```