Bounded-Sum 0, Grid Math 0, Trigonometry 0, Nature 0, Me 4

chaoticset on 2003-05-29T02:11:36

Okay -- bounded-sum GROKKED. El Groko. I Understand. It's worth my Life and my Soul, blah blah blah, I get it.

So, the major conceptual hurdle is down.

Next, I need to calculate the intersection of two lines. Easy enough, but I can't remember how to do it except for trial-and-error, and don't want to code such a monstrosity. I figure that there's an easy algebraic solution I probably never learned, or else someone else has coded such a monstrosity, and one way or another I'm right: CPAN has Math::Project, which is exactly what I need. It's part of a larger package, but that's not a big deal -- and if it becomes one in the future, I'll figure some way around it. (Thanks, Milan!)

After that, I'll need to calculate the area of four different triangles, two with complete information and two others with angles and one side. CPAN has trigonometry so that's not a problem. (Thanks, Jarkko and Raphael!)

Finally, I just need to write the bounded sum operation. It should be straightforward and monotonous, so I should probably work out all the math ahead of time, write it in comments, and then work the Perl from the comments. This method's worked in the past when I have my data structures well in hand and I get the math right; if I get the math wrong, it produces shitty code, and if I get the structures wrong, I end up breaking stuff that already works half the time.

Final sentence all this has been working up to: It's clearly time to carry a pad of paper and a pen with me for a few days, work this crap all out, and see if it works in a few pertinent test cases. (Instead of writing it tonight (wrong), rewriting it for a few hours tomorrow morning, and then trying to figure out what the hell I was doing the day after that.)