Q(uick)BASIC Function: ATN
Quick View
ATN Function
A math function that returns the arctangent of a numeric expression (the angle whose tangent is equal to the numeric expression)
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- ATN(numeric-expression)
- COS(angle)
- SIN(angle)
- TAN(angle)
Description/Parameter(s)
numeric-expression | The ratio between the sides of a right triangle. |
angle | An angle expressed in radians. |
The ATN function returns an angle in radians.
To convert from degrees to radians, multiply degrees by (PI / 180).
Example
CONST PI=3.141592654
PRINT ATN(TAN(PI/4.0)), PI/4.0 'Output is: .7853981635 .7853981635
PRINT (COS(180 * (PI / 180))) 'Output is: -1
PRINT (SIN(90 * (PI / 180))) 'Output is: 1
PRINT (TAN(45 * (PI / 180))) 'Output is: 1.000000000205103
Syntax
- ATN(numeric-expression)
Description/Parameter(s)
The numeric-expression can be of any numeric type.
ATN is evaluated by default in single precision. If numeric-expression is a double-precision value, ATN is evaluated in double precision.
The result is given in radians and is in the range -𝜋/2 to 𝜋/2 radians, where 𝜋 = 3.141593. 𝜋/2 radians equals 90 degrees.
You can convert an angle measurement from degrees to radians by multiplying the degrees by 𝜋/180, where 𝜋 = 3.141593.
To convert a radian value to degrees, multiply it by 57.2958.
Example
The following example first finds the tangent of PI/4 and then takes the arctangent of the value. The result is PI/4.
CONST PI=3.141592653
PRINT ATN(TAN(PI/4.0)), PI/4.0
Sample Output:
.78539816325 .78539816325Syntax
- ATN(numeric-expression)
Description/Parameter(s)
The argument numeric-expression can be of any numeric type.
Usage Notes
- ATN (arctangent) is the inverse of tangent (TAN) and takes the ratio of two sides of a right triangle (numeric-expression) and returns the corresponding angle. The ratio is the ratio of the lengths of the side opposite the angle and the side adjacent to the angle.
- The arctangent is given in radians and is in the range -PI/2 to PI/2 radians, where PI = 3.141593 and PI/2 radians equals 90 degrees.
- ATN is calculated in single precision if numeric-expression is an integer or single-precision value. If you use any other numeric data type, ATN is calculated in double-precision.
- To convert values from degrees to radians, multiply the angle (in degrees) times PI/180 (or .0174532925199433) where PI = 3.141593.
- To convert a radian value to degrees, multiply it by 180/PI (or 57.2957795130824) where PI = 3.141593.
See also: