根据百分比计算两个坐标之间的点

编程入门 行业动态 更新时间:2024-10-12 18:16:03
本文介绍了根据百分比计算两个坐标之间的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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%).

更多推荐

根据百分比计算两个坐标之间的点

本文发布于:2023-11-29 11:34:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646278.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:百分比   坐标   两个

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!