LoginSignup
0
0

More than 1 year has passed since last update.

分点公式「21年 三重大 後 教育・工 1(2)」をsympy でやってみた。

Last updated at Posted at 2022-07-18

オリジナル

sympyで

求点3点で、2次元3条件なので6元連立方程式で解けるはず。
ばらさなくても、解ける方法を教えて下さい。
分点公式?だそうです。分点公式を確認予定。

from sympy import *
var('a1 a2 b1 b2 c1 c2')
A=Point(a1,a2)
B=Point(b1,b2)
C=Point(c1,c2)
G=(A+B+C)*Rational(1,3)
M=(A+B)  *Rational(1,2)
N=B+(C-B)*Rational(1,5)
ans=solve([G.x-1,G.y-1,
           M.x-3,M.y-0,
           N.x-1,N.y-3],
          [a1,a2,b1,b2,c1,c2])
print("# ",A.subs([(a1,ans[a1]),(a2,ans[a2])]))
print("# ",B.subs([(b1,ans[b1]),(b2,ans[b2])]))
print("# ",C.subs([(c1,ans[c1]),(c2,ans[c2])]))
#  Point2D(4, -3)
#  Point2D(2, 3)
#  Point2D(-3, 3)
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