<p>Trying to explain a problem seems to help the thought process. This is what eventually worked for me:</p>

<p>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.</p>

<p><a href="https://i.sstatic.net/fOz83.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fOz83.png" alt="wall intersection"></a></p>

<p>Self answer, yes, but nothing came to mind before posting at SE.</p>

CC BY-SA 3.0
2016-09-07T10:32:24.703Z
Just so you know, [self answers are very welcome here](http://computergraphics.stackexchange.com/help/self-answer), whether you know the answer already or find it after posting the question.
trichoplax is on Codidact now
CC BY-SA 3.0
2016-09-05T13:32:14.480Z
2016-09-05T13:32:14.480Z
SE - stop firing the good guys
<p>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.</p>

<p><a href="https://i.sstatic.net/eoV3E.png" rel="noreferrer"><img src="https://i.sstatic.net/eoV3E.png" alt="projection"></a></p>

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

<p><a href="https://i.sstatic.net/w8Sw8.png" rel="noreferrer"><img src="https://i.sstatic.net/w8Sw8.png" alt="outside the view"></a></p>

<p>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.</p>

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

<p><a href="https://i.sstatic.net/QKBLG.png" rel="noreferrer"><img src="https://i.sstatic.net/QKBLG.png" alt="frame of view"></a></p>

<p>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?</p>

CC BY-SA 3.0
2016-09-05T12:18:31.030Z
You don't project it.  You clip the polygon it against a front clipping plane (or more generally against the view frustum) and then project those results.

I had a quick search to try to find a good page explaining the details but nothing really gave a simple/clear explanation. I could suggest a textbook if that'd help.
Simon F
CC BY-SA 3.0
2016-09-05T12:25:04.627Z
@SimonF I would appreciate a textbook suggestion. Is the 'clip' approach then suitable for rendering? Moving around in a model a made, it does not look unnatural.
SE - stop firing the good guys
CC BY-SA 3.0
2016-09-05T12:41:38.633Z
Actually it is possible to avoid near clipping by using homogeneous rendering but that has some other drawbacks.
Possible texts _include_  Watt & Watt's "Advanced Animation and Rendering Techniques"  Foley, Van Dam et al's "Computer Graphics: Principles and Practice" - It's old but clipping hasn't changed.  

I'm surprised nothing simple/clear shows up in my web searches (for example, [Wikipedia's](https://en.wikipedia.org/wiki/Clipping_(computer_graphics)#Clipping_in_3D_graphics) entry doesn't seem to contain much), but you could try searching for Weiler-Atherton or Cohen–Sutherland.
Simon F
<3d><geometry><projections><polygon><vectors>
Where should I project a polygon corner when it is behind me?
SE - stop firing the good guys
# Where should I project a polygon corner when it is behind me?

(Asked by: username_0 on 2016-09-05)

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.

[![projection](https://i.sstatic.net/eoV3E.png)](https://i.sstatic.net/eoV3E.png)

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

[![outside the view](https://i.sstatic.net/w8Sw8.png)](https://i.sstatic.net/w8Sw8.png)

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).

[![frame of view](https://i.sstatic.net/QKBLG.png)](https://i.sstatic.net/QKBLG.png)

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?

**Tags:** 3d, geometry, projections, polygon, vectors

> **Comments:**
> **username_1**: You don't project it.  You clip the polygon it against a front clipping plane (or more generally against the view frustum) and then project those results.  I had a quick search to try to find a good page explaining the details but nothing really gave a simple/clear explanation. I could suggest a textbook if that'd help.  
> **username_0**: @username_1 I would appreciate a textbook suggestion. Is the 'clip' approach then suitable for rendering? Moving around in a model a made, it does not look unnatural.  
> **username_1**: Actually it is possible to avoid near clipping by using homogeneous rendering but that has some other drawbacks. Possible texts _include_  Watt & Watt's "Advanced Animation and Rendering Techniques"  Foley, Van Dam et al's "Computer Graphics: Principles and Practice" - It's old but clipping hasn't changed.    I'm surprised nothing simple/clear shows up in my web searches (for example, [Wikipedia's](https://en.wikipedia.org/wiki/Clipping_(computer_graphics)#Clipping_in_3D_graphics) entry doesn't seem to contain much), but you could try searching for Weiler-Atherton or Cohen–Sutherland.  

---

## 1 answers

### Answer by username_0 on 2016-09-05. Score: 2

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.

[![wall intersection](https://i.sstatic.net/fOz83.png)](https://i.sstatic.net/fOz83.png)

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

> **Comments:**
> **username_2**: Just so you know, [self answers are very welcome here](http://computergraphics.stackexchange.com/help/self-answer), whether you know the answer already or find it after posting the question.  

---

