【发布时间】:2021-07-24 19:58:06
【问题描述】:
我正在尝试查找给定经度和纬度的 x 和 y 坐标。我想在我的应用程序中使用 x 和 y 坐标在 three.js 中显示多维数据集。我使用了以下公式:
public calcPosFromLatLonRad ( lat: number, lon: number, radius: number ) {
var phi = (90 - lat) * (Math.PI / 180);
var theta = (lon + 180) * (Math.PI / 180);
const x = -(radius * Math.sin(phi) * Math.cos(theta));
const z = (radius * Math.sin(phi) * Math.sin(theta));
const y = (radius * Math.cos(phi));
console.log('x Koordinate: ' + x + ' y Koordinate: ' + y + 'z Koordinate: ' + z);
return [x, y, z];
}
然后我尝试了:
const x1 = this.calcPosFromLatLonRad(52.387980, 9.719260, 100);
const pos1x = x1[0];
const pos1y = x1[1];
const pos1z = x1[2];
cube2.position.set(pos1x, pos1y, pos1z);
camera.position.z = 5;
scene.add( cube2);
const animate = () => {
requestAnimationFrame( animate );
controls.update();
renderer.render( scene, camera );
};
但我在显示器上看不到任何东西。我做错了什么?
【问题讨论】:
标签: three.js