LoginSignup
0
0

More than 5 years have passed since last update.

ラングレーの問題をだいたいsympyを使って解く

Last updated at Posted at 2017-04-20

(参考)ラングレーの問題
https://ja.wikipedia.org/wiki/%E3%83%A9%E3%83%B3%E3%82%B0%E3%83%AC%E3%83%BC%E3%81%AE%E5%95%8F%E9%A1%8C
(参考)Langley’s Adventitious Angles
https://en.m.wikipedia.org/wiki/Langley’s_Adventitious_Angles

#実行時間は、2分ぐらいかかります
from sympy import *
var('x')
x=100
B=Point(0,0)
A=Point(x*cos(pi/180*80),x*sin(pi/180*80))
C=Point(x*cos(pi/180*80)*2,0)
D2=C.rotate(pi/180*60)
E2=B.rotate(pi/180*(-50), C)
ans1=Line(C,A).intersection(Line(B,D2))
ans2=Line(B,A).intersection(Line(C,E2))
D=Point(ans1[0].x,ans1[0].y)
E=Point(ans2[0].x,ans2[0].y)
print("#角度BDE=",float(mpmath.degrees(Polygon(B,D,E).angles[D])))
#角度BDE= 30.0

#①xに値を入力しないと、以下のエラーがでます
#ValueError: Can't determine orientation
#②mpmath.radians関数を使うと
#角度BDE= 30.000000000000068

CADを使ったほうが早いかも。

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