Game Development Reference
In-Depth Information
Figure 14.2
Dot products are used to see if a polygon is facing the camera
the dot product will be negative.
If you want the actual angle represented by the dot product, you must perform an
arccosine operation. If you remember those hazy trig classes at all, you ' ll know that
the arccosine isn
s lucky,
because dot products from unit vectors have exactly the same range. So where
'
t defined everywhere, only between values [
1.0, 1.0]. That
'
'
s the
problem? The arccosine will always return positive numbers.
The dot product is directionless, giving you the same result no matter which vector
you send in first: A dot B is the same as B dot A. Still not convinced this is a prob-
lem? Let
s assume that you are using the dot product to determine the angle between
your current direction and the direction vector that points to something you are
targeting.
In Figure 14.3, the white arrow is the current direction, and the gray arrows are ori-
ented 45 degrees away about the Y-axis. Notice that one of the gray arrows is point-
ing straight to our teapot target, but the other one is pointing in a completely wrong
direction. Yet, the dot products between the white direction vector and both gray
vectors are the same because the angles are the same!
'
 
Search WWH ::




Custom Search