0

I have the bounds (x from, x to ...) of an ellipse (and thus its radius and center), x and y of a point A that is in the ellipse and an angle. I want to get point B to which the angle points (from point A) and that lies on the ellipse.

This is what I can do:

center_x = (x_from + x_to) / 2

center_y = (y_from + y_to) / 2

radius_x = center_x - x_from

radius_y = center_y - y_from

How to go on?


@All: Thank you very much! The formula works perfectly well!

  • Does your ellipse has its semi-axes parallel to the $x$- and $y$-axes? – mrf Jun 09 '12 at 23:20
  • Yes, if I got you right. x_from, x_to, y_from and y_to is my method to describe the ellipse, as if you draw an ellipse in Windows' Paint program. – human-man Jun 09 '12 at 23:23

2 Answers2

1

The ellipse can be described by the equation: $$\left(\frac{x-x_0}{a}\right)^2 + \left(\frac{y-y_0}{b}\right)^2 = 1$$ where $(x_0, y_0)$ is the center and $a$ and $b$ are the lengths of the ellipse's semi-axes (what you call radius_x and radius_y).

If $A = (p,q)$ and the given angle is $\alpha$, then the ray starting at $A$ in the direction $\alpha$ can be described by $$(x,y) = (p + t\cos\alpha, q + t\sin\alpha) \qquad \text{where $t > 0$}.\tag{*}$$

Plug this expression into the equation for the ellipse and solve for $t$. (This will be a quadratic equation; you want its positive root.) Plug this value of $t$ into (*) to get the coordinates of $B$.

mrf
  • 43,639
  • Thank you! Can you please explain the format "(x,y)"? (I'm not so familiar with what is common for mathematical thinking.) – human-man Jun 10 '12 at 00:31
1

You need to state as an explicit assumption that the main axes of the ellipse are parallel to the coordinate axes -- if that is not true, knowing the extreme $x$ and $y$ values is not enough to describe the ellipse.

However, if we can make the assumption, the way to proceed is as follows. First compute the lengths of the main semiaxes: $$ a = \frac12(x_{\rm max}-x_{\rm min}) \qquad b = \frac12(y_{\rm max}-y_{\rm min}) $$ Then the equation for the ellipse is $$ \tag{*} \left(\frac{x-x_{\rm center}}{a}\right)^2 + \left(\frac{y-y_{\rm center}}{b}\right)^2 = 1$$ Since you also know the angle $\theta$ (between $A$ and your sought point, I assume), you know there's a positive $t$ such that $$ \tag{**} x= x_A+t\cos\theta \qquad y = y_A+t\sin\theta $$ Substitute these expressions for $x$ and $y$ into $(*)$ and you get a quadratic equation in $t$. Solve that, choosing the positive root (which always exists if $A$ is inside the ellipse), and put the resulting $t$ back into $(**)$.