Live data from Hacker News

Fibonacci Sphere

extremelearning.com.au

21–30 of 37 posts

Re: Fibonacci Sphere

#21

One neat trick I’ve learned is that you can use the points on a Fibonacci sphere to optimally compress unit vectors, for things like normal textures. For example, if you have an array of 1024 points representing a Fibonacci sphere, you can compress unit vectors into lg(1024)=10 bits with a nearest neighbor search and decompress with an O(1) table lookup. In fact, the general strategy works for higher dimensions as we…

What you're saying sounds promising but I have no idea how to implement it - any articles about it that contain algorithms?

Here's some Python pseudocode to get you started:

  import math
  
  def fibonacci_sphere_point(idx, num_points):
    i = idx + 0.5
    phi = math.acos(1 - 2 * i / num_points)
    golden_ratio = (1 + 5 ** 0.5) / 2
    theta = 2 * math.pi * i / golden_ratio
    sin_phi = math.sin(phi)
    cos_phi = math.cos(phi)
    sin_theta = math.sin(theta)
    cos_theta = math.cos(theta)
    return (
      cos_theta * sin_phi,
      sin_theta * sin_phi,
      cos_phi,
    )
  
  table = [fibonacci_sphere_point(i, 1024) for i in range(1024)]

  def sqr_dist(a, b):
    return (a[0]-b[0])**2 + (a[1]-b[1])**2 + (a[2]-b[2])**2

  def decode(value):
    return table[value]

  def encode(point):
    closest_idx = 0
    closest_dist2 = sqr_dist(point, table[closest_idx])
    for i in range(1, len(table)):
      curr_dist2 = sqr_dist(point, table[i])
      if closest_dist2 > curr_dist2:
        closest_dist2 = curr_dist2
        closest_idx = i
    return closest_idx

Re: Fibonacci Sphere

#22

Author here. Happy to try to answer any questions! ;)

Super cool stuff! Thanks for the article. I was wondering if someone had an opinion on an adjacent idea. I've had Nash's infinitely collapsible sphere stuck in my head for some time: https://www.quantamagazine.org/mathematicians-identify-thres... For purposes of nearest neighbors this seems like an incredibly interesting shape to inscribe into: The sphere, despite having spherical properties also maintains linear pro…

I don't have any intelligent comments on your question, but I wanted to say that I am a fan of Quanta magazine, but somehow had missed this really cool article. So thanks for pointing me to this fascinating field. ;)

Re: Fibonacci Sphere

#23
post #3

Author here. Happy to try to answer any questions! ;)

This link - http://neilsloane.com/packings/index.html#I - has dead URLs. Like this - http://www.teleport.com/~tpgettys/dodeca.gif . I specifically wanted to check where the dodecahedron comes short. Good article, but it'll take some time to understand it. %1 is interesting, I used to use {..} for taking fractional part, %1 is intuitively easy, though not looking particularly good...

https://web.archive.org/web/20000506214514/http://www.telepo...

Re: Fibonacci Sphere

#24

Earlier quoted context omitted.

I would expect the energy minimization approach to perform better than anything else, for vectors distributed uniformly on the surface of the N-sphere. Why go with the Fibonacci sphere instead?

The Fibonacci sphere arrangement has the advantage that the point coordinates can be computed from a function, so you don't even need a lookup table to decode: def fibonacci_sphere_point(idx, num_points): i = idx + 0.5 phi = math.acos(1 - 2 * i / num_points) golden_ratio = (1 + 5 ** 0.5) / 2 theta = 2 * math.pi * i / golden_ratio sin_phi = math.sin(phi) cos_phi = math.cos(phi) sin_theta = math.sin(theta) cos_theta =…

Ahh, I get it, neat.

Re: Fibonacci Sphere

#25

One neat trick I’ve learned is that you can use the points on a Fibonacci sphere to optimally compress unit vectors, for things like normal textures. For example, if you have an array of 1024 points representing a Fibonacci sphere, you can compress unit vectors into lg(1024)=10 bits with a nearest neighbor search and decompress with an O(1) table lookup. In fact, the general strategy works for higher dimensions as we…

I used a similar method of quantizing normal vectors, but I settled for 240 of them, so one byte per normal. It was based on IIRC using a dodecahedron, split faces into triangles, then split those each into 4. Then use the face normals. I dont recall it being as complicated as it sounds, but it does work rather nicely. I could precompute view dependent shading for each normal once per frame and then use the normal index as a color index instead. CPU implementation.

Re: Fibonacci Sphere

#26

Earlier quoted context omitted.

I would expect the energy minimization approach to perform better than anything else, for vectors distributed uniformly on the surface of the N-sphere. Why go with the Fibonacci sphere instead?

One reason/situation where the Fibonacci method is preferred is because it is a direct construction method, which can be coded in a few lines, rather than an indirect iterative method. The second is that because an energy minmization method is minimizing the sum of forces, it more closely minimizes average distance between points, rather than absolute minimum distance which is what packing distance focuses on. As I d…

One advantage is that you can use arbitrary N.

If you just want N in a certain range, we can use the triangle-based polyhedron and successively quadruple or triple the number of faces. Then use the face normals as points. This gives visually appealing distributions without any real oddities.

Re: Fibonacci Sphere

#27
post #3

Author here. Happy to try to answer any questions! ;)

This link - http://neilsloane.com/packings/index.html#I - has dead URLs. Like this - http://www.teleport.com/~tpgettys/dodeca.gif . I specifically wanted to check where the dodecahedron comes short. Good article, but it'll take some time to understand it. %1 is interesting, I used to use {..} for taking fractional part, %1 is intuitively easy, though not looking particularly good...

You are right. In mathematics, the traditional notation {x} represents the fractional part of x.

Regarding the two-variable function mod(x,b). Typically this is written as x (mod b) in maths, and as x%b in computing.

It is generally well known that for positive integers x and b, the output of this function is the remainder when x is divided by b.

However, what is less well-known is that if b=1, then the convention is that:

x (mod 1) = x%1 = fractional part of x.

For example, Python, Excel both implement this special convention.

Re: Fibonacci Sphere

#28
post #23
post #3

Earlier quoted context omitted.

This link - http://neilsloane.com/packings/index.html#I - has dead URLs. Like this - http://www.teleport.com/~tpgettys/dodeca.gif . I specifically wanted to check where the dodecahedron comes short. Good article, but it'll take some time to understand it. %1 is interesting, I used to use {..} for taking fractional part, %1 is intuitively easy, though not looking particularly good...

https://web.archive.org/web/20000506214514/http://www.telepo...

I know what dodecahedron is, I wanted to see the corresponding (by the number of vertices) maximally-separated polyhedron.

Re: Fibonacci Sphere

#29
Quite cool how the author picks a topic, explains it well, and on top of that presents some novel results. He did this before with his article on minimum-discrepancy sequences, which is one of my favourite results in math.
Post reply on HN