Convert Latitude and Longitude to point in 3D space

前端 未结 3 1565
情深已故
情深已故 2020-12-04 20:14

I need to convert latitude and longitude values to a point in the 3-dimensional space. I\'ve been trying this for about 2 hours now, but I do not get the correct results.

3条回答
  •  执念已碎
    2020-12-04 20:57

    you're not doing what wikipedia suggests. read it again carefully.

    they say:

    x = r cos(phi) sin(theta)
    y = r sin(phi) sin(theta)
    z = r cos(theta)
    

    and then:

    theta == latitude
    phi == longitude
    

    and, in your case, r = radius + altitude

    so you should be using:

    r = radius + altitude
    x = r cos(long) sin(lat)
    y = r sin(long) sin(lat)
    z = r cos(lat)
    

    note that the final entry is cos(lat) (you are using longitude).

提交回复
热议问题