坐标到纬度和经度

坐标到纬度和经度

本文介绍了球体上的 3D 坐标到纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下信息:

存在一个原点为 (0,0,0) 且半径为 R 的球体.进行射线-球体相交后,我知道球体上 3D 空间中的一个点 (XYZ)(3D 空间中直线穿过球体外壳的确切位置).

对于我的程序,我想计算球体上 XYZ 点的纬度和经度,但我想不出(或谷歌)轻松地做到这一点.

简而言之,我要编写的函数是这样的:

public static LatLon FromVector3(Vector3 position, float sphereRadius){返回纬度和经度}

有人知道怎么做吗?作为参考,此 Wiki SVG 文件可能会有所帮助:

更新:

感谢所有有用的答案,所以最后我使用了这段代码:

 public static LatLon FromVector3(Vector3 position, float sphereRadius){float lat = (float)Math.Acos(position.Y/sphereRadius);//θfloat lon = (float)Math.Atan(position.X/position.Z);//phi返回新的纬度(纬度,经度);}

现在我必须考虑哪个答案最能帮助我接受:P.

解决方案

我想从 x,y,z(3d 坐标系)中找到球面极坐标应该不难.

  1. r 如果它在表面上,则始终保持不变.

  2. (90 - θ) 你的纬度(负表示它在底部),因为它是从顶部测量的.>

  3. φ 是您的经度.(但不太确定经度系统)

另请查看维基百科中的图表.

I've got the following information:

There exists a sphere with origin (0,0,0) and radius R.After doing a ray-sphere intersection I know a point (XYZ) in 3D space that is on the sphere (the exact position in 3D space where the line pierces the sphere hull).

For my program I'd like to calculate the Latitude and Longitude of the XYZ point on the sphere, but I can't think (or Google) up a way to do this easily.

So in short, the function that I'm trying to write is this:

public static LatLon FromVector3(Vector3 position, float sphereRadius)
{
    return Latitude and Longitude
}

Does anybody know how to do this? As a reference this Wiki SVG file might be helpful:

Update:

Thanks for all the helpful answers, so in the end I went with this code:

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

Now I've got to think of which answer helped me the most to accept :P.

解决方案

I guess it should not be difficult to find the spherical polar coordinates from x,y,z (3d-coordinate system).

  1. r is always constant if it's on surface.

  2. (90 - θ) your latitude (negative means it's on the bottom) as it's measured from top.

  3. φ is your longitude. (but not quite sure about longitude system)

Also check this diagram from wikipedia.

这篇关于球体上的 3D 坐标到纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 16:35