0

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. enter image description here 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).

MarianD
  • 2,963
  • The problem should be equivalent to finding the circumference with center in your point and externally tangent to the ellipse. – dfnu Mar 20 '19 at 21:27
  • At least $2$ and at most $4$ normals pass through a given point. The furthest one is what you want. See another answer of mine here. – Ng Chung Tak Mar 21 '19 at 01:20
  • There’s no simple formula for this. The answer that you’ve gotten explains how to find such a formula, but it will involve solving a trigonometric equation or something else equally unpleasant. – amd Mar 21 '19 at 18:06

1 Answers1

1

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$.

Fly by Night
  • 32,886
  • There will generally be multiple solutions to that equation. Is there a way other than brute-force checking to pick out the one that gives the minimum distance? – amd Mar 20 '19 at 21:55
  • You'd only expect four solutions for $0 \le t < 2\pi$. You can eliminate two immediately by looking at which quadrant your point is in. That leaves two to check. – Fly by Night Mar 21 '19 at 16:59