I was wondering if you could help me figure this out.
I've been trying to write some code to calculate the farthest point on an ellipse $(150w, 85h)$ from a given point $(55x, 20y)$ within the ellipse. Could anyone help walk me through the steps to achieve this? I've looked through a few examples and it still isn't clicking yet.
Is there a way to find the farthest point on the ellipse from a point within the ellipse without using brute force (comparing each point on the ellipse to the point within the ellipse)?
Assume we only know the ellipse size/location, and the point's location.
Also, the numbers I am using are made up so feel free to change them to illustrate your point.
- Ellipse: size $(150w, 85h)$, center $(0x, 0y)$ (is known)
- Point within ellipse: $(55x, 20y)$ (is known)
Thanks!
Edited for clarification. I appreciate the responses so far, but I'm looking for a formula where I don't have to compare the point within the ellipse to each point on the ellipse's edge (ideally).
HINT
Given a point $P$ on the ellipse and a point $Q$ not on the ellipse, the distance from $P$ to $Q$ is a local extremum if the chord $PQ$ is perpendicular to the tangent line to the ellipse at $P$.
We can parametrise the ellipse $\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$ by $P(a\cos t,b\sin t)$. Take a point $Q(u,v)$ not on the ellipse, then $$\vec{PQ}=(u-a\cos t){\bf i} + (v-b\sin t){\bf j}$$
The tangent to the ellipse at $P$ is parallel to $(-a\sin t){\bf i}+(b\cos t){\bf j}$.
Using the dot/scalar product, these two are perpendicular if, and only if, $$(-a\sin t)(u-a\cos t) + (b\cos t)(v-b\sin t)=0$$
For fixed $a$, $b$, $u$ and $v$, solve this for $t$.