SIN Function Programming Example
The example plots the graph of the polar equation r = 1 + sin n (Angle). This
figure is sometimes known as a cardioid, owing to its resemblance to a
heart when n equals 1.
'***Programming example for the SIN function***
CLS
CONST PI = 3.141593
SCREEN 1 : COLOR 1,1 'Medium resolution, blue background.
WINDOW (-3,-2)-(3,2) 'Convert screen to Cartesian coordinates.
INPUT "Number of petals = ", N
CLS
PSET (1,0) 'Set initial point.
FOR Angle = 0 TO 2*PI STEP .02
R = 1 + SIN(N*Angle) 'Polar equation for "flower."
X = R * COS(Angle) 'Convert polar coordinates to
Y = R * SIN(Angle) 'Cartesian coordinates.
LINE -(X,Y) 'Draw line from previous point to new point.
NEXT
END