Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radian to Degrees

Status
Not open for further replies.

bert3626

Instructor
Nov 6, 2003
2
US
How do I get a Cos to print in degrees
 
pi = 3.141592654
degrees = radians * 180/pi

David Paulson

 
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 &quot;COSINE (&quot;;ANGLE;&quot;) = &quot;;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

I hope this Helps...
Good Luck,
-Josh S

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top