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?

空間ベクトル「2024 北海道大学 フロンティア入試 選択問題【2】」をChatGPTとsympyとFreeCADでやってみたい。

Last updated at Posted at 2024-05-13

既投稿を潰してしまって、復旧中です。申し訳ありません。

オリジナル

>2024 北海道大学 フロンティア入試選択問題MathJax 様
https://mathexamtest.web.fc2.com/2024/202410001/2024100010400mj.html#top-0402
>ManabiMath 様 問題解答解説
https://mathmathmass.exblog.jp/
https://drive.google.com/file/d/1pN5Qkk-PZBeGgw2hrR1f0fFmvi23lAM9/view

> 大学入試数学問題集成 様 >【13】テキスト
< ManabiMath 様 トップページ
https://manabimath.jimdofree.com/
https://mathexamtest.web.fc2.com/2023/202320120/2023201200100mj.html#top-

公式ホームページ
https://www.hokudai.ac.jp/admission/faculty/ao/pastproblem.html
(省略)

sympyで(オリジナル 様の方法で)

・??? 勉強中

ChatGPT-3.5先生へ

大学入試数学問題集成 様> 2024 北海道大学 フロンティア入試 選択問題【2】テキスト

・ページのソースを表示です。MathMLです。
 省略しようと思いましたが、M.E.T.A.様 の全文です。

<p class="slevel"><a name="q-0402" 
id="q-0402"></a><span 
class="qnum">【2】</span> 空間内の原点<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">O</mi><mspace width=".2em"></mspace>
</math>を通りベクトル<math>
<mspace width=".2em"></mspace><mrow><mover><mi>u</mi><mo>&rightarrow;</mo></mover>
<mo>=</mo><mo stretchy="false">(</mo><mn>1</mn><mo>,</mo><mn>0</mn><mo>,</mo>
<mo>-</mo><mn>1</mn><mo rspace=".2em" stretchy="false">)</mo></mrow>
</math>に平行な直線を<math>
<mspace width=".2em"></mspace><mi>l</mi><mspace width=".2em"></mspace>
</math>とし,点<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">A</mi><mspace width=".5em"></mspace>
</math><math>
<mrow><mo stretchy="false">(</mo><mn>1</mn><mo>,</mo><mn>4</mn><mo>,</mo>
<mn>2</mn><mo rspace=".2em" stretchy="false">)</mo></mrow>
</math>を通りベクトル<math>
<mspace width=".2em"></mspace><mrow><mover><mi>v</mi><mo>&rightarrow;</mo></mover>
<mo>=</mo><mo stretchy="false">(</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo>,</mo>
<mn>1</mn><mo rspace=".2em" stretchy="false">)</mo></mrow>
</math>に平行な直線を<math>
<mspace width=".2em"></mspace><mi>m</mi><mspace width=".2em"></mspace>
</math>とする.<math>
<mi>l</mi><mspace width=".2em"></mspace>
</math>上の点<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">P</mi><mspace width=".2em"></mspace>
</math>と<math>
<mspace width=".2em"></mspace><mi>m</mi><mspace width=".2em"></mspace>
</math>上の点<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">Q</mi><mspace width=".2em"></mspace>
</math>を通る直線<math>
<mspace width=".2em"></mspace><mi>PQ</mi><mspace width=".2em"></mspace>
</math>は<math>
<mspace width=".2em"></mspace><mi>l</mi><mspace width=".2em"></mspace>
</math>と<math>
<mspace width=".2em"></mspace><mi>m</mi><mspace width=".2em"></mspace>
</math>の両方に直交する.</p>
<p class="s1level">(1) <math>
<mi mathvariant="normal">P</mi><mspace width=".2em"></mspace>
</math>と<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">Q</mi><mspace width=".2em"></mspace>
</math>の座標を求めなさい.</p>
<p class="s1level">(2) <math>
<mi>&triangle;OPQ</mi><mspace width=".2em"></mspace>
</math>の面積を求めなさい.</p>
<p class="s1level">(3) <math>
<mi>&triangle;OPQ</mi><mspace width=".2em"></mspace>
</math>を含む平面を<math>
<mspace width=".2em"></mspace><mi>&alpha;</mi><mspace width=".2em"></mspace>
</math>とする.点<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">A</mi><mspace width=".2em"></mspace>
</math>から<math>
<mspace width=".2em"></mspace><mi>&alpha;</mi><mspace width=".2em"></mspace>
</math>へ垂線を下ろし,<math>
<mi>&alpha;</mi><mspace width=".2em"></mspace>
</math>との交点を<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">H</mi><mspace width=".2em"></mspace>
</math>とする.<math>
<mi mathvariant="normal">H</mi><mspace width=".2em"></mspace>
</math>の座標,線分<math>
<mspace width=".2em"></mspace><mi>AH</mi><mspace width=".2em"></mspace>
</math>の長さ,四面体<math>
<mspace width=".2em"></mspace><mi>AOPQ</mi><mspace width=".2em"></mspace>
</math>の体積を求めなさい.</p>
<p class="s1level">(4) 点<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">Q</mi><mspace width=".2em"></mspace>
</math>に関して<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">A</mi><mspace width=".2em"></mspace>
</math>と対称な点を<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">B</mi><mspace width=".2em"></mspace>
</math>とする.四面体<math>
<mspace width=".2em"></mspace><mi>BOPQ</mi><mspace width=".2em"></mspace>
</math>の体積を求めなさい.
<div class="qbody">
<p class="slevel"><a name="q-0113" 
id="q-0113"></a><span 
class="qnum">【13】</span> 座標空間内の<math>
<mspace width=".2em"></mspace><mn>4</mn>
<mspace width=".2em"></mspace>
</math>点<math>
<mspace width=".2em"></mspace><mi mathvariant="normal">A</mi>
<mspace width=".5em"></mspace>
</math><math>
<mrow><mo stretchy="false">(</mo><mn>0</mn><mo>,</mo>
<mo>-</mo><mn>1</mn><mo>,</mo><mn>1</mn>
<mo rspace=".2em" stretchy="false">)</mo><mtext>,</mtext></mrow>
</math><math>
<mi mathvariant="normal">B</mi><mspace width=".5em"></mspace>
</math><math>
<mrow><mo stretchy="false">(</mo><mn>2</mn><mo>,</mo>
<mn>0</mn><mo>,</mo><mn>0</mn>
<mo rspace=".2em" stretchy="false">)</mo><mtext>,</mtext></mrow>
</math><math>
<mi mathvariant="normal">C</mi><mspace width=".5em"></mspace>
</math><math>
<mrow><mo stretchy="false">(</mo><mn>1</mn><mo>,</mo>
<mn>0</mn><mo>,</mo><mn>1</mn>
<mo rspace=".2em" stretchy="false">)</mo><mtext>,</mtext></mrow>
</math><math>
<mi mathvariant="normal">D</mi><mspace width=".5em"></mspace>
</math><math>
<mrow><mo stretchy="false">(</mo><mi>t</mi><mo>,</mo><mn>2</mn>
<mo>,</mo><mn>0</mn><mo rspace=".2em" stretchy="false">)</mo></mrow>
</math><math>
<mrow><mtext>(</mtext><mspace width=".2em"></mspace>
<mi>t</mi></mrow><mspace width=".2em"></mspace>
</math>は実数)が同一平面上にあるとき,<math>
<mi>t</mi><mspace width=".2em"></mspace>
</math>の値はいくらか.</p>
<p class="s2sublevel half"><math>
<mrow><mtext>1.</mtext><mo>-</mo><mn>2</mn><mtext>  </mtext></mrow>
</math><math>
<mrow><mtext>2.</mtext><mn>0</mn><mtext>  </mtext></mrow>
</math><math>
<mrow><mtext>3.</mtext><mn>2</mn><mtext>  </mtext></mrow>
</math><math>
<mrow><mtext>4.</mtext><mn>4</mn><mtext>  </mtext></mrow>
</math><math>
<mrow><mtext>5.</mtext><mn>6</mn></mrow></math>
</p>
</div>
</div>

・上記を、ChtGPTのnewchatにコピー貼り付けです。
 (始めから、sympyで。ありかも。)

この問題は、空間内の直線と点に関する問題ですね。それでは順番に解いていきましょう。
...

・あきらめました。

(従来の方法)sympyで、私のいつもの方法です。

・以下、私のコツコツのコードです。
・安易に行列式を使っています。
・Hの座標がほしいのは、手計算ならです。体積だけなら、面倒くさいですね。
>sympy docより
https://docs.sympy.org/latest/modules/geometry/plane.html#sympy.geometry.plane.Plane.projection
https://docs.sympy.org/latest/modules/geometry/plane.html

from sympy import *
var('t',real=True)
def SimentaiTaiseki(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 myCross(A,B):
    return Point(A.y*B.z-A.z*B.y,A.z*B.x-A.x*B.z,A.x*B.y-A.y*B.x)
O  =Point(0,0, 0)
u  =Point(1,0,-1)
A  =Point(1,4, 2)
v  =Point(0,1, 1)
P  =  t*u
Q  =A+s*v
rep =solve([Eq((Q-P).dot(u),0),Eq((Q-P).dot(v),0)],[s,t] ) 
P   =P.subs(rep)
Q   =Q.subs(rep)
OPQ =Herons3(O,P,Q)
H   =Plane(O,P,Q).projection(A)
AH  =A.distance(H)
AOPQ=Rational(1,3)*Herons3(O,P,Q)*A.distance(H)
B   =Q+(Q-A)
print("#(1)",P,Q)
print("#(2)",OPQ)
print("#(3)",H,AH,AOPQ)
print("#(4)",SimentaiTaiseki(B,O,P,Q))
#(1) Point3D(4/3, 0, -4/3) Point3D(1, 1/3, -5/3)
#(2) 2*sqrt(6)/9
#(3) Point3D(-5/6, 1/3, 1/6) 11*sqrt(6)/6 22/27
#(4) 22/27

FreeCADのマクロで作図

・3次元FreeCADのワイヤーフレームです。
・マクロプログラムの計算部分は、コピーしています。

import FreeCAD
import Part
import Draft
import Mesh
#########################################################################################################
# 計算
##############################################################
# ver0.1
# 
# 北海道フロ
# https://docs.sympy.org/latest/modules/geometry/plane.html
from sympy import *
var('s,t',real=True)
def Herons(a,b,c):
    s=(a+b+c)/2
    return sqrt(s*(s-a)*(s-b)*(s-c)).simplify()
def Herons3(p,q,r):
    return Herons(p.distance(q), q.distance(r), r.distance(p))
def SimentaiTaiseki(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 myCross(A,B):
    return Point(A.y*B.z-A.z*B.y,A.z*B.x-A.x*B.z,A.x*B.y-A.y*B.x)
O  =Point(0,0, 0)
u  =Point(1,0,-1)
A  =Point(1,4, 2)
v  =Point(0,1, 1)
P  =  t*u
Q  =A+s*v
rep =solve([Eq((Q-P).dot(u),0),Eq((Q-P).dot(v),0)],[s,t] ) 
P   =P.subs(rep)
Q   =Q.subs(rep)
OPQ =Herons3(O,P,Q)
H   =Plane(O,P,Q).projection(A)
AH  =A.distance(H)
AOPQ=Rational(1,3)*Herons3(O,P,Q)*A.distance(H)
B   =Q+(Q-A)
print("#(1)",P,Q)
print("#(2)",OPQ)
print("#(3)",H,AH,AOPQ)
print("#(4)",SimentaiTaiseki(B,O,P,Q))
##########################################################################################################
### 作図用
##########################################################################################################
### 3D作図
def myXYZ2Txt(A):
     return '(' + str(A.x) + ',' + str(A.y) + ',' + str(A.z) + ')'
    #return ''
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 = '1.0 mm'
    # FreeCADGui.ActiveDocument.ActiveObject.FontSize = '0.5 mm'
    # FreeCADGui.ActiveDocument.ActiveObject.FontSize = '0.1 mm'
    # FreeCADGui.ActiveDocument.ActiveObject.FontSize = '0.05 mm'
    return
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]) )
    return
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)
    return
def myLine_S(*args):
    for i in range(1,len(args)):
        myLine(args[i-1],args[i])
    return
def myLine_C(*args):
    for i in range(1,len(args)):
        myLine(args[i-1],args[i])
    myLine(args[i],args[0])
    return
def myLine_H(*args):
    for i in range(1,len(args)):
        myLine(args[0],args[i])
    return
#
#myLine_S  (A,O,B)
#myLine_S  (O,M)
#myLine_S  (A,C)
#myLine_S  (A,M)
#myLine_S  (A,D)
#myLine_C  (A,C,D)
#myTxtXYZ_S(O,"O",A,"A",B,"B",C,"C",D,"D",M,"M")

myLine_C  (  O,P,Q)
myLine_H  (A,O,P,Q)
myLine_H  (B,O,P,Q)
myLine    (A,B)
myTxtXYZ_S(O,"O",P,"P",Q,"Q")
myTxtXYZ_S(A,"A",B,"B")
#
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")

・作図はしましたが、FreeCADの勉強不足で、正しいか誤っているかよくわかりません。
1.png

拡大図
2.png

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

(テンプレート)

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?