bas7ex.hlp (Topic list)
COS Function Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This program uses the COS function to plot the graph of the polar
'equation r = n * Θ for ten values of n from 1.1 to 0.1. The program
'uses the transformations x = r * cos(Θ) and y = r * sin(Θ) to change
'polar coordinates (r, Θ) to Cartesian coordinates (x, y). The figure
'plotted is sometimes known as the Spiral of Archimedes.
 
CONST PI = 3.141593
'Gray background.
SCREEN 1 : COLOR 7
'Define window large enough for biggest spiral.
WINDOW (-4,-6)-(8,2)
'Draw line from origin to the right.
LINE (0,0)-(2.2*PI,0),1
'Draw ten spirals.
FOR N = 1.1 TO .1 STEP -.1
   'Plot starting point.
   PSET (0,0)
   FOR Angle = 0 TO 2*PI STEP .04
      'Polar equation for spiral.
      R = N * Angle
      'Convert polar coordinates to Cartesian coordinates.
      X = R * COS(Angle)
      Y = R * SIN(Angle)
      'Draw line from previous point to new point.
      LINE -(X,Y),1
   NEXT
NEXT