# How do I calculate the length of a vertical offset of the major axis in an elllipse?

Please forgive my terminology if it is imprecise. In the diagram below, for known values of X, Y and Z, I am need to calculate the value (length) of M. (It's not homework, it's for an SVG animation...)

-

In the following I will take $X$ and $Y$ as the semiaxes of the ellipse. The equation of the ellipse is $$\frac{x^2}{X^2}+\frac{y^2}{Y^2}=1.$$ You know $Z$, and you want to find $M$ sucha that the point $(M,Z)$ is on the ellipse. Substituting in the equation and a little algebra gives $$M=\frac{X}{Y}\sqrt{Y^2-Z^2}.$$

-

HINT:

Ellipse equation is $$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$

where $a$ is $X/2$ and $b$ is $Y/2$ according to your diagram.

Put $y=N$ in ellipse equation. $$\frac{x^2}{a^2}+\frac{N^2}{b^2}=1$$ and find two coordinate values of x. Then subtract them to find M.

-