What would be the "definitive" formula to calculate chainstay length from sprocket size, chainring size and number of chain links?
Unfortunately my crummy draw tool won't let me place the lines very accurately, but this is the idea:



The radii describe right angles to the two chain lines.  I'm pretty sure the two wrap angles on the two sprockets will add to 360 degrees.  The upper quadrilateral has been divided into a rectangle (if my lines were square) and a right triangle.  The hypotenuse of the triangle is the chain stay length.  The short side is the large sprocket radius minus the small sprocket radius.  

From the chain stay length and the sprocket radii you can compute the straight chain length and (with a bit of trig) the two wrap angles.  Given a wrap angle and a sprocket radius you can compute the amount of chain on the sprocket.