That is the same as saying that in the limit of large N I want a little region R ∈ ( r, r + d r), Θ ∈ ( θ, θ + d θ) to contain a number of points proportional to its area, which is r d r d θ. Well, I am using the square root here because I want these to have even-area spacing around the disk. The key strange thing is the formula r = sqrt(indices / num_pts) how did I come to that one? (Note 2.) Indices = arange(0, num_pts, dtype=float) + 0.5Īnd it produces results that look like (n=100 and n=1000): The algorithm for even spacing on a disk is, from numpy import pi, cos, sin, sqrt, arange This is based on the fact that the most irrational number is the golden ratio (1 + sqrt(5))/2 and if one emits points by the approach “stand at the center, turn a golden ratio of whole turns, then emit another point in that direction,” one naturally constructs a spiral which, as you get to higher and higher numbers of points, nevertheless refuses to have well-defined ‘bars’ that the points line up on. To understand this algorithm, I first invite you to look at the 2D sunflower spiral algorithm. Primer: sunflower spirals on the unit disk at but it just has a nice and pretty look as well as a guarantee about even spacing in the limit. So here’s a fast, non-random way to create a lattice that is approximately correct as discussed above, no lattice will be perfect, but this may be good enough. I would like to give you a complete understanding of it so that maybe you can understand how to keep this away from being “bunched up.” You said you couldn’t get the golden spiral method to work and that’s a shame because it’s really, really good. 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). So, what I'm looking for is simple pseudocode to evenly distribute N points around a unit sphere, that either returns in spherical or Cartesian coordinates. 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. 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.Ī few other question threads I came across spoke of randomized uniform distribution, which adds a level of complexity I'm not concerned about.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 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", which I couldn't see explained and ruined that possibility. This question provided good code, but I couldn't find a way to make this uniform, as this seemed 100% randomized.There's no need for "perfection", but I just need it so none of them are bunched together. Also,with MATLAB 1e–16 is the smallest precision (not number) possible i.e.I need an algorithm that can give me positions around a sphere for N points (less than 20, probably) that vaguely spreads them out.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |