Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.36 KB | None | 0 0
  1. import math
  2.  
  3. a_n_s = input(str('Is waypoint 1 N or S Latitude: '))
  4. if a_n_s.lower() == 'n':
  5.     a_n_s = 1
  6. else:
  7.     a_n_s = -1
  8.  
  9. a_e_w = input(str('Is waypoint 1 E or W Longitude: '))
  10. if a_e_w.lower() == 'e':
  11.     a_e_w = -1
  12. else:
  13.     a_e_w = 1
  14.  
  15. waypoint_a_lat_deg = float(input('Waypoint 1 Latitude Degrees: '))
  16. waypoint_a_lat_min = float(input('Waypoint 1 Latitude decimal Minutes: '))
  17. waypoint_a_lat = waypoint_a_lat_deg + (waypoint_a_lat_min / 60)
  18.  
  19. waypoint_a_lon_deg = float(input('Waypoint 1 Longitude Degrees: '))
  20. waypoint_a_lon_min = float(input('Waypoint 1 Longitude decimal Minutes: '))
  21. waypoint_a_lon = waypoint_a_lon_deg + (waypoint_a_lon_min / 60)
  22.  
  23.  
  24. b_n_s = input(str('Is waypoint 2 N or S Latitude: '))
  25. if b_n_s.lower() == 'n':
  26.     b_n_s = 1
  27. else:
  28.     b_n_s = -1
  29. b_e_w = input(str('Is waypoint 2 E or W Longitude: '))
  30. if b_e_w.lower() == 'e':
  31.     b_e_w = -1
  32. else:
  33.     b_e_w = 1
  34. waypoint_b_lat_deg = float(input('Waypoint 2 Latitude Degrees: '))
  35. waypoint_b_lat_min = float(input('Waypoint 2 Latitude decimal Minutes: '))
  36. waypoint_b_lat = waypoint_b_lat_deg + (waypoint_b_lat_min / 60)
  37.  
  38. waypoint_b_lon_deg = float(input('Waypoint 2 Longitude Degrees: '))
  39. waypoint_b_lon_min = float(input('Waypoint 2 Longitude decimal Minutes: '))
  40. waypoint_b_lon = waypoint_b_lon_deg + (waypoint_b_lon_min / 60)
  41.  
  42. lat1 = math.radians(waypoint_a_lat_deg) * a_n_s #USE THIS FOR THE SPHERICAL CALCULATIONS
  43. lon1 = math.radians(waypoint_a_lon_deg) * a_e_w #USE THIS FOR THE SPHERICAL CALCULATIONS
  44. lat2 = math.radians(waypoint_b_lat_deg) * b_n_s #USE THIS FOR THE SPHERICAL CALCULATIONS
  45. lon2 = math.radians(waypoint_b_lon_deg) * b_e_w #USE THIS FOR THE SPHERICAL CALCULATIONS
  46.  
  47. print('waypoint a lat: ' + str(waypoint_a_lat) + str(type(waypoint_a_lat)))
  48. print('waypoint a lon: ' + str(waypoint_a_lon) + str(type(waypoint_a_lon)))
  49. print('waypoint b lat: ' + str(waypoint_b_lat) + str(type(waypoint_b_lat)))
  50. print('waypoint b lon: ' + str(waypoint_b_lon) + str(type(waypoint_b_lon)))
  51.  
  52. print('lat1: ' + str(lat1) + str(type(lat1)))
  53. print('lon1: ' + str(lon1) + str(type(lon1)))
  54. print('lat2: ' + str(lat2) + str(type(lat2)))
  55. print('lon2: ' + str(lon2) + str(type(lon2)))
  56.  
  57.  
  58. true_crs = math.atan2((math.sin(lon1 - lon2) * math.cos(lat2)),(math.cos(lat1) * math.sin(lat2)) - (math.sin(lat1) * math.cos(lat2) * math.cos(lon1 - lon2))) % (math.pi * 2)
  59. print(str(math.degrees(true_crs)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement