Well, I'm going to assume you work with ellipses all of the same size and the same orientation as you've mentioned they are not rotated (this latter assumption considerably simplifies the problem).
Let's consider a pair of ellipses. I'll set the coordinate origin at the center of one of them (see figure).
A collision will take place if
F = OO' - (OM + ON) <=0
By symmetry, OM = ON so:
F = OO' - 2*OM <=0
In order to find OM we need the intercept of the first ellipse with the line connecting the centers, i.e. we must solve this system of equations:
(x/a)2 + (y/b)2 = 1
y = (q/p)x
where a and b are the semiaxes and (p,q) are the coordinates of the center for the second ellipse. This leads to:
(x/a)2 + ((qx/p)/b)2 = 1
and finally:
x = abp/Sqrt(a2q2 + b2p2)
y = abq/Sqrt(a2q2 + b2p2)
so that OM = Sqrt(x2 + y2) = ab*Sqrt(p2 + q2) / Sqrt(a2q2 + b2p2)
The distance OO' is:
OO' = Sqrt(p2 + q2)
Therefore the condition for collision becomes:
0 >= F = Sqrt(p2 + q2) - 2ab*Sqrt(p2 + q2) / Sqrt(a2q2 + b2p2) =
Sqrt(p2 + q2) * [1 - 2ab / Sqrt(a2q2 + b2p2)]
Because Sqrt(p2 + q2) is positive, then:
1 - 2ab / Sqrt(a2q2 + b2p2) <= 0
which can be finally expressed more ellegantly as:
Sqrt[(p / a)2 + (q / b)2] <= 2




Reply With Quote