Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Issues with atan2 function.. please advise!
Date: Mon, 8 Dec 2008 16:59:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 17
Message-ID: <ghjjom$asr$1@fred.mathworks.com>
References: <6f0f0e86-f955-43bc-a085-588a9cea560e@j32g2000yqn.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1228755542 11163 172.30.248.38 (8 Dec 2008 16:59:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 8 Dec 2008 16:59:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:505645

DRG <grimesd2@gmail.com> wrote in message <6f0f0e86-f955-43bc-a085-588a9cea560e@j32g2000yqn.googlegroups.com>...
> ......
> This works fine, except when you try to run the code at (X,Y) =
> (1,0.5). In fact, you get strange results anywhere that satisfies the
> following condition.
> 
> X > g, and (Y >= f - crad, Y <= f + crad)
> ......

  The "issue" is not with 'atan2'.  It's the inequality testings in your code that are inappropriate.  If I understand you correctly, you are trying to determine whether two vectors with angles 'gamma' and 'ang' with respect to the x-axis, respectively, have an acute angle between them of less than or greater than beta.  Such an angle can be computed this way:

 abs(mod(gamma-ang+pi,2*pi)-pi)

and that is what should be compared with beta.

Roger Stafford