I was accidentally trying to do test-driven development (which I realized by accident; I wasn't writing real "tests", more just printing the values before writing the code that calculates them and then writing the code and running it between) and I think I've written a morass of code.
To top it off, I'm starting to think I placed the wrong information in the data structures to begin with. Currently, I'm only figuring centroids when the object is created.
A better way to do this would be to set up a cache of calculations, figure out some quick way to test whether they'd changed at all, and then recalculate everything upon use of the apply method if anything changed. I'm not smart enough to figure out how to do that just yet, but I'm working on it.
I guess the problem isn't that the code doesn't work -- it's that it's ugly as sin. It has no idioms to speak of, and where it does they reduce readability.
I'm going to try to fix the unprettiness once I get home. I just can't write more code in this and keep it straight in my head. In the meantime, I'll try to work out what process is needed to calculate the final product and diagram it, since I can't seem to write it in Perl.
Since I'm a dipshit, I set up a wiki clone (chiq-chaq, to be specific) and I use it primarily as an enormous scratchpad. Easy to use as a bookmarking system, easy to use as a content creator, etc., and with more formatting and style options than, say, Notepad, or Hotmail. Handiness.