DISCLAIMER
  I plan to write this all in C, but I started in octave due to the
  built in graphing capabilities, which made it easier to see how
  things were working and easier to debug different parts of my
  algorithm.  Since it's in octave, there are some pretty ugly choices
  for data structures (everything is a matrix, after all).  Also, the
  given code doesn't represent all of my ideas (-- yet?).

INSTRUCTIONS TO USE
  1) Make sure octave is installed (should come with any linux distro)
  2) Run either of the scripts arrangeIcons or arrangeRandomIcons
       (Don't worry--neither makes a real change to your desktop)
  3) Twiddle with the constants in get_constants.m, if you like
       (especially the values of xm, nrows, and ncols)

  If you really want your icons arranged, move the
    here_are_some_new_icon_positions.xml
  file (created by the arrangeIcons.m script) to
    $HOME/.nautilus/metafiles/*.gnome-desktop.xml
  and then log back in.

ADVANTAGES of my algorithm
  If icons are already pre-arranged into something close to a grid,
    this is detected and icons are straightened up
  Leftmost columns do not have to be completely filled before ones to
    the right get icons (this really bugged me about the last version
    of Windows that I used--don't know if it's still a problem on that
    platform)

DISADVANTAGES (Possibly inherent problems) of my algorithm
  'Visually slanted columns' as input--I arrange into columns based on
    x-coordinate only
  Non-uniform icon (including text) sizes may not look visually
    appealing when put on a uniform grid (of course, a non-uniform
    grid may be unappealing anyway--there's at least one bug filed
    about this)

SHORTCOMINGS of my current implementation (Should not be difficult to fix...)
  Negative icon locations (to mean relative to bottom or right boundaries)
  Non-uniform icon sizes (I can't determine icon sizes so I hard code them
    right now; but these are used because grid locations should be
    relative to centers of icons)
  Icons in columns that are too full are moved to the right (with
    wraparound at the right edge) This is sub-optimal, but was easy to
    implement as a first pass

RELEVANT BUGZILLA BUGS
  41670 (Closed) Certain Icons should have standard positions
  41671          Desktop lacks 'Auto Arrange Icons'
  45953          Contains comments (near end) about standard positions for icons
  47943          Icons can be left off the screen if screen size is changed
  74927 (Closed) Trash Icon should be in the lower right corner
  88649          Desktop icon locations--relative to right or bottom sides
  96704          Icons are not vertically aligned by their center
  97597          Icons are not horizontally aligned by their center (screenshot)

  Another bug which hasn't been filed:
    "Clean Up By Name" should be "Arrange Icons By Name"

  Also see: ("Must fix" for GNOME2)
    http://developer.gnome.org/projects/gup/proposals/nautilus.html

IDEA of my algorithm

  1) Find columns into which the icons naturally fit
    a) graphical--make a function whose height is the sum of some
       local "nearness to icon" or "influence" function
    b) maxima of this function define separate columns
      b-note) In pathological cases, some maxima need to be merged
    c) icons become part of nearest column
  2) Loop through columns, sorting them by vertical position and
     assigning separate rows to each icon
  3) Wrap icons beyond a given row (i.e. that are off screen) to
     subsequent columns
  4) Assign icons a new position based on row and column number

OTHER NOTES
  There were some sticky points in the algorithm.  Some of these
  resulted in what may look like strange choices, such as the division
  by (xm+.5) in the influence function (instead of just dividing by
  xm), and the fact that I define the function at each integer plus
  the midpoints between integers (instead of just at each integer).
  These solve specific issues that arose in testing this code that are
  actually downfalls of the algorithm itself when left unchanged.
