Calculate the Y value of an arc of an ellipse given X

141 Views Asked by At

Before I say anything else, let me just state, that I am only in high school and going in Precalculus this upcoming school year, which is probably why I am having this issue in the first place. And if any more information is needed, just let me know!

I am building a game for Android this summer and I am about 2/3 of the way to completion. I'm drawing an ellipse and I can calculate that much, as I know the top-most coordinate, bottom-most coordinate, left-most coordinate, and right-most coordinate. Thus, I also know the width/height as well as the center. However, the ellipse isn't drawn completely, but rather only from a start angle to a "sweep" angle. So let's say that I draw only 100° of the ellipse, from 20 degrees to 120 degrees, which causes a resulting arc, as described here. And so, is it possible to modify the algebraic standard equation of an ellipse(e.g. $(x-h)^2\over a^2$ + $(y-k)^2\over b^2$ = 1) in order to select only a given portion of it using a specified range of degree in order to select the arc, and from there find the corresponding y value to a known x (e.g (200, y?)). However, if there is another method that would make it substantially easier or more efficient, then I just ask that the most detail possible be given so that I could implement it into code.

What I am trying to achieve, in essence.

1

There are 1 best solutions below

6
On BEST ANSWER

If your angle is $\theta$ you know $(y-k)/(x-h) = \tan{\theta}$ or $x-h = (y-k)/\tan{\theta}$. Plug this into your equation for your ellipse to get

$\displaystyle \frac{(y-k)^2}{(a\tan{\theta})^2}+\frac{(y-k)^2}{b^2}=1$

So there you have an equation that you can solve readily for $y-k$. Just be careful about which quandrant of the plane you are in.