我需要通过这两个坐标之间的距离的某个百分比找到更接近其他坐标的坐标(纬度/经度)。
示例:
location1 = (32.7991094663, -117.234719251)
location2 = (32.7094778234, -117.136413578)
# find a new location closer by 60% from location1 than location2
find_closer_location(location1, location2, 60)
用于计算我在algo下方使用的距离
from math import radians, cos, sin, asin, sqrt
def haversine(lon1, lat1, lon2, lat2):
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
km = 6371 * c
return km
答案 0 :(得分:1)
感谢每一个人的努力。
最后我想我有一个解决方案。
window.onblur = function() {
//document.title = 'We Miss You';
console.log('this works');
}
window.onfocus = function() {
//document.title = 'We Miss You';
console.log('this also works');
}
答案 1 :(得分:-1)
计算:
def moveMe(t1,t2,perc):
x1, y1= t1 # location1 = (32.7991094663, -117.234719251)
x2, y2 = t2 # location2 = (32.7094778234, -117.136413578)
dx = (x2-x1) / 100.0 * perc
dy = (y2-y1) / 100.0 * perc
return (x1+dx,y1+dy)
location1 = (32.7991094663, -117.234719251)
location2 = (32.7094778234, -117.136413578)
print(moveMe(location1,location2,10))
输出:
(32.808072630590004, -117.2445498183)
通过perc
在<0
>100
或t1
)t2
和perc
之间的线上插入一个新点。 ENT。如果你想要远离那条线,那你就必须要有点创造力。