## ATAN2 missing?

### ATAN2 missing?

The ATAN2 function appears to missing.

a = 0.5

b = -0.765

c = atan2(a, b)

PRINT "c = ", c

END

Start program
No such variable line # 5
cdeaglejr

Posts: 8
Joined: Fri Jun 19, 2015 6:32 am

### Re: ATAN2 missing?

Agree. I've got Control BASIC v0.79. Gives the same error!
Andries Pretorius

Posts: 37
Joined: Thu Nov 01, 2012 1:57 pm
Location: Johannesburg, South Africa

### Re: ATAN2 missing?

ATAN2 was first implemented in the Control BASIC v0.75 firmware.

I therefore tested ATAN2 with the following firmware versions:
Control BASIC v0.75
Control BASIC v0.76
Control BASIC v0.77
Control BASIC v0.78
Control BASIC v0.79
Control BASIC v0.80

I can confirm that ATAN2 ONLY works in the Control BASIC v0.75 firmware and NONE of the subsequent firmware versions up to v0.80.

Maybe Daniel can help here!

Regards

Andries Pretorius
Andries Pretorius

Posts: 37
Joined: Thu Nov 01, 2012 1:57 pm
Location: Johannesburg, South Africa

### Re: ATAN2 missing?

Here's a four quadrant inverse tangent subroutine named ATAN3. It determines angles between 0 and 2 PI radians.

Code: Select all
`' demo_atan3.bas' June 24, 2015' demonstrates how to intereact with the ATAN3 subroutinedtr = PI / 180.0rtd = 180.0 / PIangle_deg = 222.25678' convert angle to radiansangle_rad = dtr * angle_deg' compute sin and cosine of anglea = sin(angle_rad)b = cos(angle_rad)' call four quadrant inverse tangentGOSUB ATAN3:' print resultsprint " "print "user-defined angle = ", angle_deg, " degrees"print " "print "a = ", aprint "b = ", bprint " "print "angle from ATAN3   = ", rtd * c, " degrees"ENDATAN3:  ' four quadrant inverse tangent function  ' input  '  a = sine of angle  '  b = cosine of angle  ' output  '  c = angle (0 =< c <= 2 * pi : radians)  '''''''''''''''''''''''''''''''''''''''''  pidiv2 = PI / 2.0  x = a  GOSUB SIGN:  sgn_a = sgn  x = b  GOSUB SIGN:  sgn_b = sgn  IF (ABS(a) < 1.0e-10) THEN    c = (1.0 - sgn_b) * pidiv2    RETURN  ELSE    c = (2.0 - sgn_a) * pidiv2  ENDIF  IF (ABS(b) < 1.0e-10) THEN    RETURN  ELSE    c = c + sgn_a * sgn_b * (ABS(ATAN(a / b)) - pidiv2)  ENDIFRETURN''''''''''''''''''''''''''''''SIGN:' sign of a variable subroutine' input'  x = argument' output'  sgn = sign of x''''''''''''''''''IF (x > 0.0) THEN   sgn = 1.0ENDIFIF (abs(x) <= 1.0e-12) THEN   sgn = 0.0ENDIFIF (x < 0.0) THEN     sgn = -1.0ENDIFRETURN`

Here are the results from the demo;

Start program

user-defined angle = 222.25678 degrees

a = -0.672454395
b = -0.7401385589

angle from ATAN3 = 222.25678 degrees

Program Ended.
cdeaglejr

Posts: 8
Joined: Fri Jun 19, 2015 6:32 am 