From: "Sadik " <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Plot ellipse
Date: Tue, 13 Jan 2009 18:11:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <gkilfl$1rn$>
References: <gkidke$9f9$>
Reply-To: "Sadik " <>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1231870261 1911 (13 Jan 2009 18:11:01 GMT)
NNTP-Posting-Date: Tue, 13 Jan 2009 18:11:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: comp.soft-sys.matlab:511264

"Glyn Hudson" <> wrote in message <gkidke$9f9$>...
> Hi everyone,
> I'm trying to plot an ellipse in 2D given co-ordinates of the two foci and the distance between a point on the ellipse and the foci. What do you think is the best way to approach this? 
> Glyn. 

I will make a correction [simplification, explanation, appendix] to my previous reply.

You don't need to write x as a function of y to determine its range. Once you write y as a function of x and the other constants x0, y0, a and b, then you will see that

y = y0 +/- b* sqrt(1-(x-x0)^2/a^2) .........................  (*)

Since we don't want any complex value for y, we would require the term in the square root be non-negative. For which range of x is it non-negative?

x0-sqrt(a) <= x <= x0+sqrt(a) 

So you have your xmin = x0-sqrt(a)  and xmax x0 + sqrt(a) .

The rest is the same as before. After you have your vector of values for x, you substitute it in (*) above, once for y0 + ... to get the vector yUpper, and once for y0 - ... to get the vector yLower. Then, as you already know,

hold on

Of course, all these describe the case when the major [or minor] axis is parallel to the x-axis. In the oblique case, however, you can follow the similar "we don't want complex" approach.

Hope this helps.