I have a collision detection class that works by finding the distance between the centres and whether that distance is small enough to be a collision (see Collision Detectio
I had the same problem recently. Circle overlap is easy to determine. With ellipses it's trickier, but not that bad. You play around with the ellipse equation for a while, and the result comes up:
//Returns true if the pixel is inside the ellipse
public bool CollisionCheckPixelInEllipse(Coords pixel, Coords center, UInt16 radiusX, UInt16 radiusY)
{
Int32 asquare = radiusX * radiusX;
Int32 bsquare = radiusY * radiusY;
return ((pixel.X-center.X)*(pixel.X-center.X)*bsquare + (pixel.Y-center.Y)*(pixel.Y-center.Y)*asquare) < (asquare*bsquare);
}
// returns true if the two ellipses overlap
private bool CollisionCheckEllipses(Coords center1, UInt16 radius1X, UInt16 radius1Y, Coords center2, UInt16 radius2X, UInt16 radius2Y)
{
UInt16 radiusSumX = (UInt16) (radius1X + radius2X);
UInt16 radiusSumY = (UInt16) (radius1Y + radius2Y);
return CollisionCheckPixelInEllipse(center1, center2, radiusSumX, radiusSumY);
}