I have a simple test scene setup in a toy software rasterizer. I have a plane facing the +Z axis at the origin and the camera is facing -Z at Z=2. Everything works fine and looks good at that orientation but if I turn the camera to face -X it renders a distorted triangle long after the plane has left the view of the camera. I have been trying to debug this for weeks and can't find the problem. I assume I am missing somthing silly, maths are not my strong suit. I have check my matrix/vector math and it seems good to me.
Here is the realevent code: NOTE it's emited from the "ReadableC backend" of a toy language so the formating is a little strange. Also I am fully aware there are important parts of software rasterization that are missing i the implementation. It has been simplified to isolate the bug.