Petit Computer Wiki
Advertisement

V1[]

Indications are, BEEP in SmileBasic V1 is identical to that in V2.

V2[]

ATAN (Number)[]

ATAN(number) returns the arctangent of the given number. The result is in radians, between approximately -pi/2 and approximately pi/2.

Note: ?(ATAN(1000)-PI()/2)*1000 shows 0.244, indicating that ATAN(value) can return a value greater than PI()/2.

ATAN (Numerator, Denominator)[]

When denominator is not zero, ATAN(numerator, denominator) returns the arctangent of the fraction (numerator/denominator). The result is in radians, between approximately -pi and approximately pi.

When denominator is zero and numerator is zero, ATAN(numerator, denominator) returns 0.

When denominator is zero, and numerator is positive, ATAN(numerator, denominator) returns 1.57080078, which is slightly greater than pi/2. If I'm right about the fixed-point representation of values, this is 6434/4096.

When denominator is zero, and numerator is negative, ATAN(numerator, denominator) returns -1.57080078, which is slightly less than -pi/2. If I'm right about the fixed-point representation of values, this is -6434/4096.

Note: ?(ATAN(0,-1)-PI)*1000 shows 0.244, indicating the result can be greater than PI(), and ?(ATAN(-1,-10000)+PI)*1000 shows -0.244, indicating the result can be less than -PI().

SmileBasic V2 does not have the inverse trigonometric functions, ASIN and ACOS. These functions can be calculated with the help of ATAN, though. To calculate ASIN(S), use the expression ATAN(S,SQR(1-S*S)). To calculate ACOS(C), use the expression ATAN(SQR(1-C*C),C). These expressions do not give very accurate results, however.

V3[]

Indications are, ATAN in SmileBasic V3 is identical to that in V2. V3 does have ASIN and ACOS functions, and these will give more accurate results than the method described above.

Advertisement