球面坐标:范围选择 - 最佳实践和方法表现

发布于 2024-10-06 00:06:11 字数 342 浏览 1 评论 0原文

我正在编写一些处理坐标系、几何和其他类似内容的代码。 我想知道一般来说,关于球坐标的常见计算,哪种是存储球坐标的最常见/实用/有效的方法。 是:

theta - [0, 180)
phi - [0, 360)

还是

theta - [-90, 90)
phi - [-180, 180)

其他什么?

(为了清楚起见,上述坐标以弧度表示,但我通常会将它们保留为弧度以提高速度,因为数学函数通常是针对弧度实现的。)

我知道从数学方面来看,这是完全无关的,但我想知道某个选择是否会导致更容易或更有效的实施。

I am writing some code which deals with coordinate systems, geometry and other similar stuff.
I would like to know which is, in general, the most common/practical/efficient way for storing spherical coordinates, regarding common calculations on them.
Is it:

theta - [0, 180)
phi - [0, 360)

or

theta - [-90, 90)
phi - [-180, 180)

or something other?

(The above coordinates are expressed in radians for clarity, but I would normally keep them in radians to improve speed, since math functions are usually implemented for radians.)

I know that from a mathematical aspect, it is completely irrelevant, but I am wondering if a certain choice would result in an easier or more efficient implementation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2024-10-13 00:06:11

一些想法:

  1. 这些表示在数学上确实是等价的。从一种转换为另一种将花费您几次浮点加法,分别为 pi/2 和 pi。与球体几何算术中常见的三角学、逆三角、乘法/除法和平方根计算相比,在通用硬件上进行这些加法的成本相形见绌。

  2. 有大量关于球体几何的算术文本,这些文本是多年来为处理地球导航而开发的。本文经常使用纬度/经度坐标系,分别为-90..+90 和-180..+180。要使用众所周知的公式而不进行转换,您可能需要坚持使用该坐标系。

A couple of thoughts:

  1. The representations are indeed mathematically equivalent. Converting from one to the other will cost you a couple of floating point additions, by pi/2 and pi, respectively. The cost of those additions on common hardware pales in comparison to that of the trigonometry, reverse trig, multiplication/division, and square-root calculations that are common in the arithmetic of sphere geometry.

  2. There is a large body of arithmetic text regarding sphere geometry that was developed over the years for dealing with navigation over the earth. This text often uses the latitude/longitude coordinate system, of -90..+90 and -180..+180, respectively. To use the well known formulas without conversion, you might want to stick with that coordinate system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文