更新时间:2023-02-01 23:04:18
将其留在此处,以防将来有人需要它:
Leaving this here in case anyone needs it in the future:
如果仅需要最小距离,则不必强行使用所有对.有一些数据结构可以帮助您解决O(n * log(n))时间复杂性的问题,这比bruteforce方法要快得多.
If you need only the minimum distance, then you don't have to bruteforce all the pairs. There are some data structures that can help you solve this in O(n*log(n)) time complexity, which is way faster than the bruteforce method.
例如,您可以使用广义KNearestNeighbors(k = 1)算法来精确地做到这一点,因为您要注意点在球面上而不是在平面上.有关使用sklearn的示例实现,请参见此SO答案.
For example, you can use a generalized KNearestNeighbors (with k=1) algorithm to do exactly that, given that you pay attention to your points being on a sphere, not a plane. See this SO answer for an example implementation using sklearn.
似乎也有一些库可以解决此问题,例如 sknni 和 GriSPy .
There seems to be a few libraries to solve this too, like sknni and GriSPy.
这里也是另一个问题,关于理论的一点点.
Here's also another question that talks a bit about the theory.