Advertisement Jump to content
Sign in to follow this  

Help with handling ellipse collisions

This topic is 2492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok so I know how to calculate if two ellipses have intersected, but now I want to move my ellipses after they have intersected(ie one slides off of the other). I have an idea on how to do it in my head, but it will only work if two ellipses are the same size. I want to be able to handle the collision of two axis aligned ellipses of any size. For starters, I think I probably need to find the point of intersection but I'm not sure how to do that. Any help would be appreciated, thanks.

Here's the code for seeing if two ellipses have intersected:

//Returns true if the pixel is inside the ellipse
bool CollisionCheckPixelInEllipse(Vector2d pixel, Vector2d center, Vector2d radius)
int asquare = radius.x * radius.x;
int bsquare = radius.y * radius.y;
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
bool CollisionCheckEllipses(Vector2d center1, Vector2d radius1, Vector2d center2, Vector2d radius2)
int radiusSumX = (int) (radius1.x + radius2.x);
int radiusSumY = (int) (radius1.y + radius2.y);
return CollisionCheckPixelInEllipse(center1, center2, Vector2d(radiusSumX, radiusSumY));

EDIT: It appears this thread was posted twice by accident
EDIT2: I might just not use ellipse collisions after all

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!