Fandom

Petit Computer Wiki

ATAN (Function)

915pages on
this wiki
Add New Page
Comments0 Share

V1Edit

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

V2Edit

ATAN (Number)Edit

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)Edit

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.

V3Edit

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.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.