How to find x,y coordinates on rotated ellipse where tangent to bounding box

geometrylinear algebratrigonometry

I'm trying to find exact points(black points) on ellipse where the outside bounding box tangent to as in below image:

enter image description here

I've calculated bounding box coordinates as in below formula

enter image description here

enter image description here

from that post:
How to get the limits of rotated ellipse?

and the rotated ellipse formula is:

enter image description here

Everything seems easy, just put x and find y but I'm having trouble to get a formula like in unrotated ellipse:

enter image description here

enter image description here

I am searching for the same equations for rotated ellipses.

I searched for that kind a formula since I want to put it on a code and it'll be dynamic but no luck.
Is there any good represantion of x and y coordinates on rotated ellipse? or is there any different way to find those points?

Thanks a lot!

Best Answer

Points $(x, y)$ fulfill the rotated ellipse equation $$\frac{\left( x \cos\theta - y \sin\theta \right)^2}{a^2} + \frac{\left( y \cos\theta + x \sin\theta \right)^2}{b^2} = 1$$ So, substitute $x$ or $y$ with the corresponding maximum, $$\begin{aligned} x &= \pm \sqrt{a^2 \cos^2 \theta + b^2 \sin^2 \theta} \\ y &= \pm \sqrt{a^2 \sin^2 \theta + b^2 \cos^2 \theta} \\ \end{aligned}$$ and solve for the other coordinate.

For the right side (positive $x$ boundary), we get $$\begin{aligned} x_R &= \sqrt{a^2 \cos^2\theta + b^2 \sin^2\theta} \\ y_R &= \frac{(b^2 - a^2) \sin(2\theta)}{2 \sqrt{a^2 \cos^2\theta + b^2 \sin^2\theta}} \\ \end{aligned}$$ and for the left side (negative $x$ boundary), $$\begin{aligned} x_L &= -\sqrt{a^2 \cos^2\theta + b^2 \sin^2\theta} \\ y_L &= -\frac{(b^2 - a^2) \sin(2\theta)}{2 \sqrt{a^2 \cos^2\theta + b^2 \sin^2\theta}} \\ \end{aligned}$$ For the top side (positive $y$ boundary), we get $$\begin{aligned} x_T &= \frac{(b^2 - a^2) \sin(2\theta)}{2 \sqrt{a^2 \sin^2\theta + b^2\cos^2\theta}} \\ y_T &= \sqrt{a^2 \sin^2\theta + b^2\cos^2\theta} \\ \end{aligned}$$ and for the bottom side (negative $y$ boundary), $$\begin{aligned} x_B &= -\frac{(b^2 - a^2) \sin(2\theta)}{2 \sqrt{a^2 \sin^2\theta + b^2\cos^2\theta}} \\ y_B &= -\sqrt{a^2 \sin^2\theta + b^2\cos^2\theta} \\ \end{aligned}$$ and the axis-aligned bounding box is $(x_L, x_B) - (x_R, y_T)$.

Note that $\sin(2\theta) = \frac{1}{2}\cos(\theta)\sin(\theta)$; you do not need inverse trigonometric functions at all: $a$, $b$, $\cos\theta$, and $\sin\theta$ suffice.

(If the notation is unclear, $\cos^2\theta = ( \cos\theta )^2$.)

Related Question