﻿ COS Function ---------------------------------------------------------------------------- Action Returns the cosine of an angle given in radians. Syntax COS( x) Remarks The argument x can be of any numeric type. The cosine of an angle in a right triangle is the ratio between the length of the side adjacent to the angle and the length of the hypotenuse. COS is calculated in single precision if x is an integer or single-precision value. If you use any other numeric data type, COS is calculated in double precision. To convert values from degrees to radians, multiply the angle (in degrees) times --180 (or .0174532925199433). To convert a radian value to degrees, multiply it by 180-- (or 57.2957795130824). In both cases, - - 3.141593. See Also ATN, SIN, TAN Example The following example plots the graph of the polar equation r = nq for values of n from 0.1-1.1. This program uses the conversion factors x = cos(q) and y = sin(q) to change polar coordinates to Cartesian coordinates. The figure plotted is sometimes known as the Spiral of Archimedes. CONST PI = 3.141593 SCREEN 1 . COLOR 7' Gray background. WINDOW (-4,-6)-(8,2) ' Define window large enough for biggest spiral. LINE (0,0)-(2.2 * PI,0),1' Draw line from origin to the right. ' Draw 10 spirals. FOR N = 1.1 TO .1 STEP -.1 PSET (0,0)' Plot starting point. FOR Angle = 0 TO 2 * PI STEP .04 R = N * Angle' Polar equation for spiral. ' Convert polar coordinates to Cartesian coordinates. X = R * COS(Angle) Y = R * SIN(Angle) LINE -(X,Y),1' Draw line from previous point to new point. NEXT Angle NEXT N