how to map latitude and longitude to a 3D Sphere

99封情书 提交于 2019-12-21 02:36:08

问题


Trying to map coordinates with latitude and longitude onto a 3d sphere.

I've tried three different sets of equations from the internet and none of them work. Does anyone know how to do it.

These are the ones I tried that didn't work.

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:


Ah actually this one definitely works!

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);


来源:https://stackoverflow.com/questions/36369734/how-to-map-latitude-and-longitude-to-a-3d-sphere

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!