LoginSignup
0
0

More than 1 year has passed since last update.

2定点と直線上の動点との距離の和「22年 長崎大 文系2 理系4」をsympy でやってみた。

Last updated at Posted at 2022-07-01

オリジナル

①ベクトルでやっていません。
②誘導(3)の使い方がわかりませんでした。
アドバイスをお願いします。

sympyで

from sympy import *
var('t u v')
OO=Point(0,0,0)
OA=Point(1,2,3)
OB=Point(1,1,-1)
OC=Point(7,3,5)
#
OP=t*OA
BP2CP2=OP.distance(OB)**2+OP.distance(OC)**2
print("#(1)",BP2CP2.expand())
ans=solve(diff(BP2CP2),t)[0]
OP=ans*OA
print("#(2) 目的",OP,BP2CP2.subs({t:ans}))
#
OH=Line(OO,OA).projection(OB)
OK=Line(OO,OA).projection(OC)
print("#(3)",(OH-OB).dot(OK-OC)/(OH.distance(OB)*OK.distance(OC)))
OP=u*OA
BPCP2=(OB.distance(OP)+OC.distance(OP))**2
ans=solve(diff(BPCP2),u)[0]
OP=ans*OA
print("#(4) 目的",OP,sqrt(BPCP2.subs({u:ans})))
print("#(4) ",solve((OK-OH)-v*(OP-OH),v)[v])
#(1) 28*t**2 - 56*t + 86
#(2) 目的 Point3D(1, 2, 3) 58
#(3) 5/9
#(4) 目的 Point3D(1/2, 1, 3/2) 2*sqrt(26)
#(4)  4
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