bas7ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
TAN Function Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'The following example uses the TAN function to compute the height of an
'object using the distance from the object and the angle of elevation. The
'program draws the triangle produced by the base and the computed height.
 
SCREEN 2                       'CGA screen mode.
 
INPUT "LENGTH OF BASE: ", Baselen
INPUT "ANGLE OF ELEVATION (DEGREES,MINUTES): ", Deg, Min
 
Ang = (3.1415928# / 180) * (Deg + Min / 60)  'Convert to radians.
Height = Baselen * TAN(Ang)                  'Calculate height.
PRINT "HEIGHT ="; Height
Aspect = 4 * (200 / 640) / 3   'Screen 2 is 640 x 200 pixels.
H = 180 - Height
B = 15 + (Baselen / Aspect)
LINE (15, 180)-(B, 180)        'Draw triangle.
LINE -(B, H)
LINE -(15, 180)
 
LOCATE 24, 1: PRINT "Press any key to continue...";
DO
LOOP WHILE INKEY$ = ""