2点があります
線分ができます
角度をもとめましょう
import math import pylab as plt x1 = -100 y1 = 10 x2 = -20 y2 = 50 result1 = math.atan2(y2-y1,x2-x1) print "rad", result1 print "deg", math.degrees(result1) x3 = -150 y3 = 100 result2 = math.atan2(y3-y1,x3-x1) print "rad", result2 print "deg", math.degrees(result2) x4 = -100 y4 = 100 result3 = math.atan2(y4-y1,x4-x1) print "rad", result3 print "deg", math.degrees(result3) plt.plot([x1, x2], [y1, y2], 'k-') plt.plot([x1, x3], [y1, y3], 'k-') plt.plot([x1, x4], [y1, y4], 'k-') plt.show()
結果
rad 0.463647609001
deg 26.5650511771
rad 2.07789483119
deg 119.054604099
rad 1.57079632679
deg 90.0
合ってそうですね.
では,なぜatan2を使うのか?
そもそもatan2とは何なのか?
それは…
No more Retake : arctan2(アークタンジェント2)ってなんぞ?
ここに詳しく書いてあります