Game Development Reference
In-Depth Information
What we want to solve for is the value of t , where the distance between the two
spheres is equal to the sum of their radii, because that is the specific point where
the intersection occurs. This can be represented mathematically as follows:
The problem with this equation is we need some way to get rid of the length oper-
ation. The trick to this is remembering that the length squared of a vector is the
same thing as the dot product between and itself:
So if we were to square both sides of our sphere comparison statement, we would
get the following:
Nowthat wehavethisequation, weneedtosolvefor t .Thisprocessisalittle com-
plicated. First, let's substitute the full equations for P ( t ) and Q ( t ):
Then we can do a little bit of factoring and grouping to make the equation a bit
more palatable:
To simplify it further, we can introduce a couple substitutions:
Because the dot product is distributive over addition, we can then apply the FOIL
(first, outside, inside, last) rule between the ( A + Bt ) terms:
Search WWH ::




Custom Search