均匀地分布在一个球体n个点 [英] Evenly distributing n points on a sphere

查看:200
本文介绍了均匀地分布在一个球体n个点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己不堪重负的信息,我仍然没有能够找到我在寻找什么,至少在一个格式,我可以转换为我的用途。

I find myself overwhelmed with information, and I still haven't been able to find exactly what I'm looking for, at least not in a format I can convert for my uses.

我需要的是一种算法,可以给我周围的球体位置的N个点(低于20,可能)隐约US $ p $垫出来。没有必要对完美,但我只需要它,这样他们都不皱在一起。

What I need is an algorithm that can give me positions around a sphere for N points (less than 20, probably) that vaguely spreads them out. There's no need for "perfection", but I just need it so none of them are bunched together.

  • 提供了良好的code,但我无法找到一个方法这个问题使这个统一的,因为这似乎是100%随机的。
  • 本博客文章建议有两种方式,允许在球体点数的投入,但<一个HREF =htt​​p://sitemason.vanderbilt.edu/page/hmbADS>孔雀皇和Kuijlaars 算法,正是在伪code,我可以录制,和的 code例如我发现载节点[K],我看不出解释,并破坏了这种可能性。第二个博客的例子是黄金分割螺旋,这给了我奇怪,揉成业绩,来定义一个恒定的半径没有明确的方法。
  • 这种算法从<一个href="http://stackoverflow.com/questions/1841014/uniform-random-monte-carlo-distribution-on-unit-sphere">this问题好像它可能工作,但我不能拼凑那是什么网页上成伪code或任何东西。
  • This question provided good code, but I couldn't find a way to make this uniform, as this seemed 100% randomized.
  • This blog post recommended had two ways allowing input of number of points on the sphere, but the Saff and Kuijlaars algorithm is exactly in psuedocode I could transcribe, and the code example I found contained "node[k]", which I couldn't see explained and ruined that possibility. The second blog example was the Golden Section Spiral, which gave me strange, bunched up results, with no clear way to define a constant radius.
  • This algorithm from this question seems like it could possibly work, but I can't piece together what's on that page into psuedocode or anything.

我来了一些其他问题,跨线程随机交谈均匀分布,这增加了复杂程度,我不关心。我很抱歉,这是这么愚蠢的问题,但我想证明我真的很难看,仍然短上来了。

A few other question threads I came across spoke of randomized uniform distribution, which adds a level of complexity I'm not concerned about. I apologize that this is such a silly question, but I wanted to show that I've truly looked hard and still come up short.

所以,我正在寻找的是简单的伪code均匀分布各地的单位球面N个点,要么回报球形或笛卡尔坐标。更妙的是,如果它可以用随机位,甚至分布(认为恒星周围的行星,体面s ^ $ P $垫出来,但与空间的回旋余地)。

So, what I'm looking for is simple psuedocode to evenly distribute N points around a unit sphere, that either returns in spherical or Cartesian coordinates. Even better if it can even distribute with a bit of randomization (think planets around a star, decently spread out, but with room for leeway).

感谢这么多的人谁可以帮助,对不起文本墙。

Thanks so much to anyone who can help, and sorry for the wall of text.

推荐答案

这个例子code < /一> 节点[K] 仅仅是第k个节点。您生成一个数组N点和节点[K] 是第k个(从0到N-1)。如果这是所有困惑你,希望你现在可以使用。

In this example code node[k] is just the kth node. You are generating an array N points and node[k] is the kth (from 0 to N-1). If that is all that is confusing you, hopefully you can use that now.

(换句话说, K 是大小为N即是code片段开始之前定义的数组,其中包含点的列表)。

(in other words, k is an array of size N that is defined before the code fragment starts, and which contains a list of the points).

或者的,这里的其他答案构建(及使用Python):

Alternatively, building on the other answer here (and using Python):

> cat ll.py
from math import asin
nx = 4; ny = 5
for x in range(nx):
    lon = 360 * ((x+0.5) / nx)
    for y in range(ny):                                                         
        midpt = (y+0.5) / ny                                                    
        lat = 180 * asin(2*((y+0.5)/ny-0.5))                                    
        print lon,lat                                                           
> python2.7 ll.py                                                      
45.0 -166.91313924                                                              
45.0 -74.0730322921                                                             
45.0 0.0                                                                        
45.0 74.0730322921                                                              
45.0 166.91313924                                                               
135.0 -166.91313924                                                             
135.0 -74.0730322921                                                            
135.0 0.0                                                                       
135.0 74.0730322921                                                             
135.0 166.91313924                                                              
225.0 -166.91313924                                                             
225.0 -74.0730322921                                                            
225.0 0.0                                                                       
225.0 74.0730322921                                                             
225.0 166.91313924
315.0 -166.91313924
315.0 -74.0730322921
315.0 0.0
315.0 74.0730322921
315.0 166.91313924

如果您绘制的是,你会看到的垂直间距为两极,使每个点位于大约相同的总的区域附近较大的空间(两极附近有更少的空间水平,因此它提供了更多的纵向)。

If you plot that, you'll see that the vertical spacing is larger near the poles so that each point is situated in about the same total area of space (near the poles there's less space "horizontally", so it gives more "vertically").

这是不一样的有关于他们的邻居同样的距离(这是我想你的链接被谈论),但它可能是足以让你想要的所有的点,提高了对简单地做一个统一的土地增值税/ LON网格。

This isn't the same as all points having about the same distance to their neighbours (which is what I think your links are talking about), but it may be sufficient for what you want and improves on simply making a uniform lat/lon grid.

这篇关于均匀地分布在一个球体n个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆