eugenetswong Posted March 5, 2020 Share Posted March 5, 2020 How do we know when to use each? Quote Link to comment Share on other sites More sharing options...
+Eyvind Bernhardsen Posted March 5, 2020 Share Posted March 5, 2020 They change the transcendental functions between degrees (a full circle is 360) and radians (a full circle is 2*pi). So after a DEG, SIN(180) returns 0 and COS(180) will return -1. If you switch to radians with RAD, you need to use pi (eg SIN(3.1415927)) to get the same results. 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 5, 2020 Share Posted March 5, 2020 It's just 2 ways of expressing the same thing, like using feet or metres. But it comes in handy as systems of the day tended to use one or the other, so converting programs was made easier given the option to choose which one. 1 Quote Link to comment Share on other sites More sharing options...
stepho Posted March 6, 2020 Share Posted March 6, 2020 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 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 6, 2020 Share Posted March 6, 2020 360 degrees - conveniently that has lots of factors and is also the number of days a year was believed to have at some point. Quote Link to comment Share on other sites More sharing options...
StickJock Posted March 6, 2020 Share Posted March 6, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
eugenetswong Posted March 6, 2020 Author Share Posted March 6, 2020 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. Quote Link to comment Share on other sites More sharing options...
stepho Posted March 9, 2020 Share Posted March 9, 2020 On 3/6/2020 at 3:26 PM, StickJock said: I think you mean that radians = degrees * pi / 180 and degrees = radians * 180 / pi. Yes, you are correct. Quote Link to comment Share on other sites More sharing options...
carlsson Posted March 10, 2020 Share Posted March 10, 2020 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. Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 10, 2020 Share Posted March 10, 2020 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. Quote Link to comment Share on other sites More sharing options...
thorfdbg Posted March 10, 2020 Share Posted March 10, 2020 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. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 12, 2020 Share Posted March 12, 2020 If your using degrees in a game and know the angles will always be an integer, you can speed things considerably by pre-calculating the values in the range you need and use a lookup table in your code in an array. 1 Quote Link to comment Share on other sites More sharing options...
eugenetswong Posted March 19, 2020 Author Share Posted March 19, 2020 Guys, thanks for your info. I appreciate the input. I am confident that most uses of DEG and RAD would be used for real time calculations, such as in 2 programs in the older magazines, since we could use arrays and loops to draw the shape. This info makes me excited. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.