Sphere Packing

Author

Eric W. Weisstein
April 15, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/ComputationalGeometry/SpherePacking.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/SpherePacking.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<<Graphics`Shapes`

Around a Central Sphere

Data from Sloane

s[3,4]:=109.4712206
s[3,5]:=90.0000000
s[3,6]:=90.0000000
s[3,7]:=77.8695421
s[3,8]:=74.8584922
s[3,9]:=70.5287794
s[3,10]:=66.1468220
s[3,11]:=63.4349488
s[3,12]:=63.4349488
s[3,13]:=57.1367031
s[3,14]:=55.6705700
s[3,15]:=53.6578501
s[3,16]:=52.2443957
s[3,17]:=51.0903285
s[3,18]:=49.5566548
s[3,19]:=47.6919141
s[3,20]:=47.4310362
s[3,21]:=45.6132231
s[3,22]:=44.7401612
s[3,23]:=43.7099642
s[3,24]:=43.6907671
s[3,25]:=41.6344612
s[3,26]:=41.0376616
s[3,27]:=40.6776007
s[3,28]:=39.3551436
s[3,29]:=38.7136512
s[3,30]:=38.5971159
s[3,31]:=37.7098291
s[3,32]:=37.4752140
s[3,33]:=36.2545530
s[3,34]:=35.8077844
s[3,35]:=35.3198076
s[3,36]:=35.1897322
s[3,37]:=34.4224080
s[3,38]:=34.2506607
s[3,39]:=33.4890466
s[3,40]:=33.1583563
s[3,41]:=32.7290944
s[3,42]:=32.5063863
s[3,43]:=32.0906244
s[3,44]:=31.9834230
s[3,45]:=31.3230814
s[3,46]:=30.9591635
s[3,47]:=30.7818159
s[3,48]:=30.7627855
s[3,49]:=29.9235851
s[3,50]:=29.7529564
s[3,51]:=29.3684069
s[3,52]:=29.1947579
s[3,53]:=28.8138972
s[3,54]:=28.7169205
s[3,55]:=28.2627914
s[3,56]:=28.1480466
s[3,57]:=27.8266759
s[3,58]:=27.5564159
s[3,59]:=27.3949757
s[3,60]:=27.1928300
s[3,61]:=26.8732779
s[3,62]:=26.6839970
s[3,63]:=26.4869225
s[3,64]:=26.2350433
s[3,65]:=26.0698299
s[3,66]:=25.9474437
s[3,67]:=25.6839813
s[3,68]:=25.4638245
s[3,69]:=25.3336364
s[3,70]:=25.1709200
s[3,71]:=24.9879381
s[3,72]:=24.9264861
s[3,73]:=24.5537792
s[3,74]:=24.4209398
s[3,75]:=24.3017225
s[3,76]:=24.1281944
s[3,77]:=24.0012837
s[3,78]:=23.9310254
s[3,79]:=23.6239917
s[3,80]:=23.5530672
s[3,81]:=23.3476377
s[3,82]:=23.1946074
s[3,83]:=23.0829976
s[3,84]:=23.0517306
s[3,85]:=22.7791621
s[3,86]:=22.6743694
s[3,87]:=22.5466574
s[3,88]:=22.4678810
s[3,89]:=22.3166023
s[3,90]:=22.1540232
s[3,91]:=22.0517963
s[3,92]:=22.0275815
s[3,93]:=21.8103801
s[3,94]:=21.7237135
s[3,95]:=21.5945501
s[3,96]:=21.5206099
s[3,97]:=21.4006197
s[3,98]:=21.3710607
s[3,99]:=21.1359674
s[3,100]:=21.0312020
s[3,101]:=20.9286834
s[3,102]:=20.8556887
s[3,103]:=20.7382700
s[3,104]:=20.6566210
s[3,105]:=20.5388524
s[3,106]:=20.4394089
s[3,107]:=20.3612035
s[3,108]:=20.3044447
s[3,109]:=20.1493196
s[3,110]:=20.1113276
s[3,111]:=19.9824769
s[3,112]:=19.8913044
s[3,113]:=19.8056013
s[3,114]:=19.7450093
s[3,115]:=19.6239931
s[3,116]:=19.5497969
s[3,117]:=19.4612911
s[3,118]:=19.3893497
s[3,119]:=19.3257514
s[3,120]:=19.3240201
s[3,121]:=19.1357298
s[3,122]:=19.0700369
s[3,123]:=19.0063891
s[3,124]:=18.9539116
s[3,125]:=18.8448151
s[3,126]:=18.7815856
s[3,127]:=18.6900568
s[3,128]:=18.6349726
s[3,129]:=18.5634726
s[3,130]:=18.5103522
s[4,5]:=104.4775121
s[4,6]:=90.0000000
s[4,7]:=90.0000000
s[4,8]:=90.0000000
s[4,9]:=80.6761150
s[4,10]:=80.4059318
s[4,11]:=76.6790498
s[4,12]:=75.5224878
s[4,13]:=72.1036706
s[4,14]:=71.3661859
s[4,15]:=69.4519870
s[4,16]:=67.1930021
s[4,17]:=65.6531563
s[4,18]:=64.9872827
s[4,19]:=64.2618766
s[4,20]:=64.2618766
s[4,21]:=61.8760316
s[4,22]:=60.1398863
s[4,23]:=60.0000000
s[4,24]:=60.0000000
s[4,25]:=57.4988826
s[4,26]:=57.2625923
s[4,27]:=56.1106132
s[4,28]:=55.4351398
s[4,29]:=55.0299245
s[4,30]:=54.2511897
s[4,31]:=53.7886221
s[4,32]:=53.4360130
s[4,33]:=53.0759811
s[4,34]:=52.4011334
s[4,35]:=51.5724903
s[4,36]:=51.0745199
s[4,37]:=50.9226685
s[4,38]:=50.1535207
s[4,39]:=49.6895967
s[4,40]:=49.4208547
s[4,41]:=49.0594727
s[4,42]:=48.8204491
s[4,43]:=48.4963928
s[4,44]:=48.0251062
s[4,45]:=47.3961868
s[4,46]:=46.9743371
s[4,47]:=46.7328543
s[4,48]:=46.3832527
s[4,49]:=46.0990591
s[4,50]:=46.0742073
s[4,51]:=45.4625355
s[4,52]:=45.2812081
s[4,53]:=44.9542243
s[4,54]:=44.7883187
s[4,55]:=44.3025299
s[4,56]:=44.0114102
s[4,57]:=43.7495816
s[4,58]:=43.5341667
s[4,59]:=43.3907742
s[4,60]:=43.2167495
s[4,61]:=42.9862214
s[4,62]:=42.7870922
s[4,63]:=42.3770430
s[4,64]:=42.3062196
s[4,65]:=42.0566173
s[4,66]:=41.7550028
s[4,67]:=41.4987735
s[4,68]:=41.3146370
s[4,69]:=41.1813742
s[4,70]:=41.0851193
s[4,71]:=40.8538202
s[4,72]:=40.7098566
s[4,73]:=40.6070686
s[4,74]:=40.5754396
s[4,75]:=40.4865078
s[4,76]:=40.4418535
s[4,77]:=40.0749825
s[4,78]:=39.7568300
s[4,79]:=39.3704881
s[4,80]:=39.1321954
s[4,81]:=38.9404678
s[4,82]:=38.7616584
s[4,83]:=38.6411550
s[4,84]:=38.5216197
s[4,85]:=38.3971687
s[4,86]:=38.2834796
s[4,87]:=38.2316167
s[4,88]:=38.1934424
s[4,89]:=37.9525738
s[4,90]:=37.7779155
s[4,91]:=37.6840939
s[4,92]:=37.6073513
s[4,93]:=37.5288195
s[4,94]:=37.4811292
s[4,95]:=37.1570600
s[4,96]:=37.0622214
s[4,97]:=36.9191853
s[4,98]:=36.7966891
s[4,99]:=36.6983263
s[4,100]:=36.5636318
s[4,101]:=36.4956325
s[4,102]:=36.4186254
s[4,103]:=36.3807276
s[4,104]:=36.2615258
s[4,105]:=36.1859494
s[4,106]:=36.1333759
s[4,107]:=36.0959131
s[4,108]:=36.0509369
s[4,109]:=36.0309659
s[4,110]:=36.0076295
s[4,111]:=36.0013484
s[4,112]:=36.0000058
s[4,113]:=36.0000000
s[4,114]:=36.0000000
s[4,115]:=36.0000000
s[4,116]:=36.0000000
s[4,117]:=36.0000000
s[4,118]:=36.0000000
s[4,119]:=36.0000000
s[4,120]:=36.0000000
s[4,121]:=34.4465422
s[4,122]:=34.2716955
s[4,123]:=34.1743519
s[4,124]:=33.9853008
s[4,125]:=33.8729785
s[4,126]:=33.7679953
s[4,127]:=33.6685430
s[4,128]:=33.5726406
s[4,129]:=33.5033828
s[4,130]:=33.4075174
s[4,600]:=19.8433177
s[5,6]:=101.5369590
s[5,7]:=90.0000000
s[5,8]:=90.0000000
s[5,9]:=90.0000000
s[5,10]:=90.0000000
s[5,11]:=82.3654810
s[5,12]:=81.1451619
s[5,13]:=79.2070847
s[5,14]:=78.4630410
s[5,15]:=78.4630410
s[5,16]:=78.4630410
s[5,17]:=74.3074162
s[5,18]:=74.0080831
s[5,19]:=73.0329080
s[5,20]:=72.5792898
s[5,21]:=71.6441994
s[5,22]:=69.2068599
s[5,23]:=68.2984004
s[5,24]:=68.0230856
s[5,25]:=67.6897899
s[5,26]:=67.0305252
s[5,27]:=66.3175208
s[5,28]:=65.9100901
s[5,29]:=65.7301670
s[5,30]:=65.6046967
s[5,31]:=64.2839257
s[5,32]:=63.7779969
s[5,33]:=62.6125998
s[5,34]:=61.9343521
s[5,35]:=61.4165697
s[5,36]:=61.0530896
s[5,37]:=60.4074688
s[5,38]:=60.2482021
s[5,39]:=60.0017727
s[5,40]:=60.0000000
s[5,41]:=59.0029024
s[5,42]:=58.7856545
s[5,43]:=58.3513041
s[5,44]:=58.1661569
s[5,45]:=57.6514221
s[5,46]:=57.4326036
s[5,47]:=57.1800994
s[5,48]:=56.9676480
s[5,49]:=56.8441582
s[5,50]:=56.8441582
s[5,51]:=56.3071628
s[5,52]:=55.9343732
s[5,53]:=55.4667168
s[5,54]:=55.1747097
s[5,55]:=54.9279561
s[5,56]:=54.7453222
s[5,57]:=54.7356103
s[5,58]:=54.4462372
s[5,59]:=54.0539784
s[5,60]:=53.6051457
s[5,61]:=53.3979587
s[5,62]:=53.2010567
s[5,63]:=52.8751126
s[5,64]:=52.7108774
s[5,65]:=52.5214037
s[5,66]:=52.4752830
s[5,67]:=52.2729583
s[5,68]:=52.0286818
s[5,69]:=51.9176291
s[5,70]:=51.8973507
s[5,71]:=51.8317602
s[5,72]:=51.8317602
s[5,73]:=51.8272924
s[5,74]:=51.8272924
s[5,75]:=51.3428135
s[5,76]:=50.8459281
s[5,77]:=50.4692075
s[5,78]:=50.1905273
s[5,79]:=49.9276863
s[5,80]:=49.6870598
s[5,81]:=49.5416542
s[5,82]:=49.3488655
s[5,83]:=49.0496962
s[5,84]:=48.8819546
s[5,85]:=48.7570741
s[5,86]:=48.6290153
s[5,87]:=48.5000839
s[5,88]:=48.3577476
s[5,89]:=48.2141763
s[5,90]:=48.1896851
s[5,91]:=47.9008875
s[5,92]:=47.7716828
s[5,93]:=47.6364239
s[5,94]:=47.5270717
s[5,95]:=47.4198451
s[5,96]:=47.3535100
s[5,97]:=47.2151568
s[5,98]:=47.1352000
s[5,99]:=46.9889294
s[5,100]:=46.9094506
s[5,101]:=46.7465353
s[5,102]:=46.5719302
s[5,103]:=46.4564803
s[5,104]:=46.3923772
s[5,105]:=46.3118627
s[5,106]:=46.1395418
s[5,107]:=46.0632232
s[5,108]:=45.9430913
s[5,109]:=45.8583450
s[5,110]:=45.7248275
s[5,111]:=45.6276320
s[5,112]:=45.5373551
s[5,113]:=45.4294817
s[5,114]:=45.3304185
s[5,115]:=45.2457325
s[5,116]:=45.1419275
s[5,117]:=45.0181994
s[5,118]:=44.9252672
s[5,119]:=44.8177246
s[5,120]:=44.7301784
s[5,121]:=44.6404435
s[5,122]:=44.5817814
s[5,123]:=44.4453109
s[5,124]:=44.3486865
s[5,125]:=44.2250403
s[5,126]:=44.1807177
s[5,127]:=44.0598726
s[5,128]:=43.9739131
s[5,129]:=43.8672061
s[5,130]:=43.8024944

Computation

Solve[Sin[θ/2]==r/(1+r),r]

s[3,13]

SphereRadii[n_,d_:3]:=1/(Csc[s[d,n]Degree/2]-1)

POVSpherePacking[n_,d_:3]:=Module[{v=ReadList["Phosphine:Math Lists:Spheres:pack."<>ToString[d]<>"."<>ToString[n]<>".txt",{Number,Number,Number}]//Chop,
outfile=OpenWrite["Phosphine:Graphics Files:POVRay:Weisstein:Spheres"<>ToString[n]<>".pov"],
r=1/(Csc[s[d,n]Degree/2]-1)
},
Print[Sqrt[#.#]&/@v];
WriteString[outfile,"#include \"colors.inc\"\n\n","#default {texture {pigment {color Aquamarine transmit .4} finish {phong 0.3 ambient .3}}}\n\n",
"background {color White}\n\n",
"camera {location <5,0,0> right <0,1,0> up <0,0,1> look_at <0,0,0> angle 50}\n\n",
"light_source {<-1,-1.5,-4>}\n",
"light_source {<5,5,-1>color White}\n",
"light_source {<10,-5,-6>color White}\n\n"];
WriteString[outfile,"sphere {<0,0,0>,1 pigment {color Blue}}\n\n"];
WriteString[outfile,"sphere {"<>StringReplace[ToString[#(1+r)],{"{"->"<","}"->">"}]<>", "<>ToString[r]<>"}\n"]&/@v;
Close[outfile]
]

SphereRadii[12]

POVSpherePacking[12]

SphereRadii[13]

POVSpherePacking[13]