Where should I project a polygon corner when it is behind me? I am creating a simple 3D engine as a learning project to get the hang on spherical trigonometry. I am using the following approach.
1. A model consists of a lot of triangular faces.
2. Each triangle is rendered through finding where the vectors pointing to the corners of it intersect a plane. This creates a flat projection I draw to the screen.



I have already implemented this, and it works great, except when some of the corners of a triangle are located behind me.



It is quite obvious what the problem is: The vector pointing to the corner is never intersecting the plane. But I need a point to render the projection, as a part of the triangle is visible.
That causes trouble. I can not place the third corner anywhere on my projection plane, as the edges of the projected triangle are diverging when they escape the field of view.

Logically, the edges of the projected triangle are thus pointing towards two different points on the plane outside the frame (or on the frame border, depending on taste and size of data types).



Suddenly having to deal with rendering a four-sided polygon instead of a triangle is no problem, my rasterization algorithms are flexible. I can however not figure out how to calculate the locations of the new "off-screen" points. How can I find them?
Trying to explain a problem seems to help the thought process. This is what eventually worked for me:

I realized that I can easily find the point (in 3D space) where a line between two of the corners brakes through one of the walls in my pyramid field of view, given the coordinates of the out-of-view corner and one of the visible ones. It is only a matter of finding the intersection between two lines. The position of the intersection point gives away the height on the frame wall.



Self answer, yes, but nothing came to mind before posting at SE.