atan2
04-10-2015, 08:23 AM
Post: #1
 Powersoft Member Posts: 100 Joined: Feb 2015
atan2
Dear Forum members,

Is there a working example for the HP Prime to show the atan2(y,x) function?

Thanks.

Jan Kromhout
Hellevoetsluis-NL
04-10-2015, 11:35 AM (This post was last modified: 04-10-2015 11:56 AM by Martin Hepperle.)
Post: #2
 Martin Hepperle Senior Member Posts: 333 Joined: May 2014
RE: atan2
If you have to roll your own atan2(y,x) function have a look at

http://en.wikipedia.org/wiki/Atan2

Martin
04-10-2015, 11:41 AM
Post: #3
 DrD Senior Member Posts: 1,132 Joined: Feb 2014
RE: atan2
Here is a little atan2(y,x) program especially useful as a subroutine:

Code:
 EXPORT atan2(y,x) BEGIN // atan2 returns coordinates in correct angle for all four quadrants     CASE     if x==0 AND y==0 then return "undefined"; end;         // x=0, y=0       if x>0 then return atan(y/x); end;                     // x>0     if x<0 AND y>=0 then return atan(y/x)+pi; end;         // x<0, y>=0     if x==0 AND y>0 then return pi/2; end;                 // x=0, y>0     if x<0 AND y<=0 then return atan(y/x)-pi; end;         // x<0, y<0     if x==0 AND y<0 then return -pi/2; end;                // x=0, y<0    END;     return;   END;
04-11-2015, 03:39 AM
Post: #4
 Helge Gabert Senior Member Posts: 467 Joined: Dec 2013
RE: atan2
Don't forget there is also ARG

ARG(x+i*y)=ATAN2(y,x),

and ARG is built-in.
04-12-2015, 09:27 PM
Post: #5
 jte Member Posts: 165 Joined: Feb 2014
RE: atan2
(04-11-2015 03:39 AM)Helge Gabert Wrote:  Don't forget there is also ARG

ARG(x+i*y)=ATAN2(y,x),

and ARG is built-in.

I've just tried ARG for a handful of values and have noticed a few minor details that might be worth keeping in mind.
• Both home ARG and CAS arg respect the angle measure setting (radians / degrees).
• Home ARG returns an error for zero while the CAS arg returns 0.0.
• The CAS arg deals with large and small magnitude arguments in a different manner than home ARG does. (With CAS epsilon as 1E-12 and degrees angle measure, CAS arg returns undef for 1E309+i and for 1E-12*i, 90.0 for 1e-12+1e-11*i, and 84.2894068625 for 1.01e-12+1.01e-11*i.)
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)