Uploaded by skimming-jaws-stew

AssignmentOne Nissan Uddin

advertisement
Assignment One - Coordinates
EGN3214
Nissan Uddin
May 27, 2024
Introduction
The purpose of this assignment is to solve for the bearing as well as the distance of 3 landmarks
in Paris, France. We are given various UTM coordinates, and aforementioned objectives will be
calculated using Python.
Problem Statement
We are given the following UTC coordinates:
Eiffel Tower - 31U 0448251E 5411952N.
Louvre Museum 31U 0451057E 5412314N.
Arc de Triomphe 31U 0448337E 5413657N.
The objective is to start at the Eiffel Tower, proceed to the Louvre Museum, from there travel to
the Arc de Triomphe, and lastly travel back to where we started from.
Methodology
The primary portions of the code are the calculations for the distance between each of the
landmarks and especially the bearings. The methodology to calculate distances between each
landmark is listed below. This math function uses the distance formula between two points on a
grid.
The majority of the code are if and elseif statements used to calculate the bearing of the
landmarks. Each conditional accounts for each quadrant of the compass rose and uses the arctan
math function to solve for the degrees in that respective quadrant.
Assignment One - Coordinates
EGN3214
Nissan Uddin
May 27, 2024
Solution
Trip Distance: 1416 meters long
Eiffel Tower > Louvre Museum
Distance: 666 meters
Bearing: 253 degrees
Louvre Museum > Arc de Triomphe
Distance: 442 Meters
Bearing: 50 degrees
Arc de Triomphe > Eiffel Tower
Distance: 307 meters
Bearing: 343 degrees
Conclusion
Overall, I do not believe my solution was correct, however, the methodology is mostly correct.
There are some slight issues with the math in the code regarding the bearings of each landmark
in certain quadrants. Several hours were spent attempting to correct the code to solve for the
bearings but the solution did not present itself.
Assignment One - Coordinates
EGN3214
Appendix
import math
#Distance Calculation
def calculateDistance(e1,n1,e2,n2):
return math.sqrt((n1-n2)**2 + (e1-e2)**2)
#Bearings are calculated with conditionals
def calculateBearing(e1,n1,e2,n2):
b=0
if (n2>n1):
if(e2>e1):#Conditional covers 0-90 degrees
b=math.degrees(math.atan((n2-n1)/(e2-e1)))
elif (e2<e1): #Conditional Covers 270-360 degrees
b=270+(math.degrees(math.atan(-((n2-n1)/(e2-e1)))))
elif
(n2<n1):
if (e2>e1):#Conditional Covers 90-180 degrees
b=90+(math.degrees(math.atan(-((n2-n1)/(e2-e1)))))
elif (e2<e1): #Conditional Covers 180-270 degrees
b=180+(math.degrees(math.atan(((n2-n1)/(e2-e1)))))
return b
#Testcase
b1= calculateBearing(0,0,1,1)
b2= calculateBearing(0,0,1,-1)
b3= calculateBearing(0,0,-1,-1)
b4= calculateBearing(0,0,-1,1)
#UTM Coordinates
E2L_Distance=calculateDistance(251,952,57,314)
E2L_Bearing=calculateBearing(251,952,57,314)
L2T_Distance=calculateDistance(57,314,337,657)
L2T_Bearing=calculateBearing(57,314,337,657)
T2E_Distance=calculateDistance(337,657,251,952)
T2E_Bearing=calculateBearing(337,657,251,952)
Nissan Uddin
May 27, 2024
Assignment One - Coordinates
EGN3214
TripDistance = E2L_Distance + L2T_Distance + T2E_Distance
print('The trip is ',int(TripDistance),'meters long')
print('The bearing from Eiffel Tower to Louvre Museum
is',int(E2L_Bearing),'degrees')
print('The bearing from Louvre Museum to Arc de Triomphe
is',int(L2T_Bearing),'degrees')
print('The bearing from Arc de Triomphe to Eiffel Tower
is',int(T2E_Bearing),'degrees')
Nissan Uddin
May 27, 2024
Download