From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to find pixels inside ellipse ?
Date: Sun, 21 Aug 2011 20:53:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 38
Message-ID: <j2rr7k$sh2$>
References: <g1bsct$ggh$> <g1c6l2$b04$> <j2ellm$gt5$> <j2eomo$q1e$> <j2gopq$78p$> <j2hcup$fh9$> <j2ja2d$ebk$> <j2l4p3$cus$> <j2lfef$coo$> <j2m9gp$c3s$> <j2qsqg$583$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1313959988 29218 (21 Aug 2011 20:53:08 GMT)
NNTP-Posting-Date: Sun, 21 Aug 2011 20:53:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:740779

"Rob Comer" <> wrote in message <j2qsqg$583$>...
> By figuratively I just meant that I hadn't taken time to check your expression for r and be certain that phi was the polar angle. Now I have. It looks correct, as does your expression for theta in terms of phi.
> Your understanding of my step 2 is correct -- except that it's probably most natural to use an azimuth angle rather than a polar angle. If you have Mapping Toolbox, look at the az2parametric subfunction in ellipse1.m.
> Cheers,
> Rob
- - - - - - - - - -
Hello again Rob,

  Now that I am sure of the method used in ellipse1 (I don't have it on my system) I have compared the curve presumably generated by it with the one defined in terms of two foci.  They do generate different curves for a spherical surface, though these are rather close to one another for reasonably sized major and minor axes relative to the radius of the sphere.  The following is an example.

  Let the major axis length be 1 radian and the minor axis .5 radians.  For the curve given by ellipse1 choose a point P making an angle at the center of .3 radians with respect to the major axis.

 a = 1;
 b = .5;
 phi = .3;

Then we have for the arc distance from the center to P from ellipse1

 r = 1/sqrt(cos(phi)^2/a^2+sin(phi)^2/b^2);

If two points along the major axis are to be valid foci, the sum of the arc distances from them to the end of the minor axis must equal the sum of the arc distances from them to the end of the major axis, so the foci must be located on the major axis a distance of c on either side of the center where c is:

 c = acos(cos(a)/cos(b));

The arc distances from P to these two foci would then be:

 d1 = acos(cos(r)*cos(c)+sin(r)*sin(c)*cos(phi));
 d2 = acos(cos(r)*cos(c)-sin(r)*sin(c)*cos(phi));

These calculations result in

 d1+d2 = 2.00481761

whereas they should have added up to 2*a = 2.0 if this were an "ellipse" according to the foci definition.  The curves are therefore very close but definitely not the same.

Roger Stafford