Game Development Reference
In-Depth Information
Figure A.11
Combining displacement vectors so that one
sphere is considered stationary
is given by c m + t d . Our goal is to find t, the time at which the moving
sphere touches the stationary sphere. The geometry involved is illustrated
in Figure A.12.
Figure A.12
Dynamic intersection of
circles or spheres
To solve for t, we begin by calculating an intermediate vector e as the
vector from c m to c s , and set r equal to the sum of the radii:
e = c s
c m ,
r = r m + r s .
According to the law of cosines (see Section 1.4.5), we have
r 2 = t 2 + e 2 − 2t e cosθ.
By applying the geometric interpretation of the dot product (see Sec-
tion 2.11.2) and simplifying, we get
r 2 = t 2 + e 2 − 2t e cosθ,
r 2 = t 2 + e e − 2t( e d ),
0 = t 2 − 2( e d )t + e e − r 2 .
 
Search WWH ::




Custom Search