根据百分比计算两个坐标之间的点 [英] Calculate point between two coordinates based on a percentage

查看:483
本文介绍了根据百分比计算两个坐标之间的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个函数,它返回两点之间的点(纬度,长度)(我也指定它们的纬度,长度),并且该点基于距离百分比。

I am looking for a function that returns a point (lat, long) between two points (where I also specify their lat, long) and that point is based on a distance percentage.

所以,我在函数上指定Lat1,Lon1,Lat2,Lon2和%,它返回一个点,例如,从第一个点到第二个点的距离为20%。

So, I specify Lat1, Lon1, Lat2, Lon2 and a % on the function and, it returns a point, for example, 20% distant from the first point to the second.

推荐答案

假设坐标是十进制数。你可以使用这个等式。

Assuming the coordinate is a decimal number. You can use this equation.

function midpoint(lat1, long1, lat2, long2, per) {
     return [lat1 + (lat2 - lat1) * per, long1 + (long2 - long1) * per];
}

根据百分比返回[lat,long]的新所需坐标(例如per = 0.2,20%)。

Return a new desired coordinate of [lat, long], based on the percentage (such as per=0.2 for 20%).

这篇关于根据百分比计算两个坐标之间的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆