Path: news.mathworks.com!not-for-mail 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$1@newscl01ah.mathworks.com> References: <g1bsct$ggh$1@fred.mathworks.com> <g1c6l2$b04$1@fred.mathworks.com> <j2ellm$gt5$1@newscl01ah.mathworks.com> <j2eomo$q1e$1@newscl01ah.mathworks.com> <j2gopq$78p$1@newscl01ah.mathworks.com> <j2hcup$fh9$1@newscl01ah.mathworks.com> <j2ja2d$ebk$1@newscl01ah.mathworks.com> <j2l4p3$cus$1@newscl01ah.mathworks.com> <j2lfef$coo$1@newscl01ah.mathworks.com> <j2m9gp$c3s$1@newscl01ah.mathworks.com> <j2qsqg$583$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-02-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1313959988 29218 172.30.248.47 (21 Aug 2011 20:53:08 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sun, 21 Aug 2011 20:53:08 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:740779 "Rob Comer" <rob.comer.nospam@mathworks.com> wrote in message <j2qsqg$583$1@newscl01ah.mathworks.com>... > 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