如何从距离,方位角和高程获取3D坐标 [英] How to get 3D coordinates from distance, azimuth and elevation

查看:139
本文介绍了如何从距离,方位角和高程获取3D坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在3D环境(100x100x100虚拟立方体)中工作,其中每个点均由其x,y和z位置定义.我们有两点:A的位置为x:20 y:35 z:40,B的位置为x:50 y:40 z:85.使用此算法( https://gis.stackexchange.com/questions/108547/如何从两个xyz坐标中计算距离和倾角)我能够找到距离,方位角和海拔高度从A看到的B的数字.

I'm working in a 3D environment (a 100x100x100 virtual cube) where each point is defined by its x, y and z position. We have two points: A with position x:20 y:35 z:40 and B x:50 y:40 z:85. Using this algo (https://gis.stackexchange.com/questions/108547/how-to-calculate-distance-azimuth-and-dip-from-two-xyz-coordinates) I'm able to find the distance, the azimuth and the elevation of B seen from A.

let ax = 20;
let ay = 35;
let az = 40;

let bx = 50;
let by = 40;
let bz = 85;

let dx = bx-ax;
let dy = by-ay;
let dz = bz-az;

let dist = Math.sqrt( Math.pow(dx,2) + Math.pow(dy,2) + Math.pow(dz,2) ); // SQRT((x2–x1)2+(y2–y1)2+(z2–z1)2)
let azim = toDeg( Math.atan( dx / dy ) );                                 // arctan((x2–x1)/(y2–y1))
let elev = toDeg( Math.asin( dz / dist ) );                               // arcsin ((z2–z1) / distance)

方位角和海拔高度通过toDeg()函数进行度数转换,以进行验证

Azimuth+elevation are converted in degrees with the function toDeg() for verification

function toDeg (angle) {
    let a = angle * (180 / Math.PI);
    return a 
}

结果:

dist = 54.31390245600108
azim = 80.53767779197439
elev = 55.94671404468539

现在的问题是:如何获取B的初始值?知道B的A pos(20,35,40)和dist + azim + elev,是否有可能获得其位置50,40,85?

The question is now: how to retrieve B initial values? Knowing the A pos (20,35,40) and dist+azim+elev of B, is it possible to obtain its position 50,40,85?

假设Math函数没有返回准确的结果(小数点后的截断),绝对精度并不重要,因为使用Math.round()找到49.9999(而不是50)会给出正确的值->点x:49.9999 y:40.0002z:84,9999不存在于多维数据集中.

Supposing Math functions don't return the exact result (truncated decimals) an absolute precision is not important because finding i.e 49.9999 instead of 50 gives the correct value with Math.round() -> the point x:49.9999 y:40.0002 z:84,9999 doesn't exist in the cube.

提前寻求帮助

推荐答案

关闭以获取解决方案:

let azim = Math.atan( dx / dy ); // keep result in radians
let elev = Math.asin( dz / dist );

 X = Math.round( dist * ( Math.cos( elev ) * Math.sin( azim ) ) );
 Y = Math.round( dist * ( Math.cos( elev ) * Math.cos( azim ) ) );
 Z = Math.round( dist * Math.sin( elev ) );

最后一个可能解决的问题:在某些情况下(例如X为负数且斧头低于Math.abs(X))X和Y是错误的.我现在正在寻找一种方法来直接获得正确的结果,而不是编码条件(如果/否则...).

Last prob to solve: in some cases (i.e X negative and ax lower than Math.abs(X) ) X and Y are wrong. Instead of coding conditions (if/else...) I'm now looking for a way to obtain directly the right results.

这篇关于如何从距离,方位角和高程获取3D坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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