On Mar 13, 2010, at 8:15 AM, Jerome David Sallinger wrote:
> This question may be more to do with my understanding of OOP that the
> actual contructs of Ruby so please be patient with me.

Actually I think your question isn't really about OOP or Ruby at
all but instead is just an algorithm question related to
computer graphics or even a more general question about
combinations of things.

To bring this back to Ruby. If you have a collection of
objects and you want to consider all possible combinations
of two objects:

irb> collection =  [1,2,3,4]
=> [1, 2, 3, 4]
irb> collection.combination(2).to_a
=> [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]
irb> collection.combination(2).select { |a,b| (a-b).abs == 1 }
=> [[1, 2], [2, 3], [3, 4]]

I just showed selecting pairs based on a simple mathematical
criteria but the collection could have been your balls, and
the selection could have utilized your #intersect? method.

Note, you have to be using Ruby 1.8.7 or 1.9.X to have
the combination method.

Gary