Polar equation of an ellipse given the origin coordinates and major and minor axis lengths?

34.8k Views Asked by At

I've been trying to create a polar equation that will give me all points on an ellipse with the independent variable being theta and the dependent variable being the radius, but I'm having a great deal of trouble wrapping my mind around how to accomplish such a feat.

The ellipse is going to be defined by it's origin's x and y positions, it's major axis length, and it's minor axis length. It can be assumed that in every case the major axis is perfectly vertical and the minor axis is perfectly horizontal.


Not really relevant to the answer, but just a little more background information. I am trying to program hit detection for a game that uses ellipses for the hitbox boundaries. The reason I need an equation like this is that I am going to be determining whether an object is within the hitbox by comparing the distance from the ellipse's center to a point on the object with the distance from the ellipse's center to the point along the ellipse in the direction of the point on the object.


Any feedback is appreciated.

4

There are 4 best solutions below

1
On BEST ANSWER

Divide your major and your minor axes by $2$ to get the "major radius" and "minor radius". Call these $a$ and $b$. (A major and minor axis length don't uniquely specify an ellipse, you'll still have to decide if it's wider than long or longer than wide, so you'll have to make that choice here).

Substitute them into the usual equation of an ellipse.

$$\left(\frac{x}{a}\right)^2 + \left(\frac{y}{b}\right)^2 = 1$$

Substitute in $x = r\cos(\theta), y = r\sin(\theta)$.

$$ \begin{aligned} \left(\frac{r\cos(\theta)}{a}\right)^2 + \left(\frac{r\sin(\theta)}{b}\right)^2 &= 1\\ \frac{r^2\cos^2(\theta)}{a^2} + \frac{r^2\sin^2(\theta)}{b^2} &= 1\\ \frac{r^2\cos^2(\theta)b^2}{a^2b^2} + \frac{r^2\sin^2(\theta)a^2}{b^2a^2} &= 1\\ r^2(b^2\cos^2(\theta) + a^2\sin^2(\theta)) &= a^2b^2\\ r^2 &= \frac{a^2b^2}{b^2\cos^2(\theta) + a^2\sin^2(\theta)}\\ r &= \frac{ab}{\sqrt{b^2\cos^2(\theta) + a^2\sin^2(\theta)}}\\ \end{aligned} $$

0
On

The equation for an ellipse entered at $(h,k)$ is:

$$(\frac{x-h}{a})^2+(\frac{y-k}{b})^2=1$$

Now note this holds where $r$ is the distance from a point to the origin:

$x=r\cos(\theta)$

And likewise

$y=r\sin(\theta)$

These two equations can be seen easily, just pick a point on the $2$ dimensional $\mathbb{R^2}$ plane, then draw the length $r$ from the origin to the point and the angle $\theta$ it makes with the $x$-axis. Then use trig to come up with equations.

Now it is just a matter of plugging in and solving for $r$ (note that the quadratic equation might be of use)

4
On

HINTS:

For a start we can use standard parametric equations $ (r,\theta),(x,y) $ and then convert to Cartesian coordinates, translate by $ (h,k) $ re-convert to required polar equation $ \rho = f( \gamma ). $

$$ r= p/ (1- \epsilon \cos \theta) ; x= r \cos\theta + h ; y= r \sin \theta +k ; \rho^2 = x^2 + y^2 ; \gamma = \tan^{-1} {\frac{y}{x}}; $$

There are two ellipse tangent limits for $\gamma$ limits each of constant value, two variable radius $\rho$ limits for each intermediate $\gamma$ value as shown.

Mathematica program if helpful:

ecc = 0.6; p = 1.; h = 3.; k = 2.; r[t_] = p/(1 - ecc Sin[t]);
ell = ParametricPlot[ r[t] {Cos[t], Sin[t]}, {t, 0, 2 Pi}, 
   PlotStyle -> {Thick, Magenta}];
rho[t_] = Sqrt[r[t]^2 + h^2 + k^2 + 2 r[t] ( h Cos[t] + k Sin[t])]; 
gam[t_] = ArcTan[   r [t] Cos[t] +h, r [t] Sin[t] +k ] ;
displ = ParametricPlot[ 
   rho[t] {Cos[gam[t]], Sin[gam[t]]}, {t, 0, 2 Pi}, 
   PlotStyle -> {Thick, Red}];
Show[{ell, displ}, PlotRange -> All, GridLines -> Automatic]

DisplEllipse

To find polar angle $ \gamma $ of tangential contact to radius vector, next use the condition

$$ \frac{d \gamma}{d \rho} =0 $$

and then proceed radial transversal intersection limits...

(If you want to locate target area of displaced ellipses, calculation with pole/polar of ellipse is perhaps best, but it is not mentioned here).

3
On

The right way to check if a point is inside or outside the ellipse is to compute

$$\frac{(x-x_c)^2}{a^2}+\frac{(y-y_c)^2}{b^2}-1$$ and test the sign: negative inside, positive outside.

Polar coordinates aren't really helpful.