This was just me messing around with linear algebra. It is very buggy and messy. It has no redeeming qualities. For your own sanity, I recommend you do not look inside.
It works by taking the position vector relative to the camera, expressing it in the camera's local coordinate system, and flattening it onto the screen based on how far the plane it lies in is from the camera. At least that's the idea. I'm almost certain that I haven't properly normalized all of the direction vectors (and I think I have some sign errors in my cross products), but life is too short for correct code.