0
我使用此代碼將lonlat轉換爲x,y,z,但無法弄清楚如何做相反的事情。將lonlat轉換爲xyz,反之亦然
var phi = (this.lat)*Math.PI/180;
var theta = (this.lon-180)*Math.PI/180;
x = -(this.R) * Math.cos(phi) * Math.cos(theta);
y = -(this.R) * Math.sin(phi);
z = (this.R) * Math.cos(phi) * Math.sin(theta);
現在從X,Y轉換,Z向lonlat
lat = THREE.Math.radToDeg(Math.asin(rotation.y/this.R));
lon = THREE.Math.radToDeg(Math.atan2(rotation.z, rotation.x));
但是,這並不正常工作,我究竟做錯了什麼?
我用這個爲XYZ座標平移旋轉,然後使用我以前的公式來獲得lonlat var xyz = new THREE.Vector3(0,0,0); this.camera.getWorldDirection(xyz);' 但是,感謝您的幫助! – Noripsni