Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 820493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:29:00+00:00 2026-05-15T02:29:00+00:00

I want to improve a collision system. Right now I detect if 2 irregular

  • 0

I want to improve a collision system.

Right now I detect if 2 irregular objects collide if their bounding rectangles collide.

I want to obtain the for rectangle the corresponding ellipse while for the other one to use a circle. I found a method to obtain the ellipse coordinates but I have a problem when I try to detect if it intersects the circle.

Do you know a algorithm to test if a circle intersects an ellipse?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:29:01+00:00Added an answer on May 15, 2026 at 2:29 am

    Short answer: Solving exactly for whether the two objects intersect is complicated enough to be infeasible for the purpose of collision detection. Discretize your ellipse as an n-sided polygon for some n (depending on how accurate you need to be) and do collision detection with that polygon.

    Long answer: If you insist on determining if the smooth ellipse and circle intersect, there are two main approaches. Both involve solving first for the closest point to the circle’s center on the ellipse, and then comparing that distance to the circle’s radius.

    Approach 1: Use a parametrization of the ellipse. Transform your coordinates so that the ellipse is at the origin, with its axes aligned to the x-y axes. That is:

    • Center of ellipse: (0,0)
    • Center of circle: c = (cx, cy)
    • Radius of circle: r
    • Radius of x-aligned axis of ellipse: a
    • Radius of y-aligned axis of ellipse: b.

    The equation of the ellipse is then given by a cos(t), b sin(t). To find the closest point, we want to minimize the square distance
    || (a cos t, b sin t) - c ||^2. As Jean points out, this is “just calculus”: take a derivative, and set it equal to 0. Unless I’m missing something, though, solving the resulting (quite nasty) equation for t is not possible analytically, and must be approximated using e.g. Newton’s Method.
    Plug in the t you find into the parametric equation to get the closest point.

    • Pro: Numerical solve is only in one variable, t.
    • Con: You must be able to write down a parametrization of the ellipse, or transform your coordinates so that you can. This shouldn’t be too hard for any reasonable representation you have of the ellipse. However, I’m going to show you a second method, which is much more general and might be useful if you have to generalize your problem to, say, 3D.

    Approach 2: Use multidimensional calculus. No change of coordinates is necessary.

    • Center of circle: c = (cx, cy)
    • Radius of cirlce: r
    • Ellipse is given by g(x, y) = 0 for a function g. For instance, per Curd’s answer you might use g(x,y) = distance of (x,y) from focus 1 + distance of (x,y) from focus 2 – e.

    Finding the point on the ellipse closest to the center of the circle can then be phrased as a constrained minimization problem:

    Minimize ||(x,y) - c||^2 subject to g(x,y) = 0

    (Minimizing the square distance is equivalent to minimizing the distance, and much more pleasant to deal with since it’s a quadratic polynomial in x,y.)

    To solve the constrained minimization problem, we introduce Lagrange multiplier lambda, and solve the system of equations

    2 * [ (x,y) -c ] + lambda * Jg(x,y) = 0
    g(x,y) = 0
    

    Here Jg is the gradient of g. This is a system of three (nonlinear) equations in three unknowns: x, y, and lambda. We can solve this system using Newton’s Method, and the (x,y) we get is the closest point to the circle’s center.

    • Pro: No parametrization needs to be found
    • Pro: Method is very general, and works well whenever writing g is easier than finding a parametric equation (such as in 3D)
    • Con: Requires a multivariable Newton solve, which is very hairy if you don’t have access to a numerical method package.

    Caveat: both of these approaches technically solve for the point which extremizes the distance to the circle’s center. Thus the point found might be the furthest point from the circle, and not the closest. For both methods, seeding your solve with a good initial guess (the center of the circle works well for Method 2; you’re on your own for Method 1) will reduce this danger.

    Potential Third Approach?: It may be possible to directly solve for the roots of the system of two quadratic equations in two variables representing the circle and ellipse. If a real root exists, the objects intersect. The most direct way of solving this system, again using a numerical algorithm like Newton’s Method, won’t help because lack of convergence does not necessary imply nonexistence of a real root. For two quadratic equations in two variables, however, there may exist a specialized method that’s guaranteed to find real roots, if they exist. I myself can’t think of a way of doing this, but you may want to research it yourself (or see if someone on stackoverflow can elaborate.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working solution for my problem but now I want to improve
I'm a self taught developer (about 3 years now), and I want to improve
I am porting an existing application to C# and want to improve performance wherever
Looking to improve my IF statement, and I want to keep my code looking
I want your suggestion on the following pseudo-code. Please suggest how could I improve
I want to improve my site usability by providing users some kind of related
I want to improve the cross platform behavior of a java application. However, its
I want to improve the roundtrip time when doing TDD. I guess the total
I want to improve knowledge of different programming patterns. I want to write a
I want to improve one of my Facebook apps by allowing the users to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.