<blockquote>
<p>Now suppose in this case for front face where V and N are parallel to each then they makes angle 0°.</p>
</blockquote>
<p>In your example, V and N are pointing in opposite directions. The angle between them is 180 degrees, so the cosine is -1. Similarly:</p>
<blockquote>
<p>Again I consider the case for back face where V along with N then they makes angle 180°.</p>
</blockquote>
<p>If V and N are pointing in the same direction, then the angle between them is 0 degrees, so the cosine is 1.</p>
<p>You have these backwards; that's why you're getting the wrong value.</p>

CC BY-SA 4.0
2022-01-27T20:48:19.440Z
if I consider N for front face with the same direction of V that means if I consider N is opposite  side of front face, then V and N has 0° angle, then above formula flipped for front face and back face?
S. M.
CC BY-SA 4.0
2022-01-27T23:35:21.390Z
@Sagorika The formula is sensitive to the way you calculate *N* from the points of the face. If *N = (A,B,C)*, then also *-N = (C,B,A)*. So when checking each face, you must be careful to order the points correctly and consistently.
luser droog
CC BY-SA 4.0
2022-01-28T06:32:07.317Z
@luser droog if I consider N for front face with the same direction of V that means if I consider N is opposite side of front face, then V and N has 0° angle, then above formula flipped for front face and back face, that means front face formula and angles becomes back face formula and angle and vice versa? Am I correct?
S. M.
CC BY-SA 4.0
2022-01-28T07:03:16.820Z
@Sagorika: Your comment didn't make any more sense the second time you repeated it than the first. N cannot be both the front face and the opposite side of the front face at the same time. So your question is gibberish.
Nicol Bolas
CC BY-SA 4.0
2022-01-28T07:22:14.790Z
@Nicol Bolas I am saying instead of N pointing towards me, it pointing opposite side of the front face then front face formula and angle flipped with back face formula and angle?
S. M.
CC BY-SA 4.0
2022-01-28T14:21:47.660Z
@Sagorika: In the "front face formula", N is what *defines* which face is the front face. You cannot point N in the opposite direction without also saying that the front face is in the opposite direction. At which point, it is a different polygon.
Nicol Bolas
CC BY-SA 4.0
2022-01-30T04:34:29.150Z
@Sagorika The formula I have in mind is *N(A,B,C)=(B-A)×(C-B)* where × is the cross product. If you exchange A and C, then the resulting vector will point in the opposite direction. I encountered this problem when trying to draw [the Utah teapot](https://stackoverflow.com/a/14600918/733077). Some of my patches had  a different orientation (and I didn't want to change the data) so I couldn't use the normal vector to determine visibility at all. But if you have control of the code(and/or data) then you can arrange things so all the faces point outward.
luser droog
CC BY-SA 4.0
2022-01-30T04:36:30.020Z
@Sagorika I'm not certain that this is the problem you are having. But I do know that this is one problem that could lead to the situation you describe so it's a good wrinkle for the cold iron.
luser droog
CC BY-SA 4.0
2022-01-27T20:32:29.500Z
2022-01-27T20:32:29.500Z
Nicol Bolas
<p>Suppose I have one convex polyhedron, I need to detect back face. And <span class="math-container">$N=(A, B, C)$</span> is normal vector of polygon surface and vector <span class="math-container">$V$</span> in viewing direction. According to books formula and internet content if <span class="math-container">$V. N&gt;0$</span> then polygon is back face otherwise front face.</p>
<p>We know that <span class="math-container">$V. N=|V|.|N|cos\theta$</span> from this when we consider
<span class="math-container">$\pi/2&lt;\theta&lt;=\pi$</span> then <span class="math-container">$V. N&lt;0$</span> <span class="math-container">$\implies$</span> front face. And when we consider  <span class="math-container">$0°&lt;=\theta&lt;=\pi/2$</span> then <span class="math-container">$V. N&gt;0$</span> <span class="math-container">$\implies$</span> back face.</p>
<p><strong>Case:1</strong>
Now suppose in this case for front face where <span class="math-container">$V$</span> and <span class="math-container">$N$</span> are parallel to each then they makes angle 0°.Then we get <span class="math-container">$V. N&gt;0$</span> but according to books formula when <span class="math-container">$V. N&lt;0$</span> then we will get front face.</p>
<p>:<a href="https://i.sstatic.net/r0DBF.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/r0DBF.jpg" alt="enter image description here" /></a></p>
<p><strong>Case:2</strong> Again I consider the case for back face where <span class="math-container">$V$</span> along with <span class="math-container">$N$</span> then they makes angle 180°.Then
we get <span class="math-container">$V. N&lt;0$</span> but according to books formula when <span class="math-container">$V. N&gt;0$</span> then we will get back face. <a href="https://i.sstatic.net/kMOMV.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kMOMV.jpg" alt="enter image description here" /></a></p>
<p>My question is where I mistaken to understand the detect the back face and front face for the above cases with formula
<span class="math-container">$V. N &gt;0   or   &lt;0?$</span></p>

<rendering><polygon>
Back face detection
S. M.
# Back face detection

(Asked by: username_0 on 2022-01-27)

Suppose I have one convex polyhedron, I need to detect back face. And $N=(A, B, C)$ is normal vector of polygon surface and vector $V$ in viewing direction. According to books formula and internet content if $V. N>0$ then polygon is back face otherwise front face.

We know that $V. N=|V|.|N|cos\theta$ from this when we consider
$\pi/2<\theta<=\pi$ then $V. N<0$ $\implies$ front face. And when we consider $0°<=\theta<=\pi/2$ then $V. N>0$ $\implies$ back face.

**Case:1**
Now suppose in this case for front face where $V$ and $N$ are parallel to each then they makes angle 0°.Then we get $V. N>0$ but according to books formula when $V. N<0$ then we will get front face.

:[![enter image description here](https://i.sstatic.net/r0DBF.jpg)](https://i.sstatic.net/r0DBF.jpg)

**Case:2** Again I consider the case for back face where $V$ along with $N$ then they makes angle 180°.Then
we get $V. N<0$ but according to books formula when $V. N>0$ then we will get back face. [![enter image description here](https://i.sstatic.net/kMOMV.jpg)](https://i.sstatic.net/kMOMV.jpg)

My question is where I mistaken to understand the detect the back face and front face for the above cases with formula
$V. N >0 or <0?$

**Tags:** rendering, polygon


---

## 1 answers

### Answer by username_1 on 2022-01-27. Score: 2 | Accepted answer

> Now suppose in this case for front face where V and N are parallel to each then they makes angle 0°.

In your example, V and N are pointing in opposite directions. The angle between them is 180 degrees, so the cosine is -1. Similarly:

> Again I consider the case for back face where V along with N then they makes angle 180°.

If V and N are pointing in the same direction, then the angle between them is 0 degrees, so the cosine is 1.

You have these backwards; that's why you're getting the wrong value.

> **Comments:**
> **username_0**: if I consider N for front face with the same direction of V that means if I consider N is opposite  side of front face, then V and N has 0° angle, then above formula flipped for front face and back face?  
> **username_2**: @Sagorika The formula is sensitive to the way you calculate *N* from the points of the face. If *N = (A,B,C)*, then also *-N = (C,B,A)*. So when checking each face, you must be careful to order the points correctly and consistently.  
> **username_0**: @username_2 if I consider N for front face with the same direction of V that means if I consider N is opposite side of front face, then V and N has 0° angle, then above formula flipped for front face and back face, that means front face formula and angles becomes back face formula and angle and vice versa? Am I correct?  
> **username_1**: @Sagorika: Your comment didn't make any more sense the second time you repeated it than the first. N cannot be both the front face and the opposite side of the front face at the same time. So your question is gibberish.  
> **username_0**: @username_1 I am saying instead of N pointing towards me, it pointing opposite side of the front face then front face formula and angle flipped with back face formula and angle?  
> **username_1**: @Sagorika: In the "front face formula", N is what *defines* which face is the front face. You cannot point N in the opposite direction without also saying that the front face is in the opposite direction. At which point, it is a different polygon.  
> **username_2**: @Sagorika The formula I have in mind is *N(A,B,C)=(B-A)×(C-B)* where × is the cross product. If you exchange A and C, then the resulting vector will point in the opposite direction. I encountered this problem when trying to draw [the Utah teapot](https://stackoverflow.com/a/14600918/733077). Some of my patches had  a different orientation (and I didn't want to change the data) so I couldn't use the normal vector to determine visibility at all. But if you have control of the code(and/or data) then you can arrange things so all the faces point outward.  
> **username_2**: @Sagorika I'm not certain that this is the problem you are having. But I do know that this is one problem that could lead to the situation you describe so it's a good wrinkle for the cold iron.  

---

