Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic Misc > ARCTANXY Functi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1433 of 1466
Post > Topic >>

ARCTANXY Function

by david.williams@[EMAIL PROTECTED] (David Williams) Mar 4, 2008 at 10:03 AM

-> I'm trying to port some Zeno programs over to BASIC and I'm stuck on the

-> Zeno function ARCTANXY(x,y).  According to the Zeno manual, 
-> it should be equal to ATN(y/x) when x and y are both non-zero. 
-> I created a BASIC function that does that but the results don't match 
-> the Zeno output.  Does anyone here know exactly what calculation to 
-> use for ARCTANXY?  TIA 
  
Here's how I usually code it in QBasic. 
  
FUNCTION Ang(X, Y) 
  SELECT CASE SGN(X) 
    CASE 1: Ang = ATN(Y / X) 
    CASE -1: Ang = ATN(Y / X) + PI 
    CASE ELSE: Ang = SGN(Y) * PI / 2 
  END SELECT 
END FUNCTION 
  
Of course PI has to be pre-defined. 
  
The FUNCTION produces an angle in the range -PI/2 <= Ang < 3*PI/2. 
That's the complete circle, but if you want to adjust the range to, 
e.g., 0 to 2*PI, you'd have to add a bit of fiddling. 
  
Note that Ang is *not* equal to ATN(Y/X) if X is negative. ATN doesn't 
produce the complete circle of values. 
  
                              dow




 2 Posts in Topic:
ARCTANXY Function
david.williams@[EMAIL PRO  2008-03-04 10:03:08 
Re: ARCTANXY Function
"Tom Lake" <  2008-03-04 13:02:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 19:17:21 CDT 2008.