Friday, May 16, 2008

Math

A couple of nights ago, wracked by insomnia at 1 AM, I decided to give in to an impulse to try out a bit of math. Nothing too abstract, as I've found that my reasoning skills per se haven't improved, but something that required me to dot my "i"s and cross my "t"s. For those not of a mathematical bent, the details can be skipped entirely. Long story short: I was able to manipulate equations correctly in my head that normally are a bit tedious even on paper.

For those who want details (nerds!), here's the problem statement and (the essentials of) the solution, all done mentally:

Given the following line segments expressed in parametric form, tell whether they intersect.

(a + bt, c + dt), 0 <= t <= 1
(e + fs, g + hs), 0 <= s <= 1

So I set about solving for the value of s at which the two (infinite) lines would intersect.

a + bt = e + fs, c + dt = g + hs

t = (e + fs - a) / b = (g + hs - c) / d

b(g + hs - c) = d(e + fs - a)

bhs - dfs = d(e-a) - b(g-c)
s = [d(e - a) - b(g - c)] / (bh - df)

Voila!