Unity best practices for determining if something is inside or outside the circumference of an ellipse

Hello,

I am try to setup an asset that needs to identify regions for biome selection. I would like to do this using ellipses so I can make an island of sorts using procedural code. Basically I need a function that will determine if a 2D point is inside our outside the circumference of an ellipses given 2 sets of x/y coordinates. The first set would determine the dimensions of the ellipse. The second set would be used to determine if the point was either inside or outside the ellipse returning Boolean.
I am pretty new to using geometry in a video game setting and am researching the math. I figured there were tons of situations where the same formulas/algorithms would be useful, e.g. target ranges, etc. I am guessing if there is not already an established way to do this easily, there are supportive libraries I am just not familiar with that might help with some of the heavier math.

Here are some of the articles I’ve been going from to try to get a handle on what I need to do so far:
http://en.wikipedia.org/wiki/Ellipse#Circumference

http://en.wikipedia.org/wiki/Elliptic_integral#Complete_elliptic_integral_of_the_second_kind

http://en.wikipedia.org/wiki/Circumference

http://www.mathopenref.com/coordparamellipse.html

http://www.mathopenref.com/coordgeneralellipse.html

http://www.mathopenref.com/coordcirclealgorithm.html

And just because I thought these would be interesting to do the same with:

http://en.wikipedia.org/wiki/Hypotrochoid

http://en.wikipedia.org/wiki/Epitrochoid

It would seem to me, plotting points along the edge of an ellipse and filling the area of an ellipse are easier (or maybe just done more often) than determining the circumference of an ellipse. Am I mistaken?

Can anyone help with how I can determine inside vs the outside of an ellipse. And as a bonus maybe explain how I can even expand on that to include procedurally generated shapes like an epitrochoid? (That would make for much more realistic shorelines, ranges, etc…)

Thank you in advance,
Boysenberry Payne

“Best practices” in Unity is not to use an ellipse. There’s no built-in collider for it, the math is harder, and it’s just a game. We’d use a capsule collider or something. A big part of making a game is identifying places where you can tweak/downgrade the specification just a little, in return for 80% less work.

So that’s why you don’t see much about odd shapes here.

If you really need an ellipse (sounds like you do): you could just do the math `(ax^2+by^2

So, the answer for me came in the form of a splatmap. Basically I make a ellipse the dimensions I want in Photoshop or GIMP (or what ever image app you use) import it into Unity and then check the sprite out using Texture2D and its methods, i.e. ellipse.GetPixel(x,y).r (using a white ellipse here). If the value is greater than 0 than I know I am in the ellipse.

The colliders weren’t doing it for me because none of this is happening in the scene, but is to effect what happens in the scene.

Also the ax^2+by^2 formula works only for plotting or placing things along the edge of a ellipse, but isn’t really helpful when it comes to telling whether something is on one side or the other of that edge.

I hope this makes it easier for someone after me. I couldn’t find an answer for it in the forums…