Post Reply 
atan2
04-10-2015, 11:41 AM
Post: #3
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;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
atan2 - Powersoft - 04-10-2015, 08:23 AM
RE: atan2 - Martin Hepperle - 04-10-2015, 11:35 AM
RE: atan2 - DrD - 04-10-2015 11:41 AM
RE: atan2 - Helge Gabert - 04-11-2015, 03:39 AM
RE: atan2 - jte - 04-12-2015, 09:27 PM



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