Factor some geometry functions out into their own file.
Add support for raytracing against triangle meshes.
Minor refactoring.