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$>
References: <>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1228755542 11163 (8 Dec 2008 16:59:02 GMT)
NNTP-Posting-Date: Mon, 8 Dec 2008 16:59:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:505645

DRG <> wrote in message <>...
> ......
> 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:


and that is what should be compared with beta.

Roger Stafford