I've just spent the last few hours scouring nigh on every math site on the net, and wouldn't you know it, the equation I was after could be found here all along. That'll teach me to go looking elsewhere without checking here first. Thanks for the code.