生成给定距离,角度与中心的坐标 [英] Generate coordinates given distance, angle from a center

查看:60
本文介绍了生成给定距离,角度与中心的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在地图[x1,y1]中有给定的中心.我从那个中心画了一个半径为1英里的圆.我需要在圆周围再生成8个点,各个点到中心的距离应为1英里,因此它们位于圆的边界上.我确实知道获得x2,y2的公式,但是问题在于它不是完美的球体,因此不适用于地球地图.

I have a given center in the map [x1,y1]. From that center I am drawing a circle with a 1 mile radius. I need to generate 8 more points around the circle, the distance between the individual points to center should be 1 mile, so they are on the circle bounds. I do know the formulas to get x2, y2 but the problem is it doesn't apply to earth's map since it isn't a perfect sphere.

我尝试使用,但是没有运气

I've tried using this, but with no luck.

谁能指出我在某个地方,或者我弄错了吗?

Could anyone point me somewhere or maybe I got this wrong ?

已解决!

因此,仔细阅读整个Movable Type脚本后,我发现了这一点(为我的使用做了一些修改):

So reading carefully throughout Movable Type Scripts I found this (slightly modified for my use):

   let getPoint = (distance, bearing, center) => {

    let δ = Number(distance) / 6371e3; 
    let θ = Number(bearing).toRadians();

    let φ1 = center[0].toRadians();
    let λ1 = center[1].toRadians();

    let sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1);
    let sinδ = Math.sin(δ), cosδ = Math.cos(δ);
    let sinθ = Math.sin(θ), cosθ = Math.cos(θ);

    let sinφ2 = sinφ1*cosδ + cosφ1*sinδ*cosθ;
    let φ2 = Math.asin(sinφ2);
    let y = sinθ * sinδ * cosφ1;
    let x = cosδ - sinφ1 * sinφ2;
    let λ2 = λ1 + Math.atan2(y, x);

    return [φ2.toDegrees(), (λ2.toDegrees()+540)%360-180]; 
};

它确实解决了我的问题.

It did solved my problem.

推荐答案

您正在尝试解决所谓的

You are trying to solve what is known as the first (or direct) geodetic problem. Knowing this name will make your research easier.

如"如何使用Leaflet "和" greographiclib 适用于远距离.

As pointed out by the answers to "How to draw polyline perpendicular to another polyline using Leaflet" and "Find destination coordinates given starting coodinates, bearing, and distance", your main options to approach this problem in javascript are cheap-ruler for small(ish) areas and greographiclib for large distances.

便宜的统治者往往很快但不准确,而geolib往往更慢但非常准确.

cheap-ruler tends to be very fast but inaccurate, and geographiclib tends to be slower but very accurate.

您可能会发现其他实现,每个实现都有自己的妥协.大地测量很难,因此没有任何一种正确的方法" 来计算距离或方位角.

You might find other implementations, each with its own compromises. Geodesy is hard, so there is no "one true way" to calculate distances or azimuths.

这篇关于生成给定距离,角度与中心的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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