import numpy
import matplotlib.pyplot as pyplot
import math
import numpy as np
#monitor location
p1=[23.038432538456675, 120.25344002041491] #train
p2=[22.977589258717874, 120.20155675409865] #culture
#station location
p3=[22.98664381596604, 120.23374180477799] #102.5M
def sphere_distance(p1, p2):
import math
if p1[0] < 0 or p2[0] < 0 or p1[0] > 90 or p2[0] > 90 or p1[1] < 0 or p2[1] < 0 or p1[1] > 180 or p2[1] > 180:
return 'Parameter Error.'
r = 6371000
i1 = (p1[0] / 180) * math.pi
j1 = (p1[1] / 180) * math.pi
i2 = (p2[0] / 180) * math.pi
j2 = (p2[1] / 180) * math.pi
d = 2 * r * math.asin(math.sqrt((math.sin((i2 - i1) / 2)) ** 2 + math.cos(i1) * math.cos(i2) * (math.sin((j2 - j1) / 2)) ** 2))
return d
#find c
c = sphere_distance(p1,p2)/2
#find a
station1 = sphere_distance(p1, p3)
sattion2 = sphere_distance(p2, p3)
a =(sattion2-station1)/2
#find b
b =math.sqrt(c**2-a**2)
print("c(m)=",c)
print("a(m)=",a)
print("b=",b)
r=1
x = numpy.arange(-10000, 10000, 1)
y=np.sqrt(((x**2/a**2)-r)*b**2)
#pyplot.plot(x, y,"b")
#pyplot.plot(x, -y,"b")
#pyplot.show()
plt.plot(x, y,"b")
plt.plot(x, -y,"b")
plt.show()