经度和纬度上的球体上的三维坐标

经度和纬度上的球体上的三维坐标

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

问题描述

我得到以下信息:

存在一个带有原点(0,0,0)和半径为R的球体。
做完一个ray-sphere intersection我知道三维空间中一个点(XYZ)在球体上(三维空间中线穿透球体的确切位置)。

对于我的程序,我想计算球体上XYZ点的纬度和经度,但我不认为(或Google)可以轻松完成此操作。



所以简而言之,我试图写的函数是这样的:

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






此外,我发现这从经度和纬度转换回XYZ,这可能也有帮助:。




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:

Also I found this to convert back from latitude and longitude to XYZ, that might also be helpful: http://swardsonstudios.com/?p=65

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.

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

08-29 01:41