home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l170 / 3.ddi / SOURCE / SINEWAVE.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-09-22  |  884 b   |  32 lines

  1. SCREEN 2
  2.  
  3. ' View port sized to proper scale for graph:
  4. VIEW (20, 2)-(620, 172), , 1
  5.  
  6. CONST PI = 3.141592653589#
  7.  
  8. ' Make window large enough to graph sine wave from
  9. ' 0 radians to π radians:
  10. WINDOW (0, -1.1)-(PI, 1.1)
  11.  
  12. Style% = &HFF00                 ' Use to make dashed line.
  13.  
  14. VIEW PRINT 23 TO 24             ' Scroll printed output in
  15.                                 ' rows 23 and 24.
  16. DO
  17.    PRINT TAB(20);
  18.    INPUT "Number of cycles (0 to end): ", Cycles
  19.    CLS
  20.    LINE (PI, 0)-(0, 0), , , Style%' Draw the x (horizontal) axis.
  21.    IF Cycles > 0 THEN
  22.  
  23.       ' Start at (0,0) and plot the graph:
  24.       FOR X = 0 TO PI STEP .01
  25.          Y = SIN(Cycles * X)    ' Calculate the y coordinate.
  26.          LINE -(X, Y)           ' Draw a line from the last
  27.                                 ' point to the new point.
  28.       NEXT X
  29.    END IF
  30. LOOP WHILE Cycles > 0
  31.  
  32.