Skip to content

Instantly share code, notes, and snippets.

@skanae
Last active October 7, 2021 14:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skanae/d8c67212fa525db3e9cf854f422ed639 to your computer and use it in GitHub Desktop.
Save skanae/d8c67212fa525db3e9cf854f422ed639 to your computer and use it in GitHub Desktop.
旅麻雀用 西に100km地点を教えてくれる
from geopy.distance import geodesic
import math
# (緯度, 経度)
KyotoStation = (34.98625332246909, 135.7589705460798)
input = ("w",100) #行きたい方角と距離
nowPlace = [34.98625332246909, 135.7589705460798]
longest = [34.7024, 135.4959]
if(input[0] == "n"):
longest[0] = 46.0000
elif(input[0] == "e"):
longest[1] = 153.0000
elif(input[0] == "s"):
longest[0] = 24.0000
elif(input[0] == "w"):
longest[1] = 122.0000
outer = longest
inner = nowPlace
error = 1e10
while(abs(error) > 1):
tmp=((inner[0]+outer[0])/2,(inner[1]+outer[1])/2)
dis = geodesic(nowPlace, tmp).km
error = dis - input[1]
if(error>0):
outer = tmp
else:
inner = tmp
print(dis,tmp,inner,outer)
print(error,"\n",dis,"\n",tmp,nowPlace)
print("ここにとべ!",tmp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment