#HW1 Inverse geodetic problem on plane
from math import*
rad=pi/180
# task 1
x0=500
y0=600
x=301
y=705

s=sqrt((x0-x)**2+(y0-y)**2)
print(s)

alpha=atan((y0-y)/(x0-x))


print(alpha/rad) #alpha value in degree


#task 2 First geodetic problem on sphere
fi0=47.474795
la0=19.0620286
s=85000
r=6372797
alpha0=60


#fip=asin(sin(fi0)*cos(s/r) + cos(fi0)*sin(s/r)*cos(alpha0*rad))
fip=asin(sin(fi0*rad)*cos(s/r) + cos(fi0*rad)*sin(s/r)*cos(alpha0*rad))
print(fip/rad) #print the fip value in degree

#Divide the equation in two part, because you dont have any initial value for dla. First calculate the dla value
dla=acos((cos(s/r)-sin(fi0*rad)*sin(fip))/(cos(fi0*rad)*cos(fip)))
#If you have a dla value, then you can get the sign of dla, with the next equation //(dla/abs(dla)) give back 1 or -1.
dla=dla*(sin(dla))/(abs(sin(dla)))
print(dla/rad) #print dla value in degree, (difference between the longitudes)

la=la0+dla/rad #calculate  la value in degree
print(la)
