home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 101.img / QB45-1.ZIP / SINEWAVE.BAS < prev    next >
BASIC Source File  |  1988-09-28  |  897b  |  31 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 2π radians:
  10. WINDOW (0, -1.1)-(2 * 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 (2 * PI, 0)-(0, 0), , , Style%  ' Draw the x (horizontal) axis.
  21.    IF Cycles > 0 THEN
  22.       ' Start at (0,0) and plot the graph:
  23.       FOR X = 0 TO 2 * PI STEP .01
  24.          Y = SIN(Cycles * X)    ' Calculate the y coordinate.
  25.          LINE -(X, Y)           ' Draw a line from the last
  26.                                 ' point to the new point.
  27.       NEXT X
  28.    END IF
  29. LOOP WHILE Cycles > 0
  30.  
  31.