It's important to give back, so for any other non-math-genius programmers, here is the code, highly commented. I won't bother you to help me any further, but if yer bored/interested in glancing at the comments, maybe you can tell me if my terminology or description of what's going on is...