如何将经度和经度映射到3D球体

时间:2016-04-02 05:55:47

标签: 3d three.js coordinates

尝试将坐标与纬度和经度映射到3d球体上。

我从互联网上尝试了三套不同的方程式,但没有一套能够工作。有谁知道怎么做。

这些是我尝试过但没有用的。

var phi   = (90-lat)*(Math.PI/180),
theta = (lon+180)*(Math.PI/180),
x = -((radius) * Math.sin(phi)*Math.cos(theta)),
z = ((radius) * Math.sin(phi)*Math.sin(theta)),
y = ((radius) * Math.cos(phi));

return new THREE.Vector3(x,y,z);


  var height = 600;
  var phi = (lat)*Math.PI/180;
  var theta = (lon-180)*Math.PI/180;

  var x = -(radius+height) * Math.cos(phi) * Math.cos(theta);
  var y = (radius+height) * Math.sin(phi);
  var z = (radius+height) * Math.cos(phi) * Math.sin(theta);

  return new THREE.Vector3(x,y,z);



 var x = Math.cos(lon) * Math.sin(lat),
     y = Math.sin(lon) * Math.sin(lat),
     z = Math.cos(lat);
 return  new THREE.Vector3(x,y,z);

1 个答案:

答案 0 :(得分:3)

实际上,这个确实有效!

var phi   = (90-lat)*(Math.PI/180),
theta = (lon+180)*(Math.PI/180),
x = -((radius) * Math.sin(phi)*Math.cos(theta)),
z = ((radius) * Math.sin(phi)*Math.sin(theta)),
y = ((radius) * Math.cos(phi));

return new THREE.Vector3(x,y,z);