Graphics Reference
In-Depth Information
6.2.11 The Dot Product in Back-Face Detection
A standard way of identifying back-facing polygons relative to the virtual
camera is to compute the angle between the polygon's surface normal and the
line of sight between the camera and the polygon. If this angle is less than
90
◦
the polygon is visible; if it is equal to or greater than 90
◦
the polygon is
invisible. This geometry is shown in Figure 6.9. Although it is obvious from
Figure 6.9 that the right-hand polygon is invisible to the camera, let's prove
algebraically that this is so. Let the camera be located at (0,0,0) and the
polygon's vertex is (10, 10, 40). The normal vector is [5 5
2]
T
−
⎡
⎤
5
5
−
⎣
⎦
n
=
2
=
5
2
+5
2
+(
||
n
||
−
2)
2
=7
.
348
The camera vector
c
is
⎡
⎤
⎡
⎤
0
−
10
−
10
⎣
⎦
⎣
⎦
c
=
0
−
10
=
−
10
0
−
40
−
40
=
(
||
c
||
−
10)
2
+(
−
10)
2
+(
−
40)
2
=42
.
426
therefore
||
n
|| · ||
c
||
cos(
β
)=5
×
(
−
10) + 5
×
(
−
10) + (
−
2)
×
(
−
40)
7
.
348
×
42
.
426
×
cos(
β
)=
−
20
−
20
cos(
β
)=
=
−
0
.
0634
7
.
348
×
42
.
426
β
=cos
−
1
(
0
.
0634) = 93
.
635
◦
−
which shows that the polygon is invisible.
> 90
< 90
visible
camera
invisible
Fig. 6.9.
The angle between the surface normal and the camera's line of sight deter-
mines the polygon's visibility.