
Circle Packing - happy-go-lucky
https://en.wikipedia.org/wiki/Circle_packing
======
heinrichhartman
Sphere packings are quite a deep and fascinating area of pure mathemaics. It
has close relations to coding theory, lattice theory, number theory, modular
forms.

John Conway [1] (who recently passed away due to COVID) wrote a famous book
about it: Sphere Packings, Lattices and Groups -- which summarizes the subject
concisely.

A recent (2017) break through, was the proof that the Leech Lattice [2] yields
the optimal sphere packing in dimension 24 [3]. The error correcting code
constructed from this lattice is the Binary Golay Error Correcting Code [4].
It is able to correct 3 bits for every 24 bits, and maximally efficient in
doing so. It was used to communicate with the Voyager probes.

[1]
[https://en.wikipedia.org/wiki/John_Horton_Conway](https://en.wikipedia.org/wiki/John_Horton_Conway)
[2]
[https://en.wikipedia.org/wiki/Leech_lattice](https://en.wikipedia.org/wiki/Leech_lattice)
[3]
[https://arxiv.org/pdf/1603.06518.pdf](https://arxiv.org/pdf/1603.06518.pdf)
[4]
[https://en.wikipedia.org/wiki/Binary_Golay_code](https://en.wikipedia.org/wiki/Binary_Golay_code)

~~~
jedimastert
I didn't realize he died from COVID complications. That just makes it all the
worse.

~~~
jon_elbrook
He was 82.

~~~
taylorlunt
He was also a human being and he died.

------
dekhn
I once took a class from Huffman (one of the inventors of compression) and the
very first class he talked about error correcting codes, and I remember him
saying (25 years ago!) "Sphere packing is hard... except in 8 dimensions!"
([https://en.wikipedia.org/wiki/Kissing_number](https://en.wikipedia.org/wiki/Kissing_number))

I failed the class, but learned so many useful things.

------
julien__c
I recently saw pictures of social distancing circles drawn on the grass in
parks [1]. They were drawn in a square grid. It would be more space-efficient
to draw them in a hexagonal packing arrangement.

[1] example:
[https://images.foxtv.com/static.ktvu.com/www.ktvu.com/conten...](https://images.foxtv.com/static.ktvu.com/www.ktvu.com/content/uploads/2020/05/724/407/A79C558C64154B59A31E5D70963CFB76.jpg?ve=1&tl=1)

~~~
skrebbel
I don't think space efficiency is a goal

~~~
jakear
Indeed. Having lots of space between the circles is a better goal, as that way
people in motion also maintain distance.

~~~
jka
Circular markers could also be a lot easier to create repeatably and quickly
(for example, using a pole and string) by staff responsible for creating
distancing markers.

------
cbisnett
I was surprised to see the Wikipedia page didn’t mention any best-effort
algorithms but I guess they can’t list everything.

I like the natural noise you get from Poisson Disc Sampling [1]

[1]
[https://bl.ocks.org/mbostock/dbb02448b0f93e4c82c3](https://bl.ocks.org/mbostock/dbb02448b0f93e4c82c3)

~~~
BubRoss
Poisson disc sampling is a brute force technique and isn't an analytic method
for packing. Any sample pattern can be relaxed if you are finding neighbor
points and using multiple iterations. Poisson sampling is just trying and
rejecting many samples based on their neighbors' distances, there aren't any
deep principles being used.

It is a lot like a bubble sort in that it is O(n^2) and is useful in practice
on tiny sets and as a benchmark.

(Also that link is very cool, but it looks closer to n-rooks / latin hypercube
sampling in that it used a grid, which means it won't work in higher
dimensions)

------
dan-robertson
See also
[https://www2.stetson.edu/~efriedma/maxmin/](https://www2.stetson.edu/~efriedma/maxmin/)

------
hyperpower
I wrote about sphere packings and their relation to lattices here:
[https://nullset.xyz/2016/12/11/lattices-and-sphere-
packings/](https://nullset.xyz/2016/12/11/lattices-and-sphere-packings/)

------
simonw
Saw a beautiful example of this in action the other day in the Observable
"cherry logo" notebook: [https://observablehq.com/@observablehq/cheery-
logo](https://observablehq.com/@observablehq/cheery-logo)

------
jhoechtl
Circle packing is one of my favorite applications to display hierarchical data
where one dimension defines the radius, like the file size. Other dimensions
may alter color or line width.

Circle packing is available as an example in D3, highly recommended.

[https://observablehq.com/@d3/zoomable-circle-
packing](https://observablehq.com/@d3/zoomable-circle-packing)

~~~
tomlagier
I made a tool that does this with Chrome memory profiles

[https://heapviz.com/](https://heapviz.com/)

Also ported d3s circle packing algorithm to C++ for compilation to WASM

[https://github.com/tomlagier/circle-
pack](https://github.com/tomlagier/circle-pack)

Definitely love how that visualization turns out!

------
jhardcastle
This is important now as schools are working to figure out how to place desks
so that each student is 6 feet apart from their peers.

------
iamthepieman
I always see circle packing using ideal circles(or other shapes) inside
another ideal shape. It's my understanding that packing arbitrary shapes
inside other shape(even an ideal one) or the reverse, packing ideal shapes
inside an arbitrary shape, is NP hard. My limited research and experimentation
proves this out but my work has been in the context of getting things done and
not research or algorithm design.

Double packing, packing shapes inside shapes inside shapes is O(N^k) as far as
I can tell.

