2017-06-14 442 views
0

使用cesiumjs,我想计算两点之间的仰角,就好像我们站在第一个点的热气球上一样。点是简单的制图点(纬度,长度,高度)。使用cesiumjs计算两个lat/long/alt点之间的仰角

这幅画概括起来很好 enter image description here

一些经过研究,这是一个建议的方法:

改变你的目标点在地球固定框架这个地方 水平面,你可以使用Transforms.eastNorthUpToFixedFrame。 返回一个Matrix4,然后将您的目标点数乘以 ,产生一个新的向量。标准化该矢量,然后将仰角简化为标准化矢量的asin(z)。

这是我放在一起的代码,但它为乘法返回NaN。任何建议将不胜感激。

var Cesium = require('cesium'); 

var startPoint = new Cesium.Cartesian3.fromDegrees(-107, 30, 3000); 
var endPoint = new Cesium.Cartesian3.fromDegrees(-112, 25, 1000000); 

//To transform your target point in the Earth-fixed frame to this local horizontal plane, you can use Transforms.eastNorthUpToFixedFrame. 
var effTarget = Cesium.Transforms.eastNorthUpToFixedFrame(endPoint) 
console.log("Earth-fixed frame (target): " + effTarget); 

//That returns a Matrix4, which you then multiply your target point vector by, yielding a new vector. 
var multiplicationResult = new Cesium.Cartesian3(); 
Cesium.Cartesian3.multiplyComponents(effTarget, endPoint, multiplicationResult) 
console.log("Multiplication result: " + multiplicationResult) 

//Normalize that vector 
var normalizationResult = new Cesium.Cartesian3(); 
Cesium.Cartesian3.normalize(multiplicationResult, normalizationResult); 
console.log("Normalize result: " + normalizationResult) 

//and then the elevation angle is simply asin(z) of the normalized vector. 
var elevationAngle = Math.asin(normalizationResult.z) 
console.log("Elevation angle: " + elevationAngle) 

回答

0

我相信你正在使用错误的对象来进行乘法运算。尝试使用.multiplyByPoint方法让您的新Cartesian3结果:

//That returns a Matrix4, which you then multiply your target point vector by, yielding a new vector. 
var multiplicationResult = new Cesium.Cartesian3(); 
Cesium.Matrix4.multiplyByPoint(effTarget, endPoint, multiplicationResult) 
console.log("Multiplication result: " + multiplicationResult) 

您应该能够继续与该multiplicationResult

0

这是在正确的方向前进,但不完全正确尚未:

var startPoint = new Cesium.Cartesian3.fromDegrees(-107, 30, 3000); 
var endPoint = new Cesium.Cartesian3.fromDegrees(-112, 25, 1000000); 

//To transform your target point in the Earth-fixed frame to this local horizontal plane, you can use Transforms.eastNorthUpToFixedFrame. 
var effTarget = Cesium.Transforms.eastNorthUpToFixedFrame(endPoint); 
console.log("Earth-fixed frame (target): " + effTarget); 

//That returns a Matrix4, which you then multiply your target point vector by, yielding a new vector. 
var multiplicationResult = Cesium.Matrix4.multiplyByPointAsVector(effTarget, startPoint, new Cesium.Cartesian3()); 
console.log("Multiplication result: " + multiplicationResult); 

//Normalize that vector 
var normalizationResult = new Cesium.Cartesian3(); 
Cesium.Cartesian3.normalize(multiplicationResult, normalizationResult); 
console.log("Normalize result: " + normalizationResult); 

//and then the elevation angle is simply asin(z) of the normalized vector. 
var elevationAngle = Math.asin(normalizationResult.z); 
console.log("Elevation angle: " + Cesium.Math.toDegrees(elevationAngle)); 
+0

你尝试我所提供的答案吗? – ethorn10

+0

你好,是的,但不幸的是它没有工作。还是)感谢你的建议 – Fidel

相关问题