在 3d 物体上找到 2 个点并获取它们的距离
好的。所以我想事情会是设想纽约市和北京在谷歌地球上突出显示...
我试图弄清楚如何将点映射到 3d 原始对象(球体)上,通过圆周的任何方向获取它们的距离,以及它们的直径距离。这些点将是纬度和经度坐标。
现在,这就是我试图用来映射坐标的方法(与代码无关的版本):
x1 = radius * cos(long1) * cos(lat1);
y1 = radius * sin(long1) * cos(lat1);
z1 = radius * sin(lat1);
但我几乎确定它是错误的。我怎样才能获得每个点的位置并计算它们直接穿过球体直径的距离以及它们绕球体圆周的距离?
谢谢。
Ok. So I guess thing would to be envision new york city and beijing highlighted on google earth...
I'm trying to figure out how to map points onto a 3d primitive object (a sphere), get their distance via any direction by the circumference, and their distance by diameter. The points are going to be latitude and longitude coordinates.
Right now, this is what i'm trying to use to map the coordinates (a code agnostic version):
x1 = radius * cos(long1) * cos(lat1);
y1 = radius * sin(long1) * cos(lat1);
z1 = radius * sin(lat1);
but i'm almost sure its wrong. How could I get each points position and calculate their distances straight across the sphere's diameter and also their distance going around the circumference of the sphere?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你实际上很接近。要获得直线距离,您只需执行以下操作:
sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
对于围绕大圆的距离,请记住它是圆周率直径角。从地球中心到两点的向量的点积就是角度的余弦。所以,你得到:
pidiamacos((x1*x2 + y1*y2 + z1*z1)/diam^2)
当然,如果你绕地球走另一条路,还有第二个距离,但为此你只需要 2*pi - acos(...)。
You're actually pretty close. To get the straight line distance, you simply need to do:
sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
For the distance around the great circle, remember that it is pidiamangle. The dot product of the vectors from the center of the earth to the two points is the cosine of the angle. So, you get:
pidiamacos((x1*x2 + y1*y2 + z1*z1)/diam^2)
of course there's a 2nd distance if you go the other way around the earth, but for that you just need 2*pi - acos(...).