Up
Next
packer - a ball packer
packer [options] [ball_rad [container_rad [inner_rad]]]
Pack balls in a sphere, or between two concentric spheres. The pack is
seeded with two or more balls, then subsequent balls are added one at a
time in three point contact in positions chosen by the packing method
until no more balls may be added.
- ball_rad
- ball radius
- container_rad
- spherical container radius (default: 1)
- inner_rad
- inner spherical container radius (default: no inner container)
- -h
- program help
- -m <mthd>
- packing method
- up - bottom up (default)
- in - outside to centre
- out - centre to outside
- inup - outside in bottom
- outup - centre to outside bottom first.
- around - nearest to x=0 rotating around y-axis
- laround - nearest to last ball rotating around y-axis
- earlist - touching earliest placed ball
- -l
- alway pack each ball in contact with last placed ball
- -n <num>
- maximum number of balls to pack (default:pack all)
- -a <num>
- maximum number of balls to add to pack, repecting -N (default:pack all)
- -M
- use centre of mass for methods using a centre
- -i <file>
- input file containing coordinates of the seed balls
- -f
- frames, write output file of the form ./packer_out_0052.off
(the number is the number of balls) every time a ball is added
- -o <file>
- write output to file, if this option is not used
the program writes to standard output
Pack unit radius balls in a 5 unit radius sphere, pack nearest to the
centre, use the default seed for this method (a central ball
and two other balls all mutually in contact), write output to pk.off.
packer -m out -o pk.off 1 5
Here is a short Python script as a demonstration of how to make images
of the frames created with the -f option using
POV-ray.
import os
import glob
i=0
for off_file in glob.glob('./packer_out_[0-9][0-9][0-9][0-9].off'):
pov_file = "panim_%04d.pov" % i
os.system("off2pov -v b -x ef -D 10.5 -C 0,0,0 -R 25,10,0 -o %s %s" %(pov_file, off_file))
os.system("povray +a %s" % pov_file)
i +=1
These could be combined into a GIF animation using the
ImageMagick
convert program.
convert panim*.png pack_anim.gif
Up:
Programs and Documentation
Next:
string_art - string figures
Antiprism Documentation 15.6.2005 -
http://www.antiprism.com/