Game Development Reference
In-Depth Information
2
4
3
5
2
4
3
5
c x −r x
c y + r y
c z −r z
c x + r x
c y + r y
c z −r z
p BackUpperLeft =
,
p BackUpperRight =
,
2
4
3
5
2
4
3
5
c x −r x
c y −r y
c z −r z
c x + r x
c y −r y
c z −r z
p BackLowerLeft =
,
p BackLowerRight =
.
20.
(a) Use the sign of the dot product between v and x−p to determine whether the point
x is in front of or behind the NPC. This follows from the geometric interpretation of
the dot product,
v (x−p) = vx−pcos θ,
where θ is the angle between v and x−p.
Both v and x−p are always positive, leaving the sign of the dot product entirely
up to the value of cos θ. If cos θ > 0 then θ is less than 90 and x is in front of the
NPC. Similarly, if cos θ < 0 then θ is greater than 90 and x is behind the NPC.
The special case of v(x−p) = 0 means that x lies either directly to the left or right
of the NPC. If this case does not need to be handled explicitly, it can arbitrarily be
assigned to mean either in front of or behind.
(b) (1) x is in front of the NPC.
−3
4
−2
0
0
−2
−4
=
= (5)(3) + (−2)(−4) = 23
(2) x is in front of the NPC.
4
2
−2
1
6
−3
4
−2
=
= (5)(4) + (−2)(2) = 16
(3) x is behind the NPC.
−6
0
−2
−3
4
−2
−4
=
= (5)(−3) + (−2)(−4)
= −7
(4) x is behind the NPC.
−3
4
−2
−4
7
−2
−1
3
=
= (5)(−1) + (−2)(3) = −11
(5) x is in front of the NPC.
8
1
−2
5
5
−3
4
−2
=
= (5)(8) + (−2)(1) = 38
(6) x is in front of the NPC.
−3
4
−2
−3
0
−2
−4
=
= (5)(0) + (−2)(−4) = 8
Search WWH ::




Custom Search