Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. import math
  2.  
  3. fin = open("input.txt", "r")
  4. shipX, shipY = map(float, fin.readline().split())
  5. shipDirectionVecX, shipDirectionVecY = map(float, fin.readline().split())
  6. shipLeanVecX, shipLeanVecY = map(float, fin.readline().split())
  7. enemyX, enemyY = map(float, fin.readline().split())
  8. fin.close()
  9.  
  10. leftsideVecX = -shipDirectionVecY
  11. leftsideVecY = shipDirectionVecX
  12.  
  13. rightsideVecX = shipDirectionVecY
  14. rightsideVecY = -shipDirectionVecX
  15.  
  16. verticalAngle = (1 / math.sqrt(1 + shipLeanVecX ** 2 +
  17.                                shipLeanVecY ** 2))
  18. fout = open("output.txt", "w")
  19. if (verticalAngle > 1 / 2):
  20.     verticalAngle = math.acos(verticalAngle) * (180 / math.pi)
  21.     leftVerticalPitch = (shipLeanVecX * leftsideVecX + shipLeanVecY * leftsideVecY) / (
  22.             math.sqrt(1 + shipLeanVecX ** 2 + shipLeanVecY ** 2) * math.sqrt(leftsideVecX ** 2 + leftsideVecY ** 2))
  23.     if (leftVerticalPitch > 0):
  24.         leftVerticalPitch = verticalAngle
  25.         rightVerticalPitch = -verticalAngle
  26.     else:
  27.         leftVerticalPitch = -verticalAngle
  28.         rightVerticalPitch = verticalAngle
  29. else:
  30.     fout.write("kek1")
  31.     exit(0)
  32.  
  33. enemyVecX = enemyX - shipX
  34. enemyVecY = enemyY - shipY
  35. horizontalAngle = (enemyVecX * shipDirectionVecX + enemyVecY * shipDirectionVecY) / (
  36.         math.sqrt(enemyVecX ** 2 + enemyVecY ** 2) * math.sqrt(shipDirectionVecX ** 2 + shipDirectionVecY ** 2))
  37.  
  38. if (abs(horizontalAngle) <= math.sqrt(3) / 2):
  39.     horizontalAngle = math.acos(horizontalAngle) * (180 / math.pi)
  40. else:
  41.     fout.write("kek2")
  42.     exit(0)
  43.  
  44. boardSide = (leftsideVecX * enemyVecX + leftsideVecY * enemyVecY) / (
  45.             math.sqrt(leftsideVecX ** 2 + leftsideVecY ** 2) * math.sqrt(enemyVecX ** 2 + enemyVecY ** 2))
  46. if (boardSide >= 0):
  47.     boardSide = 1
  48. else:
  49.     boardSide = -1
  50.  
  51. fout.write(str(boardSide) + "\n")
  52. fout.write(str(-(horizontalAngle - 90)) + "\n")
  53. fout.write(str(verticalAngle) + "\n")
  54. fout.write("au-revoir")
  55. fout.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement