This code was adapted from SGI's reference implementation of OpenGL, namely their function "gluPerspective."
Note:
I would use "gluPerspective" directly, except for the fact that I can't always depend on having a stable OpenGL rendering context below me to hold the matrices.