CONSTANT PI = (22/7)
ANGLE=45
K=5
GOSUB DR
DON:
A$=INKEY$
IF A$="" THEN GOTO DON
IF A$=CHR$(27) THEN END
IF RIGHT$(A$,1)="K" THEN ANGLE=ANGLE-K:GOSUB DR
IF RIGHT$(A$,1)="M" THEN ANGLE=ANGLE+K:GOSUB DR
GOTO DON
DR:
LOCATE 1,1
PRINT " "
IF ANGLE<0 THEN ANGLE=0
IF ANGLE>360 THEN ANGLE=360
LOCATE 1,1
PRINT "COSINE (";ANGLE;" = ";COS(ANGLE*PI/180)
RETURN
...For a little more on the subject... This might make it easier to remember...
(Sometimes it's easier to remember if you understand What is going on and Why...)
Degrees:
Full Circle = 360 degrees
Half Circle = 180 degrees
Radians:
Full Circle = 2*Pi
Half Circle = Pi
So you can set up the convertion equation like this
Code:
D R
----- = ------
360 2 * Pi
Where: D = Degrees
R = Radians
To get Radians from Degrees...
R = (D * 2 * Pi) / (360)
Which can be simplified by dividing the Whole Equation by 2 leaving:
R = (D * 1 * Pi) / (180) R = D * Pi / 180
To get Degrees from Radians...
D = (R * 360) / (2 * Pi)
Which can also be simplified by dividing the Whole Equation by 2 leaving:
D = (R * 180) / (1 * Pi)
-or- D = R * 180 / Pi
Now, as stated above (by dpaulson) Pi = 3.141592654
*If you forget this value, Open up you windows calculator,
Set it to scientific mode in the View menu,
Then Click the Pi button At the bottom...
You should get this: 3.1415926535897932384626433832795
The more decimal places you use, the more acurate the calculations will be... But 8 or 9 places is plenty...
So, now that you know what the conversions are, you can save calculating time in your program by doing this...
pre calculate the Constants for the Degree and Radian conversions...
'Rad' will be (Pi / 180) or 0.017453293
'Deg' will be (180 / Pi) or 57.295779505
So, At the top of your program, Type... Const Pi = 3.141592654, Rad = 0.017453293, Deg = 57.295779505
Then you can simply Use...
R = D * Rad
or
D = R * Deg
Instead of...
R = D * Pi / 180
or
D = R * 180 / Pi
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.