fork download
  1. import math
  2. AX = 0
  3. AY = 0
  4. BX = 100
  5. BY = 0
  6.  
  7. abx = AX - BX
  8. aby = AY - BY
  9.  
  10. minangle = 100
  11. minindex = -1
  12.  
  13. pts = [[50, -10],[50, -20],[50, 1],[50, 20]]
  14. for i, p in enumerate(pts):
  15. pbx = p[0] - BX
  16. pby = p[1] - BY
  17. angle = math.atan2(-pbx*aby+pby*abx, pbx*abx+pby*aby)
  18. if angle < 0:
  19. angle += 2*math.pi
  20. if angle < minangle:
  21. minangle = angle
  22. minindex = i
  23.  
  24. print(pts[minindex])# your code goes here
Success #stdin #stdout 0.02s 9512KB
stdin
Standard input is empty
stdout
[50, -10]