I am working on a 2D RPG with a turned based battle system.

Characters move inside the confines of an ellipse movement area and when they leave the boundaries will be pushed back inside. (i.e they should be able to walk around the inner part of the ellipse). Previously we were using circles for the movement area and I wrote the code to do circle inside circle collision (not too difficult because the radius is always the same) but since we will change to using an ellipse, I am trying to update the code.

I have looked at a few solutions for actual ellipse collision/intersection and the math looks..daunting. My questions are:

  1. Are there any clean solutions to doing circle inside ellipse collision/intersection?

  2. Should I be approximating the ellipse collision in another way? Like using an n-sided polygon?

I am a bit lost on how to approach this and could really use some advice.

  • 1
    \$\begingroup\$ @AlexandreVaillancourt That question is helpful, but I think it's not a duplicate: this question asks how to confine a circle in an ellipse. That one just detects whether it would be necessary. \$\endgroup\$
    – Anko
    Commented Sep 26, 2015 at 13:11
  • \$\begingroup\$ @Anko The question was edited since I flagged it. Not sure if removing the comment will remove the flag, though.. \$\endgroup\$
    – Vaillancourt
    Commented Sep 26, 2015 at 13:15
  • \$\begingroup\$ There is here a question about circle-ellipse collision. It could help you with part of your issue :) \$\endgroup\$
    – Vaillancourt
    Commented Sep 26, 2015 at 13:26
  • \$\begingroup\$ Yes it helps a little bit. But as one of the comments states "...but not for doing circle-in-ellipse testing (or circle-ellipse intersection testing), which is actually a substantially harder problem." So that is a small part of the problem. \$\endgroup\$
    – Arbel
    Commented Sep 26, 2015 at 13:53
  • 2
    \$\begingroup\$ Naive approach: compute the smaller ellipse resulting from substracting the radius of the circle from the focal points of the main elipse. Then: is the center of the circle inside that smaller ellipse? (math.stackexchange.com/questions/76457/…) \$\endgroup\$
    – ADB
    Commented Sep 28, 2015 at 21:43

1 Answer 1


My initial answer to this is: Do not use an ellipse, unless you have a really good reason. My second answer would be: If you want to detect collision with complex shapes, use a library and/or engine. My third answer would be: If you want to see real progress on a game project: Use a set of good libraries, minimum.

And lastly, If you want to actually finish a game project: Take the time to learn a nice engine inside out, and stick to that. It is just my opinion ultimately, but I would say programming and game building are barely related. Even a small game is a vastly complex application that will take years to complete even if you use libraries.

In school, you will likely learn programming logic and theory, when it comes to actually producing software, in business especially, you will most likely just learn how to use /other/, production level software. You can do years of training on just one development suite, and some of the most employable tech skills are software certifications.

That's my honest advice after a few years of hobby game design.

  • \$\begingroup\$ I ended up taking your advice and used a framework (Box2D). The rewrite was a bit time consuming but now the collision works flawlessly inside an ellipse, or any shape for that matter! \$\endgroup\$
    – Arbel
    Commented Jul 6, 2016 at 0:49
  • \$\begingroup\$ It works in c++, java and android, I'm pretty sure. Not to mention, it's free. Not a lot of doc on the jbox but still super useful. \$\endgroup\$ Commented Jul 6, 2016 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .