Find extreme points of a rotated ellipse equation on a given axis

422 Views Asked by At

I'm having hard time figuring out how to find the points where it is most extreme on the X and Y axis.

For example lets say I have an equation that describes an ellipse that is rotated:

(x * RadiusX * Rx + y * RadiusX * Ux)^2 + (x * RadiusY * Ry + y * RadiusY * Uy)^2 = RadiusY^2

Here is a graph picture that may explain better: https://i.stack.imgur.com/PgZxT.png

How can I find the points where it will be most extreme on each axis

Please keep in mind the values for variables RadiusX, RadiusY, Rx, Ry, Ux, Uy are known.

An example with values:

((x * 1 * 0.70711) + (y * 1 * -0.70711))^2 + ((x * 1.414213 * -0.70711) + (y * 1.414213* -0.70711))^2 = 1.414213 * 1.414213

Thanks in advance!

1

There are 1 best solutions below

0
On BEST ANSWER

First, simplify the definition of your ellipse into $$(x u_x + y u_y)^2 + (x v_x + y v_y)^2 = 1 \tag{1}\label{NA1}$$ If we define $$\vec{p} = \left [ \begin{matrix} x \\ y \end{matrix} \right ], \quad \vec{u} = \left [ \begin{matrix} u_x \\ u_y \end{matrix} \right ], \quad \vec{v} = \left [ \begin{matrix} v_x \\ v_y \end{matrix} \right ] \tag{2}\label{NA2}$$ then $\eqref{NA1}$ is equivalent to $$(\vec{p}\cdot\vec{u})^2 + (\vec{p}\cdot\vec{v})^2 - 1 = 0 \tag{3}\label{NA3}$$ where $\vec{u}$ and $\vec{v}$ are the ellipse semi-axis vectors, with their lengths reciprocals of their corresponding semi-axis lengths. For example, using $u_x = 1/r_x$, $u_y = 0$, $v_x = 0$, $v_y = 1/r_y$, you get an axis-aligned ellipse with semi-axes $r_x$ and $r_y$.

If you solve $\eqref{NA3}$ for $y$ you get $$y = - \frac{x (u_x u_y + v_x v_y) \pm \sqrt{ u_y^2 + v_y^2 - x^2 (u_x v_y - u_y v_x) }}{u_y^2 + v_y^2}$$ It reaches its extrema (minimum and maximum $y$ coordinate) when its derivative is zero. Similarly, solving for $\eqref{NA3}$ for $x$ you get $$x = - \frac{y (u_x u_y + v_x v_y) \pm \sqrt{ u_x^2 + v_x^2 - y^2 (u_x v_y - u_y v_x) }}{u_x^2 + v_x^2}$$ and it too reaches its extrema (minimum and maximum $x$ coordinate) when its derivative is zero.

If you work those out, you get the axis-aligned bounding box, $$\left\lbrace \begin{aligned} x &= \pm \frac{u_x u_y + v_x v_y}{(u_x v_y - v_x u_y) \sqrt{u_x^2 + v_x^2}} \\ y &= \pm \frac{u_x u_y + v_x v_y}{(u_x v_y - v_x u_y) \sqrt{u_y^2 + v_y^2}} \end{aligned} \right . \tag{4a}\label{NA4a}$$ or, equivalently, $$\left\lbrace \begin{aligned} c &= \frac{u_x u_y + v_x v_y}{u_x v_y - v_x u_y} = \frac{\vec{u} \cdot \vec{v}}{\vec{u} \times \vec{v}} \\ x &= \pm \frac{c}{\sqrt{u_x^2 + v_x^2}} \\ y &= \pm \frac{c}{\sqrt{u_y^2 + v_y^2}} \end{aligned} \right . \tag{4b}\label{NA4b}$$ where $\cdot$ denotes dot product, and $\times$ the 2D analog of vector cross product.