Check if point is in ellipse

1.5k Views Asked by At

I have point of center, and height/width of ellipse. I have calculated coors for upper and side borders. How can i check if point is in the ellipse? All my points are in polar coordinates

2

There are 2 best solutions below

0
On BEST ANSWER

You can find foci of the ellipse since you know length of major and minor axes and vertices.

Now for any point $P$, if sum of its distances from the two foci $F_1$ and $F_2$ is less than the length of major axis, it lies inside ellipse.

That is the point lies inside ellipse if $$PF_1 + PF_2 < 2a$$

where $2a$ is the length of major axis.

0
On

I would convert from polar to Cartesian first. For this application, polar coordinates are inconvenient unless the ellipse is centered at the origin or has one of its foci there.

From your data, generate an equation of the ellipse in the form $f(x,y)=0$. If the ellipse is aligned with the coordinate axes, then you can use the standard form $f:(x,y)\mapsto{(x-x_0)^2\over a^2}+{(y-y_0)^2\over b^2}-1$, otherwise you’ll end up with the general conic $Ax^2+Bxy+Cx^2+Dx+Ey+F$. Make sure that the coefficients of $x^2$ and $y^2$ are positive. Then, just plug your point into $f$ and examine the sign of the result: the point is internal to the ellipse if $f(x,y)\lt0$, on the ellipse if $f(x,y)=0$ and external to it if $f(x,y)\gt0$.

Update: If the ellipse is centered at the origin or has a focus at the origin, then working directly in polar coordinates isn’t too bad. For an ellipse centered at the origin, the relevant equation is $$r(\theta) = {ab \over \sqrt{b^2\cos(\theta-\phi)^2 + a^2\sin(\theta-\phi)^2}}.$$ Here, $\phi$ is the angle that the major axis makes with the positive $x$-axis ($\theta = 0$) and $a$ and $b$ are the half-axis lengths. For a given point, you can compare the value of $r$ produced by the right-hand side of this equation to the point’s $r$-coordinate to determine where it lies relative to the ellipse.

For an ellipse with a focus at the origin, the equation is instead $$r(\theta) = {a(1-e^2) \over 1-e\cos(\theta-\phi)},$$ where $e$ is the eccentricity $\sqrt{1-b^2/a^2}$.