我有以下信息:
存在一个具有原点(0,0,0)和半径R的球体.在进行射线球体交叉后,我知道球体上的三维空间中的一个点(XYZ)(三维空间中线条穿透的确切位置)球体船体).
对于我的程序,我想计算球体上XYZ点的纬度和经度,但我不能想(或谷歌)一种方法来轻松地做到这一点.
简而言之,我正在尝试编写的函数是:
public static LatLon FromVector3(Vector3 position, float sphereRadius)
{
return Latitude and Longitude
}
Run Code Online (Sandbox Code Playgroud)
有人知道怎么做这个吗?作为参考,这个Wiki SVG文件可能会有所帮助:

更新:
感谢所有有用的答案,所以最后我使用了这段代码:
public static LatLon FromVector3(Vector3 position, float sphereRadius)
{
float lat = (float)Math.Acos(position.Y / sphereRadius); //theta
float lon = (float)Math.Atan(position.X / position.Z); //phi
return new LatLon(lat, lon);
}
Run Code Online (Sandbox Code Playgroud)
现在我必须考虑哪个答案对我有最大的帮助:P.