Jump to content
IGNORED

Atari BASIC: difference between DEG & RAD, and when to use


Recommended Posts

Mathematicians like to use radians (a full circle is 0 to 2*pi radians) because it makes exotic formulae a little bit simpler.
Normal people use degrees (a full circle is 360 degrees) for historical reasons (ancient Babylonians used it, therefore we use it).

 

Easy to convert between them:

radians = degrees * pi / 360.0

degrees = radians * 360.0 / pi

  • Like 1
Link to comment
Share on other sites

3 hours ago, stepho said:

Mathematicians like to use radians (a full circle is 0 to 2*pi radians) because it makes exotic formulae a little bit simpler.
Normal people use degrees (a full circle is 360 degrees) for historical reasons (ancient Babylonians used it, therefore we use it).

 

Easy to convert between them:

radians = degrees * pi / 360.0

degrees = radians * 360.0 / pi

I think you mean that radians = degrees * pi / 180 and degrees = radians * 180 / pi.

 

  • Like 1
Link to comment
Share on other sites

Great! Thanks for the info, guys.

 

I expect that most of my Atari trigonometry will be for games, so I think that I'll stick to DEG, unless somebody says otherwise.

 

I assume that we use can X on the screen to calculate Y, and vice versa, so DEG should make it easier. Feel free to let me know otherwise.

Link to comment
Share on other sites

On 3/6/2020 at 10:57 PM, eugenetswong said:

I assume that we use can X on the screen to calculate Y, and vice versa, so DEG should make it easier.

It probably depends what you're trying to do. Since none of the resolutions to my knowledge is 360x360 anyway you would need to scale everything:

 

10 DEG:FOR I=0 TO 359:PLOT 80+SIN(I)*30,40+COS(I)*30:NEXT I

15 RAD:PI=ATN(1)*4:FOR I=0 TO 2*PI STEP PI/58:PLOT 80+SIN(I)*20,40+COS(I)*20:NEXT I

 

Since 180/PI = 57.29, I rounded the second loop to PI/58 steps to get a full circle.

Link to comment
Share on other sites

DEG is more practical in that you can do useful things just using integer angle values which makes the program somewhat more readable.

 

Performance - a quick & dirty Basic program that assigns B=SIN(45) in a 1000 times loop, and the equivalent with RAD sees deg mode win out by about 66 seconds to 63.

The penalty could be in that the radians equivalent is a long fraction.

Trying the same with the reverse advantage - SIN(1) in radians vs the equivalent in degrees sees rad win out by about 72 seconds to 74.

 

So, I would theorise that there's probably an advantage if the angle in question is an integer which should mean DEG mode wins out most of the time.

 

 

 

Link to comment
Share on other sites

5 hours ago, Rybags said:

Performance - a quick & dirty Basic program that assigns B=SIN(45) in a 1000 times loop, and the equivalent with RAD sees deg mode win out by about 66 seconds to 63.

The trigonometric functions are evaluated as power series that takes arguments in radiants. This is mostly because it is simpler to make this series well-behaving and converging. If DEG is active, Atari Basic includes an additional multiplication for ATN to convert the output from radiants to degrees. For SIN and COS, it is a bit more complicated as the first step is an argument reduction to the quarter period of SIN (or COS), and this is a division, no matter whether it is in degrees or radiants. However, numbers are typically smaller for radiants, and thus, it is probably faster.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...