COS Function Programming Example
The following program plots the graph of the polar equation r = nAngle for
values of n from 0.1-1.1. This program uses the conversion factors
x = cos(Angle) and y = sin(Angle) to change polar coordinates to Cartesian x,y
coordinates. 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